Просмотр исходного кода

实现修改价格的密码设置和验证。

Pen Li 9 лет назад
Родитель
Сommit
5712cb83ff

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


+ 60 - 22
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -28,6 +28,7 @@
 #import "OfflineSettingViewController.h"
 #import "OfflineSettingViewController.h"
 #import "DefaultAppearance.h"
 #import "DefaultAppearance.h"
 #import "PriceSettingViewController.h"
 #import "PriceSettingViewController.h"
+#import "JKLockController.h"
 
 
 @interface MainViewController ()
 @interface MainViewController ()
 
 
@@ -1698,7 +1699,7 @@
         [self.sideMenuItems addObject:map.copy];
         [self.sideMenuItems addObject:map.copy];
         
         
     }
     }
-    if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+    if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
         [map setValue:@"Price Setting" forKey:@"title"];
         [map setValue:@"Price Setting" forKey:@"title"];
         //        [map setValue:@"rect_market_news" forKey:@"img"];
         //        [map setValue:@"rect_market_news" forKey:@"img"];
         [self.sideMenuItems addObject:map.copy];
         [self.sideMenuItems addObject:map.copy];
@@ -2179,23 +2180,41 @@
         UIApplication * app = [UIApplication sharedApplication];
         UIApplication * app = [UIApplication sharedApplication];
         AppDelegate *appDelegate = (AppDelegate *)[app delegate];
         AppDelegate *appDelegate = (AppDelegate *)[app delegate];
         
         
-        [appDelegate set_priceHidden:false];
-        //appDelegate.price_hidden = false;
-        //[self.sideMenuTable reloadData];
-        [self initMenuItems];
-        [self hideMenu];
+        JKLockController *lockVC = [[JKLockController alloc] init];
+        [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
+        __weak typeof(self) weakself = self;
+        lockVC.authoReturn = ^(BOOL failure) {
+
+            if (weakself) {
+                __strong typeof(weakself) strongself = weakself;
+                [appDelegate set_priceHidden:false];
+                
+                [strongself initMenuItems];
+                [strongself hideMenu];
+            }
+        };
+        [self.navigationController pushViewController:lockVC animated:YES];
+        
      }
      }
     else if([title isEqualToString:@"Hide Price"])
     else if([title isEqualToString:@"Hide Price"])
     {
     {
         UIApplication * app = [UIApplication sharedApplication];
         UIApplication * app = [UIApplication sharedApplication];
         AppDelegate *appDelegate = (AppDelegate *)[app delegate];
         AppDelegate *appDelegate = (AppDelegate *)[app delegate];
         
         
-        [appDelegate set_priceHidden:true];
-        
-        //        appDelegate.price_hidden = true;
-        [self initMenuItems];
-        //  [self.sideMenuTable reloadData];
-        [self hideMenu];
+        JKLockController *lockVC = [[JKLockController alloc] init];
+        [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
+        __weak typeof(self) weakself = self;
+        lockVC.authoReturn = ^(BOOL failure) {
+            
+            if (weakself) {
+                __strong typeof(weakself) strongself = weakself;
+                [appDelegate set_priceHidden:true];
+                
+                [strongself initMenuItems];
+                [strongself hideMenu];
+            }
+        };
+        [self.navigationController pushViewController:lockVC animated:YES];
      }
      }
     
     
     
     
@@ -2255,18 +2274,32 @@
         [self.navigationController pushViewController:scannerVC animated:true];
         [self.navigationController pushViewController:scannerVC animated:true];
     } else if ([title isEqualToString:@"Price Setting"]) {
     } else if ([title isEqualToString:@"Price Setting"]) {
         
         
-        PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
-        
-        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
-        
-        navi.navigationBar.translucent = NO;
-        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-        [self presentViewController:navi animated:YES completion:^{
-            
 
 
+        UIApplication * app = [UIApplication sharedApplication];
+        AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+        
+        JKLockController *lockVC = [[JKLockController alloc] init];
+        [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
+        __weak typeof(self) weakself = self;
+        lockVC.authoReturn = ^(BOOL failure) {
             
             
-        }];
-
+            if (weakself) {
+                __strong typeof(weakself) strongself = weakself;
+                
+                PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
+                
+                UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
+                
+                navi.navigationBar.translucent = NO;
+                navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+                [strongself presentViewController:navi animated:YES completion:^{
+                    
+                }];
+                
+            }
+        };
+        [self.navigationController pushViewController:lockVC animated:YES];
+        
         
         
     }
     }
 }
 }
@@ -2401,4 +2434,9 @@
         });
         });
     });
     });
 }
 }
+
+- (void)showPriceAuth:(NSInteger)from {
+    
+}
+
 @end
 @end

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

@@ -23,6 +23,9 @@
 		42B3C9BB1D642C880053985C /* order_info.html in Resources */ = {isa = PBXBuildFile; fileRef = 42B3C9BA1D642C880053985C /* order_info.html */; };
 		42B3C9BB1D642C880053985C /* order_info.html in Resources */ = {isa = PBXBuildFile; fileRef = 42B3C9BA1D642C880053985C /* order_info.html */; };
 		42B99E131D7D032300E773CD /* SortItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E121D7D032300E773CD /* SortItemViewController.m */; };
 		42B99E131D7D032300E773CD /* SortItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E121D7D032300E773CD /* SortItemViewController.m */; };
 		42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E151D7D052A00E773CD /* SortItemCell.m */; };
 		42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E151D7D052A00E773CD /* SortItemCell.m */; };
+		42BED01B1DAF74DF004576E0 /* JKDotView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BED0161DAF74DF004576E0 /* JKDotView.m */; };
+		42BED01C1DAF74DF004576E0 /* JKLockButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BED0181DAF74DF004576E0 /* JKLockButton.m */; };
+		42BED01D1DAF74DF004576E0 /* JKLockController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BED01A1DAF74DF004576E0 /* JKLockController.m */; };
 		42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */; };
 		42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */; };
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
 		42E58BFB1D7E5EF50092810A /* SortButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E58BFA1D7E5EF50092810A /* SortButton.m */; };
 		42E58BFB1D7E5EF50092810A /* SortButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E58BFA1D7E5EF50092810A /* SortButton.m */; };
@@ -238,6 +241,12 @@
 		42B99E121D7D032300E773CD /* SortItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemViewController.m; sourceTree = "<group>"; };
 		42B99E121D7D032300E773CD /* SortItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemViewController.m; sourceTree = "<group>"; };
 		42B99E141D7D052A00E773CD /* SortItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortItemCell.h; sourceTree = "<group>"; };
 		42B99E141D7D052A00E773CD /* SortItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortItemCell.h; sourceTree = "<group>"; };
 		42B99E151D7D052A00E773CD /* SortItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemCell.m; sourceTree = "<group>"; };
 		42B99E151D7D052A00E773CD /* SortItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemCell.m; sourceTree = "<group>"; };
+		42BED0151DAF74DF004576E0 /* JKDotView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKDotView.h; sourceTree = "<group>"; };
+		42BED0161DAF74DF004576E0 /* JKDotView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKDotView.m; sourceTree = "<group>"; };
+		42BED0171DAF74DF004576E0 /* JKLockButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKLockButton.h; sourceTree = "<group>"; };
+		42BED0181DAF74DF004576E0 /* JKLockButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKLockButton.m; sourceTree = "<group>"; };
+		42BED0191DAF74DF004576E0 /* JKLockController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKLockController.h; sourceTree = "<group>"; };
+		42BED01A1DAF74DF004576E0 /* JKLockController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKLockController.m; sourceTree = "<group>"; };
 		42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = contactAdvanceSearch.json; sourceTree = "<group>"; };
 		42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = contactAdvanceSearch.json; sourceTree = "<group>"; };
 		42DC31121D546FBE00BCD1C6 /* category.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
 		42DC31121D546FBE00BCD1C6 /* category.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
 		42E58BF91D7E5EF50092810A /* SortButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortButton.h; sourceTree = "<group>"; };
 		42E58BF91D7E5EF50092810A /* SortButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortButton.h; sourceTree = "<group>"; };
@@ -638,6 +647,19 @@
 			name = "Price Setting";
 			name = "Price Setting";
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
+		42BED0141DAF74DF004576E0 /* JKLock */ = {
+			isa = PBXGroup;
+			children = (
+				42BED0151DAF74DF004576E0 /* JKDotView.h */,
+				42BED0161DAF74DF004576E0 /* JKDotView.m */,
+				42BED0171DAF74DF004576E0 /* JKLockButton.h */,
+				42BED0181DAF74DF004576E0 /* JKLockButton.m */,
+				42BED0191DAF74DF004576E0 /* JKLockController.h */,
+				42BED01A1DAF74DF004576E0 /* JKLockController.m */,
+			);
+			path = JKLock;
+			sourceTree = "<group>";
+		};
 		42E58BFF1D7E735A0092810A /* UIColor+HEX */ = {
 		42E58BFF1D7E735A0092810A /* UIColor+HEX */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
@@ -885,6 +907,7 @@
 		716387C71953CDB4006E65E6 /* utils */ = {
 		716387C71953CDB4006E65E6 /* utils */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				42BED0141DAF74DF004576E0 /* JKLock */,
 				421C54FF1D81586D00CFA3B1 /* JKTimer */,
 				421C54FF1D81586D00CFA3B1 /* JKTimer */,
 				42E58BFF1D7E735A0092810A /* UIColor+HEX */,
 				42E58BFF1D7E735A0092810A /* UIColor+HEX */,
 				71BBA2171CEAC10200C91DED /* zip */,
 				71BBA2171CEAC10200C91DED /* zip */,
@@ -1478,6 +1501,7 @@
 				715001FF1D114D9100F5927F /* BundleDetailButton.m in Sources */,
 				715001FF1D114D9100F5927F /* BundleDetailButton.m in Sources */,
 				7162A5421C58719D00AB630E /* RATreeNodeCollectionController.m in Sources */,
 				7162A5421C58719D00AB630E /* RATreeNodeCollectionController.m in Sources */,
 				71DF74631C575E7900F2789C /* CommonEditorCellSwitch.m in Sources */,
 				71DF74631C575E7900F2789C /* CommonEditorCellSwitch.m in Sources */,
+				42BED01D1DAF74DF004576E0 /* JKLockController.m in Sources */,
 				7162A5DE1C5876E300AB630E /* RetrievePassViewController.m in Sources */,
 				7162A5DE1C5876E300AB630E /* RetrievePassViewController.m in Sources */,
 				7141DD541C57459B00F7DF59 /* rscode.c in Sources */,
 				7141DD541C57459B00F7DF59 /* rscode.c in Sources */,
 				71DF74621C575E7900F2789C /* CommonEditorCellSignature.m in Sources */,
 				71DF74621C575E7900F2789C /* CommonEditorCellSignature.m in Sources */,
@@ -1514,6 +1538,7 @@
 				7141DD551C57459B00F7DF59 /* split.c in Sources */,
 				7141DD551C57459B00F7DF59 /* split.c in Sources */,
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
+				42BED01B1DAF74DF004576E0 /* JKDotView.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */,
 				42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */,
 				7162A5AB1C58735900AB630E /* PDFListViewController.m in Sources */,
 				7162A5AB1C58735900AB630E /* PDFListViewController.m in Sources */,
@@ -1603,6 +1628,7 @@
 				7162A5431C58719D00AB630E /* RATreeNodeInfo.m in Sources */,
 				7162A5431C58719D00AB630E /* RATreeNodeInfo.m in Sources */,
 				7162A4FF1C585FFB00AB630E /* WebViewController.m in Sources */,
 				7162A4FF1C585FFB00AB630E /* WebViewController.m in Sources */,
 				71FFBBE91C60894900D91DC2 /* iSalesDB.m in Sources */,
 				71FFBBE91C60894900D91DC2 /* iSalesDB.m in Sources */,
+				42BED01C1DAF74DF004576E0 /* JKLockButton.m in Sources */,
 				7162A55B1C58724700AB630E /* ContactAdvanceSearchViewController.m in Sources */,
 				7162A55B1C58724700AB630E /* ContactAdvanceSearchViewController.m in Sources */,
 				7162A5441C58719D00AB630E /* RATreeNodeInfo+Private.m in Sources */,
 				7162A5441C58719D00AB630E /* RATreeNodeInfo+Private.m in Sources */,
 				7162A5C51C5873BB00AB630E /* SearchViewController.m in Sources */,
 				7162A5C51C5873BB00AB630E /* SearchViewController.m in Sources */,

+ 20 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKDotView.h

@@ -0,0 +1,20 @@
+//
+//  JKDotView.h
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef NS_ENUM(NSUInteger, JKDotState) {
+    JKDotStateNormal,
+    JKDotStateSelected
+};
+
+@interface JKDotView : UIView
+
+@property (nonatomic,assign) JKDotState state;
+
+@end

+ 68 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKDotView.m

@@ -0,0 +1,68 @@
+//
+//  JKDotView.m
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKDotView.h"
+
+@interface JKDotView ()
+
+@property (nonatomic,strong) CAShapeLayer *inscribedCircleLayer;///<内切圆
+
+
+@end
+
+@implementation JKDotView
+
+-(CAShapeLayer *)inscribedCircleLayer{
+    if (!_inscribedCircleLayer) {
+        _inscribedCircleLayer = [CAShapeLayer layer];
+        _inscribedCircleLayer.strokeColor = [UIColor blackColor].CGColor;
+        _inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+        _inscribedCircleLayer.lineWidth = 1.0f;
+    }
+    return _inscribedCircleLayer;
+}
+
+- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
+    
+    self.inscribedCircleLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.bounds].CGPath;
+    
+    [self.layer addSublayer:self.inscribedCircleLayer];
+    
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        self.backgroundColor = [UIColor clearColor];
+        [self.layer setNeedsDisplay];
+    }
+    return self;
+}
+
+- (void)setState:(JKDotState)state {
+    _state = state;
+    
+    switch (state) {
+        case JKDotStateNormal:{
+            _inscribedCircleLayer.strokeColor = [UIColor blackColor].CGColor;
+            _inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+        }
+            break;
+        case JKDotStateSelected:{
+            _inscribedCircleLayer.strokeColor = [UIColor blackColor].CGColor;
+            _inscribedCircleLayer.fillColor = [UIColor blackColor].CGColor;
+        }
+            break;
+            
+        default:
+            break;
+    }
+}
+
+
+
+@end

+ 18 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKLockButton.h

@@ -0,0 +1,18 @@
+//
+//  JKLockButton.h
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+
+@interface JKLockButton : UIButton
+
+@property (nonatomic,assign) NSInteger number;
+
+
+@end

+ 97 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKLockButton.m

@@ -0,0 +1,97 @@
+//
+//  JKLockButton.m
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKLockButton.h"
+
+@interface JKLockButton ()
+
+@property (nonatomic,strong) CAShapeLayer *inscribedCircleLayer;///<内切圆
+
+@property (nonatomic,strong) CAShapeLayer *borderLayer;///<边框
+
+
+@end
+
+@implementation JKLockButton
+
+- (void)setNumber:(NSInteger)number {
+    _number = number;
+    
+    if (number >= 0 && number < 10) {
+        [self setTitle:[NSString stringWithFormat:@"%d",number] forState:UIControlStateNormal];
+        self.titleLabel.font = [UIFont systemFontOfSize:17.0f];
+    } else {
+        [self setTitle:@"delete" forState:UIControlStateNormal];
+        self.titleLabel.font = [UIFont systemFontOfSize:14.0f];
+    }
+    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+}
+-(CAShapeLayer *)inscribedCircleLayer{
+    if (!_inscribedCircleLayer) {
+        _inscribedCircleLayer = [CAShapeLayer layer];
+        _inscribedCircleLayer.strokeColor = [UIColor lightGrayColor].CGColor;
+        _inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+        _inscribedCircleLayer.lineWidth = 1.0f;
+    }
+    return _inscribedCircleLayer;
+}
+
+-(CAShapeLayer *)borderLayer{
+    if (!_borderLayer) {
+        _borderLayer = [CAShapeLayer layer];
+        _borderLayer.fillColor = [UIColor clearColor].CGColor;
+        _borderLayer.strokeColor = [UIColor clearColor].CGColor;
+        _borderLayer.lineWidth = 1.0f;
+    }
+    return _borderLayer;
+}
+
+
+- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
+    
+    self.inscribedCircleLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.bounds].CGPath;
+
+    self.borderLayer.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
+    
+    [self.layer addSublayer:self.inscribedCircleLayer];
+    [self.layer addSublayer:self.borderLayer];
+    
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        [self.layer setNeedsDisplay];
+        [self.inscribedCircleLayer addSublayer:self.titleLabel.layer];
+    }
+    return self;
+}
+
+- (void)setImage:(UIImage *)image forState:(UIControlState)state {
+    
+}
+
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+    self.inscribedCircleLayer.strokeColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.5].CGColor;
+    self.inscribedCircleLayer.fillColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.5].CGColor;
+    
+    NSSet *allTargets = self.allTargets;
+    
+    id target = [allTargets.allObjects firstObject];
+    
+    if (target) {
+        [self sendActionsForControlEvents:UIControlEventTouchUpInside];
+    }
+}
+
+- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+    self.inscribedCircleLayer.strokeColor = [UIColor lightGrayColor].CGColor;
+    self.inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+}
+
+
+@end

+ 19 - 0
RedAnt ERP Mobile/iSales-NPD/JKLock/JKLockController.h

@@ -0,0 +1,19 @@
+//
+//  JKLockController.h
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef void(^authoBlock)(BOOL failure);
+
+@interface JKLockController : UIViewController
+
+@property (nonatomic,copy) authoBlock authoReturn;
+
+- (void)setPasswordKey:(NSString *)passwordKey;
+
+@end

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

@@ -0,0 +1,243 @@
+//
+//  JKLockController.m
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKLockController.h"
+#import "JKLockButton.h"
+#import "JKDotView.h"
+
+#define Password_Length 4
+#define Dot_Interval 60
+#define Dot_Width 20
+
+
+@interface JKLockController ()
+
+@property (nonatomic,strong) UILabel *tipLabel;///<提示标签
+@property (nonatomic,copy) NSString *password;///<密码
+@property (nonatomic,strong) NSMutableArray *dotArray;///<密码视图
+@property (nonatomic,copy) NSString *input;///<输入
+@property (nonatomic,assign) NSUInteger index;///<输入了多少位
+
+@property (nonatomic,copy,readonly) NSString *passwordKey;///<取密码的钥匙
+
+@end
+
+@implementation JKLockController
+
+- (void)setPasswordKey:(NSString *)passwordKey {
+    _passwordKey = passwordKey;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    self.view.backgroundColor = [UIColor colorWithRed:0.5 green:0.8 blue:0.6 alpha:1];
+        
+    self.index = 0;
+    self.input = @"";
+    [self loadPassword];
+    [self configAppearance];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+    return YES;
+}
+
+- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+    
+    [self configAppearance];
+}
+
+- (void)clearView {
+    for (UIView *view in self.view.subviews) {
+        [view removeFromSuperview];
+        [self.dotArray removeAllObjects];
+    }
+}
+
+- (void)configAppearance {
+    CGFloat width = CGRectGetWidth(self.view.bounds);
+    CGFloat height = CGRectGetHeight(self.view.bounds);
+    
+    [self clearView];
+    
+    // 20
+    CGFloat y0 = height * 0.2;
+    self.tipLabel.center = CGPointMake(width / 2, y0 + CGRectGetHeight(self.tipLabel.bounds) / 2);
+    [self.view addSubview:self.tipLabel];
+    
+    // 10
+    CGFloat y1 = y0 + CGRectGetHeight(self.tipLabel.bounds) + 20; // 间距20,高度20
+    CGFloat x1 = (width - Dot_Width * Password_Length - Dot_Interval * (Password_Length - 1)) / 2;
+    for (int i = 0; i < Password_Length; i++) {
+        JKDotView *dot = [[JKDotView alloc] initWithFrame:CGRectMake(x1 + (Dot_Width + Dot_Interval) * i, y1, Dot_Width, Dot_Width)];
+        
+        [self.view addSubview:dot];
+        [self.dotArray addObject:dot];
+    }
+    
+    // 70
+    // 3 * 4
+    CGFloat y2 = y1 + Dot_Width + 0.1 * height; // 间距 80 / 40
+    CGFloat Button_Width = 0.07 * (width > height ? height : width);
+    CGFloat interval = 0.05 * (width > height ? height : width);
+    CGFloat x2 = (width - Button_Width * 3 - interval * 2) / 2;
+    
+    for (int i = 0; i < 3; i++) { // col
+        
+        for (int j = 0; j < 4; j++) { // row
+            
+            
+            if (i == 0 && j == 3) { // 取消
+                
+                UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+                cancelBtn.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                [cancelBtn setTitle:@"cancel" forState:UIControlStateNormal];
+                [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+                [cancelBtn addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+                [self.view addSubview:cancelBtn];
+                
+            } else if (i == 2 && j == 3) { // 删除
+                
+                UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+                deleteBtn.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                [deleteBtn setTitle:@"delete" forState:UIControlStateNormal];
+                [deleteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+                [deleteBtn addTarget:self action:@selector(deleteButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+                [self.view addSubview:deleteBtn];
+                
+            } else { // 数字
+                JKLockButton *btn = [[JKLockButton alloc] initWithFrame:CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width)];
+                if (i == 1 && j == 3) {
+                    btn.number = 0;
+                } else {
+                    btn.number = 1 + i + j * 3;
+                }
+                [self.view addSubview:btn];
+                [btn addTarget:self action:@selector(numberButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+            }
+            
+        }
+        
+    }
+    
+}
+
+- (void)loadPassword {
+    
+    NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:self.passwordKey];
+    self.password = password;
+    
+}
+
+- (void)setPassword:(NSString *)password {
+    _password = password;
+    if (password) {
+        self.tipLabel.text = @"Please Input Your Password";
+    } else {
+        self.tipLabel.text = @"Please Set A Password";
+    }
+}
+
+- (UILabel *)tipLabel {
+    if (!_tipLabel) {
+        _tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 20)];
+        _tipLabel.font = [UIFont systemFontOfSize:20.0f];
+        _tipLabel.textAlignment = NSTextAlignmentCenter;
+        
+    }
+    return _tipLabel;
+}
+
+- (NSMutableArray *)dotArray {
+    if (!_dotArray) {
+        _dotArray = [NSMutableArray arrayWithCapacity:Password_Length];
+    }
+    return _dotArray;
+}
+
+- (void)numberButtonClick:(JKLockButton *)sender {
+    if (self.index < Password_Length) {
+        NSInteger number = sender.number;
+        JKDotView *dot = [self.dotArray objectAtIndex:self.index];
+        dot.state = JKDotStateSelected;
+        
+        self.input = [self.input stringByAppendingString:[NSString stringWithFormat:@"%d",number]];
+        self.index++;
+    }
+    
+    if (self.index == Password_Length) {
+        
+        [self performSelector:@selector(verifyPassword) withObject:nil afterDelay:0.5];
+    }
+}
+
+- (void)cancelButtonClick:(UIButton *)sender {
+    if (self.navigationController) {
+        [self.navigationController popViewControllerAnimated:YES];
+    } else {
+        [self dismissViewControllerAnimated:YES completion:nil];
+    }
+}
+
+- (void)deleteButtonClick:(UIButton *)sender {
+    if (self.index > 0) {
+        
+        JKDotView *dot = [self.dotArray objectAtIndex:self.index - 1];
+        dot.state = JKDotStateNormal;
+        
+        self.input = [self.input substringToIndex:self.index - 1];
+        self.index--;
+        
+    }
+}
+
+
+- (void)verifyPassword {
+    
+    self.index = 0;
+    for (JKDotView *dot in self.dotArray) {
+        dot.state = JKDotStateNormal;
+    }
+    
+    if (self.password) { // 验证
+        NSLog(@"password: %@",self.password);
+        if ([self.password isEqualToString:self.input]) {
+            
+            [[NSUserDefaults standardUserDefaults] setObject:self.password forKey:self.passwordKey];
+            [[NSUserDefaults standardUserDefaults] synchronize];
+            
+            self.tipLabel.text = @"Please Input Your Password";
+            [self cancelButtonClick:nil];// 返回前一个页面
+            sleep(0.25);// 先回到前一个页面才做事情,0.25s为隐式动画持续时间
+            if (self.authoReturn) {
+                self.authoReturn(YES);
+            }
+            
+            
+        } else {
+            
+            self.tipLabel.text = @"The Password Doesn't Match,Please Try Again";
+        }
+        
+    } else { //设置
+        
+        self.password = self.input;
+        self.tipLabel.text = @"Please Check The Password Again";
+    }
+    self.input = @"";
+}
+
+
+@end

+ 13 - 2
RedAnt ERP Mobile/iSales-NPD/PriceSettingViewController.m

@@ -12,6 +12,7 @@
 #import "CategoryPriceViewController.h"
 #import "CategoryPriceViewController.h"
 #import "iSalesNetwork.h"
 #import "iSalesNetwork.h"
 #import "Singleton.h"
 #import "Singleton.h"
+#import <objc/runtime.h>
 
 
 
 
 
 
@@ -44,9 +45,13 @@
 
 
 - (void)configAppearance {
 - (void)configAppearance {
     
     
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    self.showPrice = !appDelegate.price_hidden;
     
     
     [self changePriceType:self.priceType];
     [self changePriceType:self.priceType];
-    self.showButton.selected = self.showPrice;
+    self.showButton.selected = !self.showPrice;
     
     
     UIBarButtonItem *closeButton =   [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
     UIBarButtonItem *closeButton =   [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
                                                                       style:UIBarButtonItemStylePlain
                                                                       style:UIBarButtonItemStylePlain
@@ -93,8 +98,14 @@
 - (IBAction)showOrHidePriceButtonClick:(UIButton *)sender {
 - (IBAction)showOrHidePriceButtonClick:(UIButton *)sender {
     
     
     sender.selected = !sender.selected;
     sender.selected = !sender.selected;
-    self.showPrice = sender.selected;
+    self.showPrice = !sender.selected;
+    
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    [appDelegate set_priceHidden:sender.selected];
     
     
+    objc_msgSend(appDelegate.main_vc,@selector(initMenuItems));// initMenuItems 不是公开的方法
 }
 }
 
 
 - (IBAction)calculatePriceButtonClick:(UIButton *)sender {
 - (IBAction)calculatePriceButtonClick:(UIButton *)sender {