Explorar el Código

增加价格设置口令重置。

Pen Li hace 9 años
padre
commit
99741a023c

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


+ 6 - 0
RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

@@ -30,6 +30,7 @@
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
 		42E58BFB1D7E5EF50092810A /* SortButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E58BFA1D7E5EF50092810A /* SortButton.m */; };
 		42E58C021D7E735A0092810A /* UIColor+JK_HEX.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E58C011D7E735A0092810A /* UIColor+JK_HEX.m */; };
+		42F637521DB2178E00605C4B /* JKMessageBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F637511DB2178E00605C4B /* JKMessageBoxController.m */; };
 		710274251CC606C4009FD219 /* UserListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 710274241CC606C4009FD219 /* UserListViewController.m */; };
 		7111E5721C76C557004763B3 /* customer_info_template_edit.json in Resources */ = {isa = PBXBuildFile; fileRef = 7111E5711C76C557004763B3 /* customer_info_template_edit.json */; };
 		71131F921CA1372300DBF6E2 /* SimplifiedBuyingProgramViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71131F911CA1372300DBF6E2 /* SimplifiedBuyingProgramViewController.m */; };
@@ -253,6 +254,8 @@
 		42E58BFA1D7E5EF50092810A /* SortButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortButton.m; sourceTree = "<group>"; };
 		42E58C001D7E735A0092810A /* UIColor+JK_HEX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+JK_HEX.h"; sourceTree = "<group>"; };
 		42E58C011D7E735A0092810A /* UIColor+JK_HEX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+JK_HEX.m"; sourceTree = "<group>"; };
+		42F637501DB2178E00605C4B /* JKMessageBoxController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKMessageBoxController.h; sourceTree = "<group>"; };
+		42F637511DB2178E00605C4B /* JKMessageBoxController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKMessageBoxController.m; sourceTree = "<group>"; };
 		56528CA8B8A71F67C2EE5366 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
 		6C826876B24EFB83AC94A464 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
 		710274231CC606C4009FD219 /* UserListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserListViewController.h; path = common/Functions/sidemenu/UserListViewController.h; sourceTree = SOURCE_ROOT; };
@@ -650,6 +653,8 @@
 		42BED0141DAF74DF004576E0 /* JKLock */ = {
 			isa = PBXGroup;
 			children = (
+				42F637501DB2178E00605C4B /* JKMessageBoxController.h */,
+				42F637511DB2178E00605C4B /* JKMessageBoxController.m */,
 				42BED0151DAF74DF004576E0 /* JKDotView.h */,
 				42BED0161DAF74DF004576E0 /* JKDotView.m */,
 				42BED0171DAF74DF004576E0 /* JKLockButton.h */,
@@ -1539,6 +1544,7 @@
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
 				42BED01B1DAF74DF004576E0 /* JKDotView.m in Sources */,
+				42F637521DB2178E00605C4B /* JKMessageBoxController.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */,
 				7162A5AB1C58735900AB630E /* PDFListViewController.m in Sources */,

+ 63 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKLockController.m

@@ -9,6 +9,8 @@
 #import "JKLockController.h"
 #import "JKLockButton.h"
 #import "JKDotView.h"
+#import "JKMessageBoxController.h"
+#import "AppDelegate.h"
 
 #define Password_Length 4
 #define Dot_Interval 60
@@ -20,6 +22,7 @@
 
 @property (nonatomic,strong) UILabel *tipLabel;///<提示标签
 @property (nonatomic,copy) NSString *password;///<密码
+@property (nonatomic,strong) UIButton *forgottenButton;
 @property (nonatomic,strong) NSMutableArray *dotArray;///<密码视图
 @property (nonatomic,copy) NSString *input;///<输入
 @property (nonatomic,assign) NSUInteger index;///<输入了多少位
@@ -174,6 +177,10 @@
         
     }
     
+    // forget
+    self.forgottenButton.frame = CGRectMake(width - 100, height - 70, 80, 40);
+    [self.view addSubview:self.forgottenButton];
+    
 }
 
 - (void)loadPassword {
@@ -202,6 +209,19 @@
     return _tipLabel;
 }
 
+- (UIButton *)forgottenButton {
+    if (!_forgottenButton) {
+        _forgottenButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        [_forgottenButton setTitle:@"forget" forState:UIControlStateNormal];
+        [_forgottenButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
+        _forgottenButton.tag = View_Tag + 2;
+        _forgottenButton.titleLabel.font = [UIFont systemFontOfSize:14.0f];
+        [_forgottenButton addTarget:self action:@selector(forgottenButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _forgottenButton;
+}
+
+
 - (NSMutableArray *)dotArray {
     if (!_dotArray) {
         _dotArray = [NSMutableArray arrayWithCapacity:Password_Length];
@@ -245,6 +265,49 @@
     }
 }
 
+- (void)forgottenButtonClick:(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;
+        
+        if ([text isEqualToString:appDelegate.password]) {
+            
+            [[NSUserDefaults standardUserDefaults] removeObjectForKey:self.passwordKey];
+            weakself.password = nil;
+            weakself.index = 0;
+            weakself.input = @"";
+            
+            weakself.tipLabel.text = @"Please Set A New Password";
+            [weakVC dismissViewControllerAnimated:YES completion:^{
+                weakself.tipLabel.text = @"Please Set A New Password";
+            }];
+            
+        } else {
+            
+            [weakVC warning:@"It's wrong,please try again"];
+            
+        }
+        
+        
+        
+        
+    };
+    
+    [self presentViewController:messageBoxController animated:YES completion:nil];
+    
+}
+
 
 - (void)verifyPassword {
     

+ 26 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKMessageBoxController.h

@@ -0,0 +1,26 @@
+//
+//  JKAlertController.h
+//  Lock
+//
+//  Created by Jack on 2016/10/15.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef BOOL(^textChangeHandler)(UITextField *textField,NSRange changeRange,NSString*string);
+
+typedef void(^inputHandler)(NSString *text);
+
+@interface JKMessageBoxController : UIViewController
+
+@property (nonatomic,copy) textChangeHandler changeHandler;
+
+@property (nonatomic,copy) inputHandler textHandler;
+
+
++ (instancetype)messageBoxControllerWithTip:(NSString *)msg;
+
+- (void)warning:(NSString *)msg;
+
+@end

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

@@ -0,0 +1,150 @@
+//
+//  JKAlertController.m
+//  Lock
+//
+//  Created by Jack on 2016/10/15.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKMessageBoxController.h"
+#import "AppDelegate.h"
+
+@interface JKMessageBoxController ()<UITextFieldDelegate>
+
+@property (nonatomic,strong) UILabel *titleLabel;
+@property (nonatomic,strong) UITextField *textFiled;
+@property (nonatomic,strong) UIView *buttonBackground;
+@property (nonatomic,strong) UIButton *cancelButton;
+@property (nonatomic,strong) UIButton *yesButton;
+
+@end
+
+@implementation JKMessageBoxController
+
++ (instancetype)messageBoxControllerWithTip:(NSString *)msg {
+    JKMessageBoxController *alertController = [[JKMessageBoxController alloc] init];
+
+    // 设置弹出视图时视图大小位置
+    alertController.modalPresentationStyle = UIModalPresentationFormSheet; // 只在iPad起作用
+    alertController.preferredContentSize = CGSizeMake(300, 130); // 只有在 UIModalPresentationFormSheet 的时候起作用
+    alertController.titleLabel.text = msg;
+    alertController.title = msg;
+    
+    return alertController;
+}
+
+- (void)warning:(NSString *)msg {
+    self.textFiled.text = @"";
+    self.titleLabel.text = msg;
+    self.titleLabel.textColor = [UIColor redColor];
+    
+    [self performSelector:@selector(resetTitleLabel) withObject:nil afterDelay:1];
+}
+
+- (void)resetTitleLabel {
+    self.titleLabel.text = self.title;
+    self.titleLabel.textColor = [UIColor blackColor];
+}
+
+- (UILabel *)titleLabel {
+    if (!_titleLabel) {
+        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, self.preferredContentSize.width - 20, 25)];
+        _titleLabel.font = [UIFont systemFontOfSize:14];
+        _titleLabel.textAlignment = NSTextAlignmentCenter;
+    }
+    return _titleLabel;
+}
+
+- (UITextField *)textFiled {
+    if (!_textFiled) {
+        _textFiled = [[UITextField alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.titleLabel.frame) + 10, self.preferredContentSize.width - 20, 25)];
+        _textFiled.font = [UIFont systemFontOfSize:13];
+        _textFiled.borderStyle = UITextBorderStyleRoundedRect;
+        _textFiled.secureTextEntry = YES;
+        _textFiled.delegate = self;
+    }
+    return _textFiled;
+}
+
+- (UIView *)buttonBackground {
+    if (!_buttonBackground) {
+        _buttonBackground = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.textFiled.frame) + 20, self.preferredContentSize.width,  self.preferredContentSize.height - CGRectGetMaxY(self.textFiled.frame) - 10)];
+        
+        [_buttonBackground addSubview:self.cancelButton];
+        [_buttonBackground addSubview:self.yesButton];
+        _buttonBackground.backgroundColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1];
+    }
+    return _buttonBackground;
+}
+
+- (UIButton *)cancelButton {
+    if (!_cancelButton) {
+        _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        _cancelButton.frame = CGRectMake(0, 0.5, self.preferredContentSize.width / 2 - 0.25, CGRectGetHeight(self.buttonBackground.frame));
+        [_cancelButton setTitle:@"cancel" forState:UIControlStateNormal];
+        [_cancelButton setTitleColor:[UIColor colorWithRed:0.3 green:0.3 blue:0.8 alpha:1] forState:UIControlStateNormal];
+        [_cancelButton setTitleColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.9 alpha:1] forState:UIControlStateHighlighted];
+        _cancelButton.backgroundColor = [UIColor whiteColor];
+        _cancelButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
+        [_cancelButton addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _cancelButton;
+}
+
+- (UIButton *)yesButton {
+    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 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];
+        _yesButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
+        [_yesButton addTarget:self action:@selector(yesButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _yesButton;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+ 
+    self.view.backgroundColor = [UIColor whiteColor];
+    
+    [self.view addSubview:self.titleLabel];
+    [self.view addSubview:self.textFiled];
+    [self.view addSubview:self.buttonBackground];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)cancelButtonClick:(UIButton *)sender {
+    if (self.navigationController) {
+        [self.navigationController popViewControllerAnimated:YES];
+    } else {
+        [self dismissViewControllerAnimated:YES completion:nil];
+    }
+}
+
+- (void)yesButtonClick:(UIButton *)sender {
+    
+    if (self.textHandler) {
+        self.textHandler(self.textFiled.text);
+    }
+    
+}
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    
+    if (self.changeHandler) {
+        return self.changeHandler(textField,range,string);
+    }
+    
+    return YES;
+}
+
+
+@end