//
|
// HDLEZTempDetailView.m
|
// EZSDK
|
//
|
// Created by 陈启扬 on 2023/3/14.
|
//
|
|
#import "HDLEZTempDetailView.h"
|
#import "HDLEZNormalCellView.h"
|
#import "HDLEZScrollView.h"
|
@interface HDLEZTempDetailView ()
|
@property (nonatomic, strong)HDLEZScrollView *scrollV;//滚动view
|
|
@property (nonatomic, strong)UIView *passwordV;//密码view
|
@property (nonatomic, strong)UILabel *passwordL;//密码lable
|
@property (nonatomic, strong)UILabel *describeL;//描述lable
|
|
|
@property (nonatomic, strong)HDLEZNormalCellView *userV;//使用人view
|
@property (nonatomic, strong)HDLEZNormalCellView *validV;//有效期view
|
@property (nonatomic, strong)HDLEZNormalCellView *validTimeV;//生效时间view
|
@property (nonatomic, strong)HDLEZNormalCellView *expireTimeV;//失效时间view
|
@property (nonatomic, strong)HDLEZNormalCellView *useCountV;//使用次数view
|
|
@property (nonatomic, strong)HDLEZButton *deleteBtn;//删除按钮
|
|
@end
|
|
@implementation HDLEZTempDetailView
|
|
-(instancetype)init{
|
self = [super init];
|
if (self) {
|
[self initUI];
|
}
|
|
return self;
|
}
|
|
-(void)initUI{
|
//滚动view
|
_scrollV=[[HDLEZScrollView alloc] init];
|
if (@available(iOS 11.0, *)) {
|
_scrollV.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
}
|
[self addSubview:_scrollV];
|
[_scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(self);
|
make.right.left.bottom.equalTo(self);
|
}];
|
_scrollV.contentSize=CGSizeMake(HDLEZ_APP_SCREEN_WIDTH, 665);
|
|
//密码view
|
_passwordV=[[UIView alloc] init];
|
[_scrollV addSubview:_passwordV];
|
[_passwordV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_scrollV);
|
make.left.right.equalTo(self);
|
make.height.mas_equalTo(180);
|
}];
|
|
//密码背景imageV
|
UIImageView *passBackImgV=[[UIImageView alloc] init];
|
[_passwordV addSubview:passBackImgV];
|
[passBackImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.center.equalTo(_passwordV);
|
make.height.mas_equalTo(165);
|
make.width.mas_equalTo(258);
|
}];
|
passBackImgV.image=[UIImage imageNamed:@"hdl_ez_temp_pass_word"];
|
|
//密码lable
|
_passwordL=[[UILabel alloc] init];
|
[_passwordV addSubview:_passwordL];
|
[_passwordL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(passBackImgV).offset(50);
|
make.left.equalTo(passBackImgV).offset(44);
|
make.right.equalTo(passBackImgV).offset(-44);
|
make.height.mas_equalTo(37);
|
}];
|
_passwordL.textAlignment=NSTextAlignmentCenter;
|
_passwordL.textColor=HDLEZ_COLOR_TEXT_WHITE;
|
_passwordL.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_26);
|
|
//描述lable
|
_describeL=[[UILabel alloc] init];
|
[_passwordV addSubview:_describeL];
|
[_describeL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_passwordL.mas_bottom);
|
make.left.right.equalTo(_passwordL);
|
make.height.mas_equalTo(15);
|
}];
|
_describeL.textAlignment=NSTextAlignmentCenter;
|
_describeL.adjustsFontSizeToFitWidth=YES;
|
_describeL.textColor=HDLEZ_COLOR_TEXT_WHITE;
|
_describeL.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_10);
|
_describeL.text=HDLEZLocallizedString(@"device_temp_long_tap_copy");
|
|
//使用人
|
_userV=[[HDLEZNormalCellView alloc] init];
|
[_scrollV addSubview:_userV];
|
[_userV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_passwordV.mas_bottom);
|
make.left.right.equalTo(self);
|
make.height.mas_equalTo(50);
|
}];
|
_userV.title= HDLEZLocallizedString(@"device_temp_user");
|
_userV.titleL.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_16);
|
[_userV.lineV setHidden:YES];
|
[_userV hideNextImg];
|
|
//有效期
|
_validV=[[HDLEZNormalCellView alloc] init];
|
[_scrollV addSubview:_validV];
|
[_validV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_userV.mas_bottom).offset(8);
|
make.left.right.equalTo(self);
|
make.height.mas_equalTo(50);
|
}];
|
_validV.title= HDLEZLocallizedString(@"device_temp_valid_date");
|
_validV.titleL.textColor=HDLEZ_COLOR_TEXT_LIGHT_BLUE;
|
_validV.titleL.font=HDLEZ_Get_FontBoldWithSize(HDLEZ_FontSize_16);
|
[_validV hideNextImg];
|
|
//生效时间
|
_validTimeV=[[HDLEZNormalCellView alloc] init];
|
[_scrollV addSubview:_validTimeV];
|
[_validTimeV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_validV.mas_bottom);
|
make.left.right.equalTo(self);
|
make.height.mas_equalTo(50);
|
}];
|
_validTimeV.title=HDLEZLocallizedString(@"device_temp_valid_begin");
|
[_validTimeV hideNextImg];
|
|
//失效时间
|
_expireTimeV=[[HDLEZNormalCellView alloc] init];
|
[_scrollV addSubview:_expireTimeV];
|
[_expireTimeV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_validTimeV.mas_bottom);
|
make.left.right.equalTo(self);
|
make.height.mas_equalTo(50);
|
}];
|
_expireTimeV.title=HDLEZLocallizedString(@"device_temp_valid_end");
|
[_expireTimeV.lineV setHidden:YES];
|
[_expireTimeV hideNextImg];
|
|
//使用次数
|
_useCountV=[[HDLEZNormalCellView alloc] init];
|
[_scrollV addSubview:_useCountV];
|
[_useCountV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_expireTimeV.mas_bottom).offset(8);
|
make.left.right.equalTo(self);
|
make.height.mas_equalTo(50);
|
}];
|
_useCountV.title=HDLEZLocallizedString(@"device_temp_use_times");
|
[_useCountV.lineV setHidden:YES];
|
[_useCountV hideNextImg];
|
|
//删除按钮
|
_deleteBtn=[[HDLEZButton alloc] init];
|
[_scrollV addSubview:_deleteBtn];
|
[_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(_useCountV.mas_bottom).offset(50);
|
make.left.equalTo(self).offset(80);
|
make.right.equalTo(self).offset(-80);
|
make.height.mas_equalTo(42);
|
}];
|
_deleteBtn.layer.cornerRadius=21;
|
_deleteBtn.layer.borderWidth=1;
|
_deleteBtn.layer.borderColor=HDLEZ_COLOR_BACKGROUND_LINE_RED.CGColor;
|
[_deleteBtn setTitleColor:HDLEZ_COLOR_BACKGROUND_LINE_RED forState:UIControlStateNormal];
|
_deleteBtn.titleLabel.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_16);
|
[_deleteBtn setTitle:HDLEZLocallizedString(@"delete") forState:UIControlStateNormal];
|
[_deleteBtn addTarget:self action:@selector(delete) forControlEvents:UIControlEventTouchUpInside];
|
|
//添加点击事件
|
UILongPressGestureRecognizer *longTap=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longTapTemp)];
|
[passBackImgV addGestureRecognizer:longTap];
|
_passwordV.userInteractionEnabled=YES;
|
passBackImgV.userInteractionEnabled=YES;
|
|
|
}
|
|
/*长按密码
|
*/
|
-(void)longTapTemp{
|
if (self.longTapPassWordBlock) {
|
self.longTapPassWordBlock(_passwordL.text);
|
}
|
}
|
|
/*点击删除
|
*/
|
-(void)delete{
|
if (self.deletePassWordBlock) {
|
self.deletePassWordBlock(@"");
|
}
|
}
|
|
/*时间转string
|
@param date 时间
|
*/
|
-(NSString *)turnDate:(NSDate*)date{
|
return [HDLEZConstants timeStrWithFormate:[NSString stringWithFormat:@"yyyy%@MM%@dd%@ HH:mm",HDLEZLocallizedString(@"device_temp_year"),HDLEZLocallizedString(@"device_temp_month"),HDLEZLocallizedString(@"device_temp_date")] data:date];
|
}
|
|
|
|
/*设置临时密码信息值
|
*/
|
-(void)setTemPdetailModel:(HDLEZTemInfoModel *)temPdetailModel{
|
_temPdetailModel=temPdetailModel;
|
|
//密码
|
_passwordL.text=temPdetailModel.password;
|
|
//使用人
|
_userV.contentL.text=temPdetailModel.userName;
|
|
//开始时间
|
_validTimeV.contentL.text= [self turnDate:[NSDate dateWithTimeIntervalSince1970:[temPdetailModel.beginTime integerValue]]];
|
|
//结束时间
|
_expireTimeV.contentL.text= [self turnDate:[NSDate dateWithTimeIntervalSince1970:[temPdetailModel.endTime integerValue]]];
|
|
//使用此时
|
if ([temPdetailModel.limitCount isEqualToString:@"-1"]) {
|
_useCountV.contentL.text=HDLEZLocallizedString(@"device_temp_unlimited_use_times");
|
}else{
|
_useCountV.contentL.text=[NSString stringWithFormat:@"%@%@%@,%@%@%@",HDLEZLocallizedString(@"device_temp_total"),temPdetailModel.limitCount,HDLEZLocallizedString(@"device_temp_times"),HDLEZLocallizedString(@"device_temp_left"),temPdetailModel.useCount,HDLEZLocallizedString(@"device_temp_times")];
|
}
|
|
|
}
|
|
|
@end
|