inputPWDViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. //
  2. // inputPWDViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/10/12.
  6. //
  7. #import "inputPWDViewController.h"
  8. #import "connectDeviceManager.h"
  9. #import "RSATool.h"
  10. #import "forgetPwdViewController.h"
  11. #import "SceneDelegate.h"
  12. @interface inputPWDViewController (){
  13. NSString *pwd;
  14. UILabel *pointView0;
  15. UILabel *pointView1;
  16. UILabel *pointView2;
  17. UILabel *pointView3;
  18. }
  19. @property(nonatomic,strong)UILabel *pwdErrorTip;
  20. @end
  21. @implementation inputPWDViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. // Do any additional setup after loading the view.
  25. pwd = @"";
  26. [self drawAnyView];
  27. }
  28. - (void)drawAnyView{
  29. [self.navigationBar setHidden:YES];
  30. [self.toolBar setHidden:YES];
  31. [self.view setBackgroundColor:HWF5F7FAColor];
  32. /*设置密码标题*/
  33. UILabel *topLabel = [[UILabel alloc] init];
  34. [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  35. [topLabel setTextColor:HW333333Color];
  36. [topLabel setTextAlignment:(NSTextAlignmentCenter)];
  37. [topLabel setText:NSLocalizedString(@"guide_input_pwd_title",nil)];
  38. [self.view addSubview:topLabel];
  39. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.mas_equalTo(20);
  41. make.right.mas_equalTo(-20);
  42. make.top.mas_equalTo(99.f + H_STATE_BAR);
  43. }];
  44. CGFloat w_pwd = 24.f;
  45. CGFloat h_pwd = 24.f;
  46. CGFloat pointFont = 20.f;
  47. /*密码视图*/
  48. pointView0 = [[UILabel alloc] init];
  49. [pointView0 setTextColor:HW0A132BColor];
  50. [pointView0 setBackgroundColor:HWE3E8F1Color];
  51. [pointView0 setClipsToBounds:YES];
  52. [pointView0 setTextAlignment:(NSTextAlignmentCenter)];
  53. [pointView0 setFont:[UIFont systemFontOfSize:pointFont]];
  54. [pointView0.layer setCornerRadius:w_pwd/2.f];
  55. [self.view addSubview:pointView0];
  56. [pointView0 mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.equalTo(self.view.mas_centerX).offset((0-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  58. make.height.mas_equalTo(h_pwd);
  59. make.width.mas_equalTo(w_pwd);
  60. make.top.mas_equalTo(151.f + H_STATE_BAR);
  61. }];
  62. pointView1 = [[UILabel alloc] init];
  63. [pointView1 setTextColor:HW0A132BColor];
  64. [pointView1 setBackgroundColor:HWE3E8F1Color];
  65. [pointView1 setClipsToBounds:YES];
  66. [pointView1 setTextAlignment:(NSTextAlignmentCenter)];
  67. [pointView1 setFont:[UIFont systemFontOfSize:pointFont]];
  68. [pointView1.layer setCornerRadius:w_pwd/2.f];
  69. [self.view addSubview:pointView1];
  70. [pointView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.left.equalTo(self.view.mas_centerX).offset((1-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  72. make.height.mas_equalTo(h_pwd);
  73. make.width.mas_equalTo(w_pwd);
  74. make.top.mas_equalTo(151.f + H_STATE_BAR);
  75. }];
  76. pointView2 = [[UILabel alloc] init];
  77. [pointView2 setTextColor:HW0A132BColor];
  78. [pointView2 setBackgroundColor:HWE3E8F1Color];
  79. [pointView2 setClipsToBounds:YES];
  80. [pointView2 setTextAlignment:(NSTextAlignmentCenter)];
  81. [pointView2 setFont:[UIFont systemFontOfSize:pointFont]];
  82. [pointView2.layer setCornerRadius:w_pwd/2.f];
  83. [self.view addSubview:pointView2];
  84. [pointView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.left.equalTo(self.view.mas_centerX).offset((2-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  86. make.height.mas_equalTo(h_pwd);
  87. make.width.mas_equalTo(w_pwd);
  88. make.top.mas_equalTo(151.f + H_STATE_BAR);
  89. }];
  90. pointView3 = [[UILabel alloc] init];
  91. [pointView3 setTextColor:HW0A132BColor];
  92. [pointView3 setBackgroundColor:HWE3E8F1Color];
  93. [pointView3 setClipsToBounds:YES];
  94. [pointView3 setTextAlignment:(NSTextAlignmentCenter)];
  95. [pointView3 setFont:[UIFont systemFontOfSize:pointFont]];
  96. [pointView3.layer setCornerRadius:w_pwd/2.f];
  97. [self.view addSubview:pointView3];
  98. [pointView3 mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.equalTo(self.view.mas_centerX).offset((3-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  100. make.height.mas_equalTo(h_pwd);
  101. make.width.mas_equalTo(w_pwd);
  102. make.top.mas_equalTo(151.f + H_STATE_BAR);
  103. }];
  104. //忘记密码按钮
  105. UIButton *forgetPwdBut = [[UIButton alloc] init];
  106. [forgetPwdBut setTitle:NSLocalizedString(@"input_pwd_forget_pwd",nil) forState:(UIControlStateNormal)];
  107. [forgetPwdBut setTitleColor:[UIColor hwColor:@"#13B2EB" alpha:1.0] forState:(UIControlStateNormal)];
  108. [forgetPwdBut addTarget:self action:@selector(forgetPwdFun) forControlEvents:UIControlEventTouchUpInside];
  109. //forgetPwdBut.backgroundColor = [UIColor redColor];
  110. [self.view addSubview:forgetPwdBut];
  111. [forgetPwdBut mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.top.mas_equalTo(pointView3.mas_bottom).offset(20.f);
  113. make.centerX.mas_equalTo(0.f);
  114. make.width.mas_equalTo(150);
  115. make.height.mas_equalTo(40);
  116. }];
  117. /*下方绘制键盘按钮*/
  118. UIView *bgViewForNumberBoard = [[UIView alloc] init];
  119. [bgViewForNumberBoard setBackgroundColor:[UIColor clearColor]];
  120. CGFloat w_bgViewForNumberBoard = SCREEN_W - 2*22.f*AUTOSCALE;
  121. CGFloat h_bgViewForNumberBoard = 330.f;
  122. [self.view addSubview:bgViewForNumberBoard];
  123. [bgViewForNumberBoard mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.left.mas_equalTo(22.f*AUTOSCALE);
  125. make.height.mas_equalTo(h_bgViewForNumberBoard);
  126. make.width.mas_equalTo(w_bgViewForNumberBoard);
  127. make.bottom.mas_equalTo(-70.f);
  128. }];
  129. CGFloat w_key_btn = w_bgViewForNumberBoard/3.f;
  130. CGFloat h_key_btn = h_bgViewForNumberBoard/4.f;
  131. /*绘制键盘 1~9*/
  132. for (NSInteger nFori = 0; nFori < 9; nFori++) {
  133. CGFloat x_key_btn = (nFori%3)*w_key_btn;
  134. CGFloat y_key_btn = (nFori/3)*h_key_btn;
  135. UIButton *keyBoardBtn = [[UIButton alloc] init];
  136. [keyBoardBtn setBackgroundColor:[UIColor clearColor]];
  137. [keyBoardBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  138. [keyBoardBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
  139. [keyBoardBtn setTitle:[NSString stringWithFormat:@"%ld",nFori+1] forState:(UIControlStateNormal)];
  140. [keyBoardBtn addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
  141. [bgViewForNumberBoard addSubview:keyBoardBtn];
  142. [keyBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  143. make.left.mas_equalTo(x_key_btn);
  144. make.top.mas_equalTo(y_key_btn);
  145. make.width.mas_equalTo(w_key_btn);
  146. make.height.mas_equalTo(h_key_btn);
  147. }];
  148. }
  149. /*删除按钮*/
  150. UIButton *deleteBoardBtn = [[UIButton alloc] init];
  151. [deleteBoardBtn setBackgroundColor:[UIColor clearColor]];
  152. [deleteBoardBtn addTarget:self action:@selector(deleteBoardBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
  153. [deleteBoardBtn setImage:[UIImage imageNamed:@"key_board_delete"] forState:(UIControlStateNormal)];
  154. [bgViewForNumberBoard addSubview:deleteBoardBtn];
  155. [deleteBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  156. make.left.mas_equalTo(0);
  157. make.bottom.mas_equalTo(0);
  158. make.width.mas_equalTo(w_key_btn);
  159. make.height.mas_equalTo(h_key_btn);
  160. }];
  161. /*0*/
  162. UIButton *keyBoardBtn0 = [[UIButton alloc] init];
  163. [keyBoardBtn0 setBackgroundColor:[UIColor clearColor]];
  164. [keyBoardBtn0 setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  165. [keyBoardBtn0.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
  166. [keyBoardBtn0 setTitle:@"0" forState:(UIControlStateNormal)];
  167. [keyBoardBtn0 addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
  168. [bgViewForNumberBoard addSubview:keyBoardBtn0];
  169. [keyBoardBtn0 mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.left.mas_equalTo(w_key_btn);
  171. make.bottom.mas_equalTo(0);
  172. make.width.mas_equalTo(w_key_btn);
  173. make.height.mas_equalTo(h_key_btn);
  174. }];
  175. /*OK*/
  176. UIButton *keyBoardBtnOK = [[UIButton alloc] init];
  177. [keyBoardBtnOK setBackgroundColor:[UIColor clearColor]];
  178. [keyBoardBtnOK setTitleColor:HW13B2EBColor forState:(UIControlStateNormal)];
  179. [keyBoardBtnOK.titleLabel setFont:[UIFont boldSystemFontOfSize:30.f]];
  180. [keyBoardBtnOK setTitle:@"OK" forState:(UIControlStateNormal)];
  181. [keyBoardBtnOK addTarget:self action:@selector(keyBoardBtnOKPressed) forControlEvents:(UIControlEventTouchUpInside)];
  182. [bgViewForNumberBoard addSubview:keyBoardBtnOK];
  183. [keyBoardBtnOK mas_makeConstraints:^(MASConstraintMaker *make) {
  184. make.left.mas_equalTo(2*w_key_btn);
  185. make.bottom.mas_equalTo(0);
  186. make.width.mas_equalTo(w_key_btn);
  187. make.height.mas_equalTo(h_key_btn);
  188. }];
  189. /*绘制引导视图*/
  190. //[self addGuideView];
  191. }
  192. - (void)addGuideView{
  193. UIView *bgView = [[UIView alloc] init];
  194. [bgView setBackgroundColor:HW000000Color60];
  195. [self.view addSubview:bgView];
  196. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  197. make.left.mas_equalTo(0);
  198. make.bottom.mas_equalTo(0);
  199. make.right.mas_equalTo(0);
  200. make.top.mas_equalTo(0);
  201. }];
  202. /*密码背景*/
  203. UIView *pwdBgView = [[UIView alloc] init];
  204. [pwdBgView setBackgroundColor:HWF5F7FAColor];
  205. pwdBgView.layer.cornerRadius = 26.f;
  206. [bgView addSubview:pwdBgView];
  207. [pwdBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  208. make.centerX.equalTo(bgView.mas_centerX);
  209. make.top.mas_equalTo(68.f + H_STATE_BAR);
  210. make.width.mas_equalTo(248);
  211. make.height.mas_equalTo(138);
  212. }];
  213. /*密码*/
  214. UILabel *topLabel = [[UILabel alloc] init];
  215. [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  216. [topLabel setTextColor:HW333333Color];
  217. [topLabel setTextAlignment:(NSTextAlignmentCenter)];
  218. [topLabel setText:NSLocalizedString(@"guide_set_pwd_title",nil)];
  219. [pwdBgView addSubview:topLabel];
  220. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  221. make.left.mas_equalTo(20);
  222. make.right.mas_equalTo(-20);
  223. make.top.mas_equalTo(31.f);
  224. }];
  225. for (NSInteger nfori = 0; nfori < 4; nfori++) {
  226. CGFloat w_pwd = 24.f;
  227. CGFloat h_pwd = 24.f;
  228. /*密码视图*/
  229. UILabel *pointView = [[UILabel alloc] init];
  230. [pointView setBackgroundColor:HWE3E8F1Color];
  231. [pointView setClipsToBounds:YES];
  232. [pointView.layer setCornerRadius:w_pwd/2.f];
  233. [pwdBgView addSubview:pointView];
  234. [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
  235. make.left.mas_equalTo(40.f + (w_pwd + w_pwd)*nfori);
  236. make.height.mas_equalTo(h_pwd);
  237. make.width.mas_equalTo(w_pwd);
  238. make.top.mas_equalTo(83.f);
  239. }];
  240. }
  241. /*箭头视图*/
  242. UIImageView *flagImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_set_pwd_flag"]];
  243. [bgView addSubview:flagImageView];
  244. [flagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  245. make.left.equalTo(pwdBgView.mas_left).offset(49);
  246. make.height.mas_equalTo(56);
  247. make.width.mas_equalTo(14);
  248. make.top.equalTo(pwdBgView.mas_bottom);
  249. }];
  250. /*不可点击btn*/
  251. UIButton *unableBtn = [[UIButton alloc] init];
  252. unableBtn.frame = CGRectMake(0, 0, 250, 40.f);
  253. // gradient
  254. CAGradientLayer *gl = [CAGradientLayer layer];
  255. gl.frame = CGRectMake(0,0,250,40.f);
  256. gl.startPoint = CGPointMake(0, 0.5);
  257. gl.endPoint = CGPointMake(1, 0.5);
  258. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  259. gl.locations = @[@(0), @(1.0f)];
  260. [unableBtn.layer addSublayer:gl];
  261. [unableBtn setUserInteractionEnabled:NO];
  262. [unableBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide",nil) forState:(UIControlStateNormal)];
  263. [unableBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  264. [unableBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  265. [unableBtn.layer setCornerRadius:8.f];
  266. unableBtn.clipsToBounds = YES;
  267. [bgView addSubview:unableBtn];
  268. [unableBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  269. make.left.equalTo(pwdBgView.mas_left).offset(16);
  270. make.width.mas_equalTo(250);
  271. make.top.equalTo(flagImageView.mas_bottom);
  272. make.height.mas_equalTo(40.f);
  273. }];
  274. UIButton *knowBtn = [[UIButton alloc] init];
  275. [knowBtn setBackgroundColor:[UIColor clearColor]];
  276. [knowBtn.layer setCornerRadius:18.f];
  277. [knowBtn.layer setBorderColor:HWFFFFFFColor.CGColor];
  278. [knowBtn.layer setBorderWidth:1];
  279. [knowBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:(UIControlStateNormal)];
  280. [knowBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  281. [knowBtn.titleLabel setFont:[UIFont systemFontOfSize:16]];
  282. [bgView addSubview:knowBtn];
  283. [knowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  284. make.right.equalTo(pwdBgView.mas_right).offset(-10);
  285. make.width.mas_equalTo(120);
  286. make.top.equalTo(unableBtn.mas_bottom).offset(25);
  287. make.height.mas_equalTo(36.f);
  288. }];
  289. [knowBtn addTarget:bgView
  290. action:@selector(removeFromSuperview)
  291. forControlEvents:(UIControlEventTouchUpInside)];
  292. }
  293. - (void)deleteBoardBtnPressed{
  294. if (pwd.length > 0){
  295. NSInteger numberLength = pwd.length;
  296. if (numberLength == 1){
  297. [pointView0 setText:@""];
  298. [pointView0 setBackgroundColor:HWE3E8F1Color];
  299. }else if (numberLength == 2){
  300. [pointView1 setText:@""];
  301. [pointView1 setBackgroundColor:HWE3E8F1Color];
  302. }else if (numberLength == 3){
  303. [pointView2 setText:@""];
  304. [pointView2 setBackgroundColor:HWE3E8F1Color];
  305. }else if (numberLength == 4){
  306. [pointView3 setText:@""];
  307. [pointView3 setBackgroundColor:HWE3E8F1Color];
  308. }
  309. pwd = [pwd substringToIndex:numberLength-1];
  310. }
  311. }
  312. - (void)keyBoardBtnOKPressed{
  313. if (pwd.length == 4){
  314. /*进入下一级推拉流界面*/
  315. [self verifyPwdFun:pwd];
  316. return;
  317. // //是否已经有密码了 有就是输入密码 没有就是设置密码
  318. // NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
  319. //
  320. // NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  321. //
  322. // if([desPwdStr isEqualToString:pwd]){
  323. // [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  324. // if(_isQRCodeType){
  325. // [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  326. // }
  327. //
  328. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  329. // [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
  330. // });
  331. //
  332. // //view 加载在windows上
  333. // [self.view removeFromSuperview];
  334. //
  335. // }
  336. // else{
  337. // [self deleteBoardBtnPressed];
  338. // [self deleteBoardBtnPressed];
  339. // [self deleteBoardBtnPressed];
  340. // [self deleteBoardBtnPressed];
  341. //
  342. // //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
  343. // //[[iToast makeText:@"111"] show];
  344. //
  345. // _pwdErrorTip = [[UILabel alloc] init];
  346. // _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil);
  347. // _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
  348. // _pwdErrorTip.textColor = [UIColor whiteColor];
  349. // _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
  350. // [self.view addSubview:_pwdErrorTip];
  351. //
  352. // _pwdErrorTip.layer.masksToBounds = YES;
  353. // _pwdErrorTip.layer.cornerRadius = 10;
  354. //
  355. // [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
  356. // make.center.mas_equalTo(0);
  357. // make.width.mas_equalTo(200);
  358. // make.height.mas_equalTo(40.f);
  359. // }];
  360. //
  361. // ///
  362. // [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
  363. //
  364. // [self->_pwdErrorTip removeFromSuperview];
  365. // self->_pwdErrorTip = nil;
  366. // }];
  367. // }
  368. }
  369. }
  370. #pragma mark 验证密码是否正确
  371. -(void)verifyPwdFun:(NSString*)text
  372. {
  373. /*先判断本地有无设备 无设备时需要先扫码添加设备*/
  374. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  375. if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  376. //有设备了先去做链接准备 // 80bec9c5
  377. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  378. if(SNStr){
  379. [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:NO didNetEnd:^(bool didSuc) {
  380. if(didSuc){
  381. NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
  382. NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  383. if ([desPwdStr isEqualToString:text]){
  384. [self verifyPwdRightFun];
  385. }
  386. else{
  387. [self verifyPwdWrongFun:NO];
  388. }
  389. }
  390. else{
  391. [self verifyPwdWrongFun:YES];
  392. }
  393. }];
  394. }
  395. }
  396. }
  397. #pragma mark 验证密码正常
  398. -(void)verifyPwdRightFun
  399. {
  400. //隐私模式验证密码 不走后续流程
  401. if(_isCheckPwdType){
  402. if(_didInputRightPwdFun){
  403. _didInputRightPwdFun();
  404. }
  405. [self.navigationController popViewControllerAnimated:YES];
  406. return;
  407. }
  408. [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  409. if(_isQRCodeType){
  410. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  411. }
  412. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  413. [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
  414. });
  415. //view 加载在windows上
  416. [self.view removeFromSuperview];
  417. }
  418. #pragma mark 验证密码错误
  419. -(void)verifyPwdWrongFun:(BOOL)isNetFail
  420. {
  421. [self deleteBoardBtnPressed];
  422. [self deleteBoardBtnPressed];
  423. [self deleteBoardBtnPressed];
  424. [self deleteBoardBtnPressed];
  425. //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
  426. //[[iToast makeText:@"111"] show];
  427. _pwdErrorTip = [[UILabel alloc] init];
  428. NSString *curTipStr = nil;
  429. if(isNetFail){
  430. curTipStr = NSLocalizedString(@"log_login_system_busy",nil);
  431. }
  432. else{
  433. curTipStr = NSLocalizedString(@"logo_input_pwd_fail",nil);
  434. }
  435. _pwdErrorTip.text = curTipStr;
  436. _pwdErrorTip.numberOfLines = 0;
  437. _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
  438. _pwdErrorTip.textColor = [UIColor whiteColor];
  439. _pwdErrorTip.font = [UIFont systemFontOfSize:16.0];
  440. _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
  441. [self.view addSubview:_pwdErrorTip];
  442. _pwdErrorTip.layer.masksToBounds = YES;
  443. _pwdErrorTip.layer.cornerRadius = 10;
  444. CGSize curSize = [curTipStr boundingRectWithSize:CGSizeMake(SCREEN_W - 20 - 20 -20, 1000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0]} context:nil].size;
  445. CGFloat curWidth = curSize.width;
  446. CGFloat curheight = curSize.height;
  447. if(curWidth < (SCREEN_W - 20 - 20)){
  448. curWidth += 20;
  449. }
  450. if(curheight < 30){
  451. curheight = 40;
  452. }
  453. else{
  454. curheight += 10;
  455. }
  456. [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
  457. make.center.mas_equalTo(0);
  458. make.width.mas_equalTo(curWidth);
  459. make.height.mas_equalTo(curheight);
  460. }];
  461. ///
  462. [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
  463. [self->_pwdErrorTip removeFromSuperview];
  464. self->_pwdErrorTip = nil;
  465. }];
  466. }
  467. - (void)keyBoardBtnPressed:(id)sender{
  468. UIButton *btn = (UIButton *)sender;
  469. NSString *selectNumberStr = btn.titleLabel.text;
  470. if (pwd.length < 4){
  471. NSInteger numberLength = pwd.length;
  472. if (numberLength == 0){
  473. [pointView0 setText:selectNumberStr];
  474. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  475. [self->pointView0 setBackgroundColor:HW0A132BColor];
  476. });
  477. }else if (numberLength == 1){
  478. [pointView1 setText:selectNumberStr];
  479. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  480. [self->pointView1 setBackgroundColor:HW0A132BColor];
  481. });
  482. }else if (numberLength == 2){
  483. [pointView2 setText:selectNumberStr];
  484. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  485. [self->pointView2 setBackgroundColor:HW0A132BColor];
  486. });
  487. }else if (numberLength == 3){
  488. [pointView3 setText:selectNumberStr];
  489. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  490. [self->pointView3 setBackgroundColor:HW0A132BColor];
  491. [self keyBoardBtnOKPressed];
  492. });
  493. }
  494. pwd = [pwd stringByAppendingString:selectNumberStr];
  495. }
  496. }
  497. #pragma mark 点击忘记密码
  498. - (void)forgetPwdFun
  499. {
  500. if(_isCheckPwdType){
  501. forgetPwdViewController *vc = [forgetPwdViewController new];
  502. vc.isCheckPwdType = YES;
  503. [self.navigationController pushViewController:vc animated:YES];
  504. return;
  505. }
  506. //发个通知 记录进入了设置密码
  507. [[NSNotificationCenter defaultCenter] postNotificationName:forgetPwdNotification object:nil];
  508. //SceneDelegate *sceneDelegate = (SceneDelegate *)self.window.rootViewController;
  509. }
  510. /*
  511. #pragma mark - Navigation
  512. // In a storyboard-based application, you will often want to do a little preparation before navigation
  513. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  514. // Get the new view controller using [segue destinationViewController].
  515. // Pass the selected object to the new view controller.
  516. }
  517. */
  518. @end