inputPWDViewController.m 23 KB

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