// // inputPWDViewController.m // 隐私保护 // // Created by xd h on 2023/10/12. // #import "inputPWDViewController.h" #import "connectDeviceManager.h" #import "RSATool.h" #import "forgetPwdViewController.h" #import "SceneDelegate.h" #import "TipsQRCodeForChangeDeviceViewController.h" #import "BaseNavigationController.h" #import "QRCodeScanForChangeDeviceViewController.h" #import "customToastVew.h" #import "UIInterface+HXRotation.h" @interface inputPWDViewController (){ NSString *pwd; UILabel *pointView0; UILabel *pointView1; UILabel *pointView2; UILabel *pointView3; } @property(nonatomic,strong)UILabel *pwdErrorTip; @property(nonatomic,strong)UIButton *leftButton; @end @implementation inputPWDViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. HLog(@"showCalculatorVC %f -- %f",self.view.frame.size.width,self.view.frame.size.height) [self hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait]; pwd = @""; [self drawAnyView]; //每次进入刷新密码 [[netWorkManager shareInstance] RefreshThridMsg]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if(_isCheckPwdType && !_leftButton){ [self initLeftButtonFun]; } } #pragma mark UI - (void)initLeftButtonFun { CGFloat btn_w_h = 40; CGFloat btn_show = 28; _leftButton = [[UIButton alloc] init]; [self.view addSubview:_leftButton]; [_leftButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(H_STATE_BAR + (64.f - btn_w_h)/2.f); make.left.mas_equalTo(10); make.width.mas_equalTo(btn_w_h); make.height.mas_equalTo(btn_w_h); }]; [_leftButton setImage:[UIImage imageNamed:@"icon_base_back"] forState:(UIControlStateNormal)]; [_leftButton setImageEdgeInsets:(UIEdgeInsetsMake((btn_w_h - btn_show)/2.f, (btn_w_h - btn_show)/2.f, (btn_w_h - btn_show)/2.f, (btn_w_h - btn_show)/2.f))]; [_leftButton addTarget:self action:@selector(backBtnPressed) forControlEvents:(UIControlEventTouchUpInside)]; } - (void)drawAnyView{ [self.navigationBar setHidden:YES]; [self.toolBar setHidden:YES]; [self.view setBackgroundColor:HWF5F7FAColor]; //扫一扫 切换设置 UIButton *saobut = [[UIButton alloc] init]; [saobut setImage:[UIImage imageNamed:@"saoyisao"] forState:UIControlStateNormal]; [self.view addSubview:saobut]; //saobut.backgroundColor = [UIColor greenColor]; [saobut addTarget:self action:@selector(scanToChangeDeviceFun) forControlEvents:UIControlEventTouchUpInside]; [saobut mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(40); make.height.mas_equalTo(40); make.right.mas_equalTo(-20); make.top.mas_equalTo(30.f + safeArea); }]; if(_isCheckPwdType){ saobut.hidden = YES; } /*设置密码标题*/ UILabel *topLabel = [[UILabel alloc] init]; [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]]; [topLabel setTextColor:HW333333Color]; [topLabel setTextAlignment:(NSTextAlignmentCenter)]; [topLabel setText:NSLocalizedString(@"guide_input_pwd_title",nil)]; [self.view addSubview:topLabel]; [topLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20); make.right.mas_equalTo(-20); make.top.mas_equalTo(99.f + H_STATE_BAR); }]; CGFloat w_pwd = 24.f; CGFloat h_pwd = 24.f; CGFloat pointFont = 20.f; /*密码视图*/ pointView0 = [[UILabel alloc] init]; [pointView0 setTextColor:HW0A132BColor]; [pointView0 setBackgroundColor:HWE3E8F1Color]; [pointView0 setClipsToBounds:YES]; [pointView0 setTextAlignment:(NSTextAlignmentCenter)]; [pointView0 setFont:[UIFont systemFontOfSize:pointFont]]; [pointView0.layer setCornerRadius:w_pwd/2.f]; [self.view addSubview:pointView0]; [pointView0 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.mas_centerX).offset((0-2)*(w_pwd+w_pwd) + w_pwd/2.f); make.height.mas_equalTo(h_pwd); make.width.mas_equalTo(w_pwd); make.top.mas_equalTo(151.f + H_STATE_BAR); }]; pointView1 = [[UILabel alloc] init]; [pointView1 setTextColor:HW0A132BColor]; [pointView1 setBackgroundColor:HWE3E8F1Color]; [pointView1 setClipsToBounds:YES]; [pointView1 setTextAlignment:(NSTextAlignmentCenter)]; [pointView1 setFont:[UIFont systemFontOfSize:pointFont]]; [pointView1.layer setCornerRadius:w_pwd/2.f]; [self.view addSubview:pointView1]; [pointView1 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.mas_centerX).offset((1-2)*(w_pwd+w_pwd) + w_pwd/2.f); make.height.mas_equalTo(h_pwd); make.width.mas_equalTo(w_pwd); make.top.mas_equalTo(151.f + H_STATE_BAR); }]; pointView2 = [[UILabel alloc] init]; [pointView2 setTextColor:HW0A132BColor]; [pointView2 setBackgroundColor:HWE3E8F1Color]; [pointView2 setClipsToBounds:YES]; [pointView2 setTextAlignment:(NSTextAlignmentCenter)]; [pointView2 setFont:[UIFont systemFontOfSize:pointFont]]; [pointView2.layer setCornerRadius:w_pwd/2.f]; [self.view addSubview:pointView2]; [pointView2 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.mas_centerX).offset((2-2)*(w_pwd+w_pwd) + w_pwd/2.f); make.height.mas_equalTo(h_pwd); make.width.mas_equalTo(w_pwd); make.top.mas_equalTo(151.f + H_STATE_BAR); }]; pointView3 = [[UILabel alloc] init]; [pointView3 setTextColor:HW0A132BColor]; [pointView3 setBackgroundColor:HWE3E8F1Color]; [pointView3 setClipsToBounds:YES]; [pointView3 setTextAlignment:(NSTextAlignmentCenter)]; [pointView3 setFont:[UIFont systemFontOfSize:pointFont]]; [pointView3.layer setCornerRadius:w_pwd/2.f]; [self.view addSubview:pointView3]; [pointView3 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.mas_centerX).offset((3-2)*(w_pwd+w_pwd) + w_pwd/2.f); make.height.mas_equalTo(h_pwd); make.width.mas_equalTo(w_pwd); make.top.mas_equalTo(151.f + H_STATE_BAR); }]; //忘记密码按钮 UIButton *forgetPwdBut = [[UIButton alloc] init]; [forgetPwdBut setTitle:NSLocalizedString(@"input_pwd_forget_pwd",nil) forState:(UIControlStateNormal)]; [forgetPwdBut setTitleColor:[UIColor hwColor:@"#13B2EB" alpha:1.0] forState:(UIControlStateNormal)]; [forgetPwdBut addTarget:self action:@selector(forgetPwdFun) forControlEvents:UIControlEventTouchUpInside]; //forgetPwdBut.backgroundColor = [UIColor redColor]; [self.view addSubview:forgetPwdBut]; [forgetPwdBut mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(pointView3.mas_bottom).offset(20.f); make.centerX.mas_equalTo(0.f); make.width.mas_equalTo(300); make.height.mas_equalTo(40); }]; /*下方绘制键盘按钮*/ UIView *bgViewForNumberBoard = [[UIView alloc] init]; [bgViewForNumberBoard setBackgroundColor:[UIColor clearColor]]; CGFloat w_bgViewForNumberBoard = SCREEN_W - 2*22.f*AUTOSCALE; CGFloat curAUTOSCALE = AUTOSCALE; if(SCREEN_W > SCREEN_H){ curAUTOSCALE = ([[UIScreen mainScreen] bounds].size.height / 375); w_bgViewForNumberBoard = SCREEN_H - 2*22.f*curAUTOSCALE; } CGFloat h_bgViewForNumberBoard = 330.f; [self.view addSubview:bgViewForNumberBoard]; [bgViewForNumberBoard mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(22.f*curAUTOSCALE); make.height.mas_equalTo(h_bgViewForNumberBoard); make.width.mas_equalTo(w_bgViewForNumberBoard); make.bottom.mas_equalTo(-70.f); }]; CGFloat w_key_btn = w_bgViewForNumberBoard/3.f; CGFloat h_key_btn = h_bgViewForNumberBoard/4.f; /*绘制键盘 1~9*/ for (NSInteger nFori = 0; nFori < 9; nFori++) { CGFloat x_key_btn = (nFori%3)*w_key_btn; CGFloat y_key_btn = (nFori/3)*h_key_btn; UIButton *keyBoardBtn = [[UIButton alloc] init]; [keyBoardBtn setBackgroundColor:[UIColor clearColor]]; [keyBoardBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)]; [keyBoardBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]]; [keyBoardBtn setTitle:[NSString stringWithFormat:@"%ld",nFori+1] forState:(UIControlStateNormal)]; [keyBoardBtn addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)]; [bgViewForNumberBoard addSubview:keyBoardBtn]; [keyBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(x_key_btn); make.top.mas_equalTo(y_key_btn); make.width.mas_equalTo(w_key_btn); make.height.mas_equalTo(h_key_btn); }]; } /*删除按钮*/ UIButton *deleteBoardBtn = [[UIButton alloc] init]; [deleteBoardBtn setBackgroundColor:[UIColor clearColor]]; [deleteBoardBtn addTarget:self action:@selector(deleteBoardBtnPressed) forControlEvents:(UIControlEventTouchUpInside)]; [deleteBoardBtn setImage:[UIImage imageNamed:@"key_board_delete"] forState:(UIControlStateNormal)]; [bgViewForNumberBoard addSubview:deleteBoardBtn]; [deleteBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.bottom.mas_equalTo(0); make.width.mas_equalTo(w_key_btn); make.height.mas_equalTo(h_key_btn); }]; /*0*/ UIButton *keyBoardBtn0 = [[UIButton alloc] init]; [keyBoardBtn0 setBackgroundColor:[UIColor clearColor]]; [keyBoardBtn0 setTitleColor:HW0A132BColor forState:(UIControlStateNormal)]; [keyBoardBtn0.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]]; [keyBoardBtn0 setTitle:@"0" forState:(UIControlStateNormal)]; [keyBoardBtn0 addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)]; [bgViewForNumberBoard addSubview:keyBoardBtn0]; [keyBoardBtn0 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(w_key_btn); make.bottom.mas_equalTo(0); make.width.mas_equalTo(w_key_btn); make.height.mas_equalTo(h_key_btn); }]; /*OK*/ UIButton *keyBoardBtnOK = [[UIButton alloc] init]; [keyBoardBtnOK setBackgroundColor:[UIColor clearColor]]; [keyBoardBtnOK setTitleColor:HW13B2EBColor forState:(UIControlStateNormal)]; [keyBoardBtnOK.titleLabel setFont:[UIFont boldSystemFontOfSize:30.f]]; [keyBoardBtnOK setTitle:@"OK" forState:(UIControlStateNormal)]; [keyBoardBtnOK addTarget:self action:@selector(keyBoardBtnOKPressed) forControlEvents:(UIControlEventTouchUpInside)]; [bgViewForNumberBoard addSubview:keyBoardBtnOK]; [keyBoardBtnOK mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(2*w_key_btn); make.bottom.mas_equalTo(0); make.width.mas_equalTo(w_key_btn); make.height.mas_equalTo(h_key_btn); }]; /*绘制引导视图*/ //[self addGuideView]; } - (void)addGuideView{ UIView *bgView = [[UIView alloc] init]; [bgView setBackgroundColor:HW000000Color60]; [self.view addSubview:bgView]; [bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.bottom.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(0); }]; /*密码背景*/ UIView *pwdBgView = [[UIView alloc] init]; [pwdBgView setBackgroundColor:HWF5F7FAColor]; pwdBgView.layer.cornerRadius = 26.f; [bgView addSubview:pwdBgView]; [pwdBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(bgView.mas_centerX); make.top.mas_equalTo(68.f + H_STATE_BAR); make.width.mas_equalTo(248); make.height.mas_equalTo(138); }]; /*密码*/ UILabel *topLabel = [[UILabel alloc] init]; [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]]; [topLabel setTextColor:HW333333Color]; [topLabel setTextAlignment:(NSTextAlignmentCenter)]; [topLabel setText:NSLocalizedString(@"guide_set_pwd_title",nil)]; [pwdBgView addSubview:topLabel]; [topLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20); make.right.mas_equalTo(-20); make.top.mas_equalTo(31.f); }]; for (NSInteger nfori = 0; nfori < 4; nfori++) { CGFloat w_pwd = 24.f; CGFloat h_pwd = 24.f; /*密码视图*/ UILabel *pointView = [[UILabel alloc] init]; [pointView setBackgroundColor:HWE3E8F1Color]; [pointView setClipsToBounds:YES]; [pointView.layer setCornerRadius:w_pwd/2.f]; [pwdBgView addSubview:pointView]; [pointView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(40.f + (w_pwd + w_pwd)*nfori); make.height.mas_equalTo(h_pwd); make.width.mas_equalTo(w_pwd); make.top.mas_equalTo(83.f); }]; } /*箭头视图*/ UIImageView *flagImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_set_pwd_flag"]]; [bgView addSubview:flagImageView]; [flagImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(pwdBgView.mas_left).offset(49); make.height.mas_equalTo(56); make.width.mas_equalTo(14); make.top.equalTo(pwdBgView.mas_bottom); }]; /*不可点击btn*/ UIButton *unableBtn = [[UIButton alloc] init]; unableBtn.frame = CGRectMake(0, 0, 250, 40.f); // gradient CAGradientLayer *gl = [CAGradientLayer layer]; gl.frame = CGRectMake(0,0,250,40.f); gl.startPoint = CGPointMake(0, 0.5); gl.endPoint = CGPointMake(1, 0.5); gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor]; gl.locations = @[@(0), @(1.0f)]; [unableBtn.layer addSublayer:gl]; [unableBtn setUserInteractionEnabled:NO]; [unableBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide",nil) forState:(UIControlStateNormal)]; [unableBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; [unableBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]]; [unableBtn.layer setCornerRadius:8.f]; unableBtn.clipsToBounds = YES; [bgView addSubview:unableBtn]; [unableBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(pwdBgView.mas_left).offset(16); make.width.mas_equalTo(250); make.top.equalTo(flagImageView.mas_bottom); make.height.mas_equalTo(40.f); }]; UIButton *knowBtn = [[UIButton alloc] init]; [knowBtn setBackgroundColor:[UIColor clearColor]]; [knowBtn.layer setCornerRadius:18.f]; [knowBtn.layer setBorderColor:HWFFFFFFColor.CGColor]; [knowBtn.layer setBorderWidth:1]; [knowBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:(UIControlStateNormal)]; [knowBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; [knowBtn.titleLabel setFont:[UIFont systemFontOfSize:16]]; [bgView addSubview:knowBtn]; [knowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(pwdBgView.mas_right).offset(-10); make.width.mas_equalTo(120); make.top.equalTo(unableBtn.mas_bottom).offset(25); make.height.mas_equalTo(36.f); }]; [knowBtn addTarget:bgView action:@selector(removeFromSuperview) forControlEvents:(UIControlEventTouchUpInside)]; } - (void)deleteBoardBtnPressed{ if (pwd.length > 0){ NSInteger numberLength = pwd.length; if (numberLength == 1){ [pointView0 setText:@""]; [pointView0 setBackgroundColor:HWE3E8F1Color]; }else if (numberLength == 2){ [pointView1 setText:@""]; [pointView1 setBackgroundColor:HWE3E8F1Color]; }else if (numberLength == 3){ [pointView2 setText:@""]; [pointView2 setBackgroundColor:HWE3E8F1Color]; }else if (numberLength == 4){ [pointView3 setText:@""]; [pointView3 setBackgroundColor:HWE3E8F1Color]; } pwd = [pwd substringToIndex:numberLength-1]; } } - (void)keyBoardBtnOKPressed{ if (pwd.length == 4){ /*进入下一级推拉流界面*/ [self verifyPwdFun:pwd]; return; // //是否已经有密码了 有就是输入密码 没有就是设置密码 // NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password; // // NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY]; // // if([desPwdStr isEqualToString:pwd]){ // [connectDeviceManager shareInstance].isFirstInputPwdDone = YES; // if(_isQRCodeType){ // [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil]; // } // // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil]; // }); // // //view 加载在windows上 // [self.view removeFromSuperview]; // // } // else{ // [self deleteBoardBtnPressed]; // [self deleteBoardBtnPressed]; // [self deleteBoardBtnPressed]; // [self deleteBoardBtnPressed]; // // //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show]; // //[[iToast makeText:@"111"] show]; // // _pwdErrorTip = [[UILabel alloc] init]; // _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil); // _pwdErrorTip.textAlignment = NSTextAlignmentCenter; // _pwdErrorTip.textColor = [UIColor whiteColor]; // _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7]; // [self.view addSubview:_pwdErrorTip]; // // _pwdErrorTip.layer.masksToBounds = YES; // _pwdErrorTip.layer.cornerRadius = 10; // // [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) { // make.center.mas_equalTo(0); // make.width.mas_equalTo(200); // make.height.mas_equalTo(40.f); // }]; // // /// // [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) { // // [self->_pwdErrorTip removeFromSuperview]; // self->_pwdErrorTip = nil; // }]; // } } } #pragma mark 验证密码是否正确 -(void)verifyPwdFun:(NSString*)text { /*先判断本地有无设备 无设备时需要先扫码添加设备*/ NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device]; if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){ //有设备了先去做链接准备 // 80bec9c5 NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"]; if(SNStr){ NSString *curPwd = nil; NSString*desPwdStr = nil; if(ksharedAppDelegate.DeviceThirdIdMod.data.password && ksharedAppDelegate.DeviceThirdIdMod.data.password.length > 0){ curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password; desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY]; } else{ if(deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]) { desPwdStr = deviceDict[Const_Have_Add_Device_PWD]; } } if ([desPwdStr isEqualToString:text]){ [self verifyPwdRightFun]; } else{ [self verifyPwdWrongFun:NO]; } } } } #pragma mark 验证密码正常 -(void)verifyPwdRightFun { //隐私模式验证密码 不走后续流程 if(_isCheckPwdType){ [self.navigationController popViewControllerAnimated:NO]; if(_didInputRightPwdFun){ _didInputRightPwdFun(); } return; } if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable) { //[[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show]; customToastVew *view = [customToastVew makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)]; [view show]; [self.view addSubview:view]; return; } ksharedAppDelegate.isFirstInputPwdDone = YES; ksharedAppDelegate.isDidShowPwdType = NO; if(_isQRCodeType){ [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil]; } //非隐私模式被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return if(![webRtcManager shareManager].isWaitShowLogoutAlert){ [[webRtcManager shareManager] beginToLinkWebRtcFun]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil]; }); } //view 加载在windows上 [self.view removeFromSuperview]; } #pragma mark 验证密码错误 -(void)verifyPwdWrongFun:(BOOL)isNetFail { [self deleteBoardBtnPressed]; [self deleteBoardBtnPressed]; [self deleteBoardBtnPressed]; [self deleteBoardBtnPressed]; //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show]; //[[iToast makeText:@"111"] show]; _pwdErrorTip = [[UILabel alloc] init]; NSString *curTipStr = nil; if(isNetFail){ curTipStr = NSLocalizedString(@"log_login_system_busy",nil); } else{ curTipStr = NSLocalizedString(@"logo_input_pwd_fail",nil); } _pwdErrorTip.text = curTipStr; _pwdErrorTip.numberOfLines = 0; _pwdErrorTip.textAlignment = NSTextAlignmentCenter; _pwdErrorTip.textColor = [UIColor whiteColor]; _pwdErrorTip.font = [UIFont systemFontOfSize:16.0]; _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7]; [self.view addSubview:_pwdErrorTip]; _pwdErrorTip.layer.masksToBounds = YES; _pwdErrorTip.layer.cornerRadius = 10; CGSize curSize = [curTipStr boundingRectWithSize:CGSizeMake(SCREEN_W - 20 - 20 -20, 1000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0]} context:nil].size; CGFloat curWidth = curSize.width; CGFloat curheight = curSize.height; if(curWidth < (SCREEN_W - 20 - 20)){ curWidth += 20; } if(curheight < 30){ curheight = 40; } else{ curheight += 10; } [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(0); make.width.mas_equalTo(curWidth); make.height.mas_equalTo(curheight); }]; /// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self->_pwdErrorTip removeFromSuperview]; self->_pwdErrorTip = nil; }); } - (void)keyBoardBtnPressed:(id)sender{ UIButton *btn = (UIButton *)sender; NSString *selectNumberStr = btn.titleLabel.text; if (pwd.length < 4){ NSInteger numberLength = pwd.length; if (numberLength == 0){ [pointView0 setText:selectNumberStr]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self->pointView0 setBackgroundColor:HW0A132BColor]; }); }else if (numberLength == 1){ [pointView1 setText:selectNumberStr]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self->pointView1 setBackgroundColor:HW0A132BColor]; }); }else if (numberLength == 2){ [pointView2 setText:selectNumberStr]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self->pointView2 setBackgroundColor:HW0A132BColor]; }); }else if (numberLength == 3){ [pointView3 setText:selectNumberStr]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self->pointView3 setBackgroundColor:HW0A132BColor]; [self keyBoardBtnOKPressed]; }); } pwd = [pwd stringByAppendingString:selectNumberStr]; } } #pragma mark 点击忘记密码 - (void)forgetPwdFun { if(_isCheckPwdType){ forgetPwdViewController *vc = [forgetPwdViewController new]; vc.isCheckPwdType = YES; [self.navigationController pushViewController:vc animated:YES]; return; } //发个通知 记录进入了设置密码 [[NSNotificationCenter defaultCenter] postNotificationName:forgetPwdNotification object:nil]; //SceneDelegate *sceneDelegate = (SceneDelegate *)self.window.rootViewController; } #pragma mark 扫一扫 切换设备 - (void)scanToChangeDeviceFun { //TipsQRCodeForChangeDeviceViewController *vc = [[TipsQRCodeForChangeDeviceViewController alloc] init]; QRCodeScanForChangeDeviceViewController *vc = [[QRCodeScanForChangeDeviceViewController alloc] init]; if(self.navigationController){ [self.navigationController pushViewController:vc animated:YES]; } else{ //发个通知 [[NSNotificationCenter defaultCenter] postNotificationName:scanChangeDeviceNotification object:nil]; //view 加载在windows上 [self.view removeFromSuperview]; } } @end