소스 검색

修改忘记口令处理为显示密码;
增加重置口令

Pen Li 9 년 전
부모
커밋
0aadf01307

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 88 - 3
RedAnt ERP Mobile/iSales-NPD/JKLock/JKLockController.m

@@ -23,6 +23,7 @@
 @property (nonatomic,strong) UILabel *tipLabel;///<提示标签
 @property (nonatomic,copy) NSString *password;///<密码
 @property (nonatomic,strong) UIButton *forgottenButton;
+@property (nonatomic,strong) UIButton *resetButton;
 @property (nonatomic,strong) NSMutableArray *dotArray;///<密码视图
 @property (nonatomic,copy) NSString *input;///<输入
 @property (nonatomic,assign) NSUInteger index;///<输入了多少位
@@ -178,9 +179,13 @@
     }
     
     // forget
-    self.forgottenButton.frame = CGRectMake(width - 100, height - 70, 80, 40);
+    self.forgottenButton.frame = CGRectMake(width - 120, height - 40, 120, 40);
     [self.view addSubview:self.forgottenButton];
     
+    // reset
+    self.resetButton.frame = CGRectMake(0, height - 40, 120, 40);
+    [self.view addSubview:self.resetButton];
+    
 }
 
 - (void)loadPassword {
@@ -212,7 +217,7 @@
 - (UIButton *)forgottenButton {
     if (!_forgottenButton) {
         _forgottenButton = [UIButton buttonWithType:UIButtonTypeCustom];
-        [_forgottenButton setTitle:@"forget" forState:UIControlStateNormal];
+        [_forgottenButton setTitle:@"forget password" forState:UIControlStateNormal];
         [_forgottenButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
         _forgottenButton.tag = View_Tag + 2;
         _forgottenButton.titleLabel.font = [UIFont systemFontOfSize:14.0f];
@@ -221,6 +226,17 @@
     return _forgottenButton;
 }
 
+- (UIButton *)resetButton {
+    if (!_resetButton) {
+        _resetButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        [_resetButton setTitle:@"reset password" forState:UIControlStateNormal];
+        [_resetButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
+        _resetButton.tag = View_Tag + 2;
+        _resetButton.titleLabel.font = [UIFont systemFontOfSize:14.0f];
+        [_resetButton addTarget:self action:@selector(resetButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _resetButton;
+}
 
 - (NSMutableArray *)dotArray {
     if (!_dotArray) {
@@ -277,6 +293,72 @@
         return YES;
     };
     
+    messageBoxController.textHandler = ^(NSString *text){
+        
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        
+        if ([text isEqualToString:appDelegate.password]) {
+            
+//            [[NSUserDefaults standardUserDefaults] removeObjectForKey:self.passwordKey];
+//            weakself.password = nil;
+            weakself.index = 0;
+            weakself.input = @"";
+            for (JKDotView *dot in self.dotArray) {
+                dot.state = JKDotStateNormal;
+            }
+            
+//            weakself.tipLabel.text = @"Please Set A New Password";
+            [weakVC dismissViewControllerAnimated:YES completion:^{
+//                weakself.tipLabel.text = @"Please Set A New Password";
+                
+                    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Your Current Password" message:weakself.password preferredStyle:UIAlertControllerStyleAlert];
+
+                
+                    UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                
+                        if (alertController.navigationController) {
+                            [alertController.navigationController popViewControllerAnimated:YES];
+                        } else {
+                            [alertController dismissViewControllerAnimated:YES completion:nil];
+                        }
+                
+                    }];
+                
+                    [alertController addAction:action];
+                    
+
+                    [weakself presentViewController:alertController animated:YES completion:nil];
+
+
+                
+            }];
+            
+        } else {
+            
+            [weakVC warning:@"It's wrong,please try again"];
+            
+        }
+        
+        
+        
+        
+    };
+    
+    [self presentViewController:messageBoxController animated:YES completion:nil];
+    
+}
+
+- (void)resetButtonClick:(UIButton *)sender {
+    JKMessageBoxController *messageBoxController = [JKMessageBoxController messageBoxControllerWithTip:@"Please enter your login password"];
+    
+    __weak typeof(messageBoxController) weakVC = messageBoxController;
+    __weak typeof(self) weakself = self;
+    
+    messageBoxController.changeHandler = ^(UITextField *textField,NSRange range,NSString *string) {
+        
+        return YES;
+    };
+    
     messageBoxController.textHandler = ^(NSString *text){
         
         AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
@@ -287,10 +369,14 @@
             weakself.password = nil;
             weakself.index = 0;
             weakself.input = @"";
+            for (JKDotView *dot in self.dotArray) {
+                dot.state = JKDotStateNormal;
+            }
             
             weakself.tipLabel.text = @"Please Set A New Password";
             [weakVC dismissViewControllerAnimated:YES completion:^{
                 weakself.tipLabel.text = @"Please Set A New Password";
+                
             }];
             
         } else {
@@ -305,7 +391,6 @@
     };
     
     [self presentViewController:messageBoxController animated:YES completion:nil];
-    
 }
 
 

+ 1 - 1
RedAnt ERP Mobile/iSales-NPD/JKLock/JKMessageBoxController.m

@@ -95,7 +95,7 @@
     if (!_yesButton) {
         _yesButton = [UIButton buttonWithType:UIButtonTypeCustom];
         _yesButton.frame = CGRectMake(CGRectGetMaxX(self.cancelButton.frame) + 0.5, 0.5, self.preferredContentSize.width / 2 - 0.25, CGRectGetHeight(self.buttonBackground.frame));
-        [_yesButton setTitle:@"sure" forState:UIControlStateNormal];
+        [_yesButton setTitle:@"ok" forState:UIControlStateNormal];
         [_yesButton setTitleColor:[UIColor colorWithRed:0.3 green:0.3 blue:0.8 alpha:1] forState:UIControlStateNormal];
         [_yesButton setTitleColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.9 alpha:1] forState:UIControlStateHighlighted];
         _yesButton.backgroundColor = [UIColor whiteColor];