inputPWDViewController.m 24 KB

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