Bladeren bron

1.修改Apex CRM签名。

Pen Li 7 jaren geleden
bovenliggende
commit
78df2ef472

+ 29 - 0
RedAnt CRM/APEX CRM/APEX CRM.xcodeproj/project.pbxproj

@@ -33,6 +33,10 @@
 		42A8A21A21AE8309003B854B /* RAPhotoPreview.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 42A8A21921AE8309003B854B /* RAPhotoPreview.xcassets */; };
 		42A8A21F21AE842E003B854B /* RAPhotoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A8A21E21AE842E003B854B /* RAPhotoModel.m */; };
 		42A8A22321AE8603003B854B /* UIImage+RedAnt.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A8A22221AE8603003B854B /* UIImage+RedAnt.m */; };
+		42F53F8621B617E4008EAEFC /* signature.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42F53F8021B617E3008EAEFC /* signature.storyboard */; };
+		42F53F8721B617E4008EAEFC /* Signature.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 42F53F8121B617E3008EAEFC /* Signature.xcassets */; };
+		42F53F8821B617E4008EAEFC /* SignatureView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F53F8321B617E3008EAEFC /* SignatureView.m */; };
+		42F53F8921B617E4008EAEFC /* SignatureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F53F8521B617E3008EAEFC /* SignatureViewController.m */; };
 		7106E80A21A684F20056DD20 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7106E80921A684F20056DD20 /* AppDelegate.m */; };
 		7106E80D21A684F20056DD20 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7106E80C21A684F20056DD20 /* ViewController.m */; };
 		7106E81021A684F20056DD20 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7106E80E21A684F20056DD20 /* Main.storyboard */; };
@@ -102,6 +106,12 @@
 		42A8A21E21AE842E003B854B /* RAPhotoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAPhotoModel.m; sourceTree = "<group>"; };
 		42A8A22121AE8603003B854B /* UIImage+RedAnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+RedAnt.h"; sourceTree = "<group>"; };
 		42A8A22221AE8603003B854B /* UIImage+RedAnt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+RedAnt.m"; sourceTree = "<group>"; };
+		42F53F8021B617E3008EAEFC /* signature.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = signature.storyboard; sourceTree = "<group>"; };
+		42F53F8121B617E3008EAEFC /* Signature.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Signature.xcassets; sourceTree = "<group>"; };
+		42F53F8221B617E3008EAEFC /* SignatureView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignatureView.h; sourceTree = "<group>"; };
+		42F53F8321B617E3008EAEFC /* SignatureView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SignatureView.m; sourceTree = "<group>"; };
+		42F53F8421B617E3008EAEFC /* SignatureViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignatureViewController.h; sourceTree = "<group>"; };
+		42F53F8521B617E3008EAEFC /* SignatureViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SignatureViewController.m; sourceTree = "<group>"; };
 		7106E80521A684F20056DD20 /* APEX CRM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "APEX CRM.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		7106E80821A684F20056DD20 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		7106E80921A684F20056DD20 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -349,6 +359,20 @@
 			path = ../../../common/UIImage;
 			sourceTree = "<group>";
 		};
+		42F53F7F21B617E3008EAEFC /* signature */ = {
+			isa = PBXGroup;
+			children = (
+				42F53F8021B617E3008EAEFC /* signature.storyboard */,
+				42F53F8121B617E3008EAEFC /* Signature.xcassets */,
+				42F53F8221B617E3008EAEFC /* SignatureView.h */,
+				42F53F8321B617E3008EAEFC /* SignatureView.m */,
+				42F53F8421B617E3008EAEFC /* SignatureViewController.h */,
+				42F53F8521B617E3008EAEFC /* SignatureViewController.m */,
+			);
+			name = signature;
+			path = "../../../RedAnt ERP Mobile/common/Functions/signature";
+			sourceTree = "<group>";
+		};
 		7106E7FC21A684F20056DD20 = {
 			isa = PBXGroup;
 			children = (
@@ -368,6 +392,7 @@
 		7106E80721A684F20056DD20 /* APEX CRM */ = {
 			isa = PBXGroup;
 			children = (
+				42F53F7F21B617E3008EAEFC /* signature */,
 				4214C4A221B25EA40091A528 /* NSString */,
 				4277784C21AFB96700BCF7FA /* MapNavigation */,
 				42A8A22021AE8603003B854B /* UIImage */,
@@ -486,10 +511,12 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				42F53F8721B617E4008EAEFC /* Signature.xcassets in Resources */,
 				42A8A21A21AE8309003B854B /* RAPhotoPreview.xcassets in Resources */,
 				7106E81521A684F50056DD20 /* LaunchScreen.storyboard in Resources */,
 				4212AB9D21AD2AFE00BE4E45 /* InfoPlist.strings in Resources */,
 				7106E81221A684F50056DD20 /* Assets.xcassets in Resources */,
+				42F53F8621B617E4008EAEFC /* signature.storyboard in Resources */,
 				4212AB8E21AD22AB00BE4E45 /* QRCode.storyboard in Resources */,
 				7106E81021A684F20056DD20 /* Main.storyboard in Resources */,
 				4212ABA321AD2B7300BE4E45 /* Localizable.strings in Resources */,
@@ -509,6 +536,7 @@
 				4277784F21AFB98600BCF7FA /* RAMapNavigateHandler.m in Sources */,
 				4212ABCC21AD450A00BE4E45 /* LPShareActivity.m in Sources */,
 				4212AB9821AD25C800BE4E45 /* RAPreviewController.m in Sources */,
+				42F53F8821B617E4008EAEFC /* SignatureView.m in Sources */,
 				4212ABC521AD3C3200BE4E45 /* RADataProvider.m in Sources */,
 				42A8A21F21AE842E003B854B /* RAPhotoModel.m in Sources */,
 				7106E83D21AD1B070056DD20 /* zip.c in Sources */,
@@ -538,6 +566,7 @@
 				7106E82621A698D20056DD20 /* RAWKWebView.m in Sources */,
 				4212AB9421AD22AB00BE4E45 /* RAExceptionHandler.m in Sources */,
 				4214C4A521B25EC20091A528 /* NSString+RAJavascript.m in Sources */,
+				42F53F8921B617E4008EAEFC /* SignatureViewController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 37 - 10
RedAnt CRM/APEX CRM/APEX CRM/RAWKWebView.m

@@ -21,6 +21,7 @@
 #import "RAPhotoModel.h"
 #import "RAMapNavigateHandler.h"
 #import "NSString+RAJavascript.h"
+#import "SignatureViewController.h"
 
 
 @interface RAWKWebView () <UINavigationControllerDelegate,UIImagePickerControllerDelegate,MFMailComposeViewControllerDelegate>
@@ -97,6 +98,7 @@
     [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Preview"];
     [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Navigation"];
     [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"DatetimePicker"];
+    [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Signature"];
     
     //    [self.configuration.userContentController addScriptMessageHandler:self name:@"Color"];
     //    [self.configuration.userContentController addScriptMessageHandler:self name:@"Pay"];
@@ -110,13 +112,14 @@
     [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Location"];
     [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Share"];
     [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"JumpTo"];
-    [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"ViewImage"];
-    [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"PostDialog"];
-        [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Photo"];
-        [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Email"];
-        [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Preview"];
-    [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Navigation"];
-    [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"DatetimePicker"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"ViewImage"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"PostDialog"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Photo"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Email"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Preview"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Navigation"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"DatetimePicker"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Signature"];
 }
 - (void)dealloc
 {
@@ -364,6 +367,26 @@
     [RAMapNavigateHandler ra_navigate:addr withTitle:name viewController:self.ra_viewController];
 }
 
+- (void)ra_signature:(NSDictionary *)params {
+    
+    __weak typeof(self) weakSelf = self;
+    SignatureViewController *signatureVC = [SignatureViewController ra_signatureViewControllerWithCompletion:^(UIImage *image) {
+        
+        NSData *data = UIImageJPEGRepresentation(image, 1.0);
+        
+        NSString *imageSource = [NSString stringWithFormat:@"data:image/jpg;base64,%@",[data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]];
+        
+        [weakSelf returnToWebPage:params value:imageSource];
+        
+    }];
+    
+    [self.ra_viewController.navigationController pushViewController:signatureVC animated:NO];
+}
+
+- (void)ra_dateTimePicker:(NSDictionary *)params {
+    
+}
+
 #pragma mark - Web Callback
 
 -(void) returnToWebPage:(NSDictionary*)params value:(NSObject*)value
@@ -387,7 +410,7 @@
 //        value =[NSString stringWithFormat:@"'%@'",value];
         value = [(NSString *)value ra_stringByEscapingForJavascriptWithDelimiter:'\'' wrapWithDelimiters:YES];
     }
-    NSString *jsStr = [NSString stringWithFormat:params[@"callback"],caller,value];
+    NSString *jsStr = [NSString stringWithFormat:params[@"callback"],caller.UTF8String,value.description.UTF8String];
     [self.wkwebView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
         NSLog(@"%@----%@",result, error);
     }];
@@ -546,18 +569,22 @@
         NSLog(@"%@",params);
     }
 }
+
 - (void)handleDatetimePicker:(NSDictionary *)params
 {
-    NSLog(@"handleSignature %@",params);
+    [self ra_dateTimePicker:params];
 }
+
 - (void)handleSignature:(NSDictionary *)params
 {
-    NSLog(@"handleSignature %@",params);
+    [self ra_signature:params];
 }
+
 - (void)handleCamScan:(NSDictionary *)params
 {
     [self ra_openQRCodeScanner:params];
 }
+
 - (void)handleLocation:(NSDictionary *)params
 {
     [self returnToWebPage:params value:@"abc,def,'aaa"];

+ 2 - 1
RedAnt CRM/APEX CRM/APEX CRM/ViewController.m

@@ -23,7 +23,8 @@
     
     WKWebTestViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"WKWebTestViewController"];
 
-    vc.url=@"http://192.168.0.138:8080/backend_test/index.html";
+//    vc.url=@"http://192.168.0.138:8080/backend_test/index.html";
+    vc.url = @"http://192.168.0.130:8080/MyWeb/html/test.html";
     [self.navigationController pushViewController:vc animated:YES];
     
     

+ 2 - 0
RedAnt CRM/APEX CRM/APEX CRM/WKWebTestViewController.m

@@ -19,6 +19,8 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
+    [UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor whiteColor];
+    
     if (@available(iOS 11, *)) {
         self.webview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
     } else {