inputPWDViewController.m 23 KB

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