|
@@ -16,11 +16,10 @@
|
|
|
#import "RAProgressHUD.h"
|
|
#import "RAProgressHUD.h"
|
|
|
#import <MessageUI/MessageUI.h>
|
|
#import <MessageUI/MessageUI.h>
|
|
|
#import "LPShareActivity.h"
|
|
#import "LPShareActivity.h"
|
|
|
-
|
|
|
|
|
#import "NSDictionary+Extension.h"
|
|
#import "NSDictionary+Extension.h"
|
|
|
-
|
|
|
|
|
#import "RAPhotoPreviewController.h"
|
|
#import "RAPhotoPreviewController.h"
|
|
|
#import "RAPhotoModel.h"
|
|
#import "RAPhotoModel.h"
|
|
|
|
|
+#import "RAMapNavigateHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface RAWKWebView () <UINavigationControllerDelegate,UIImagePickerControllerDelegate,MFMailComposeViewControllerDelegate>
|
|
@interface RAWKWebView () <UINavigationControllerDelegate,UIImagePickerControllerDelegate,MFMailComposeViewControllerDelegate>
|
|
@@ -29,13 +28,6 @@
|
|
|
|
|
|
|
|
@implementation RAWKWebView
|
|
@implementation RAWKWebView
|
|
|
|
|
|
|
|
-/*
|
|
|
|
|
-// Only override drawRect: if you perform custom drawing.
|
|
|
|
|
-// An empty implementation adversely affects performance during animation.
|
|
|
|
|
-- (void)drawRect:(CGRect)rect {
|
|
|
|
|
- // Drawing code
|
|
|
|
|
-}
|
|
|
|
|
-*/
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
{
|
|
{
|
|
|
self = [super initWithFrame:frame];
|
|
self = [super initWithFrame:frame];
|
|
@@ -43,10 +35,6 @@
|
|
|
|
|
|
|
|
[self initWKWebView];
|
|
[self initWKWebView];
|
|
|
[self initMessageHandler];
|
|
[self initMessageHandler];
|
|
|
-// WKPreferences *preferences = [WKPreferences new];
|
|
|
|
|
-// preferences.javaScriptCanOpenWindowsAutomatically = YES;
|
|
|
|
|
-// preferences.minimumFontSize = 40.0;
|
|
|
|
|
-// self.configuration.preferences = preferences;
|
|
|
|
|
}
|
|
}
|
|
|
return self;
|
|
return self;
|
|
|
}
|
|
}
|
|
@@ -103,7 +91,7 @@
|
|
|
[self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Photo"];
|
|
[self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Photo"];
|
|
|
[self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Email"];
|
|
[self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Email"];
|
|
|
[self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Preview"];
|
|
[self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Preview"];
|
|
|
- [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Navigation"];
|
|
|
|
|
|
|
+ [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Navigation"];
|
|
|
|
|
|
|
|
|
|
|
|
|
// [self.configuration.userContentController addScriptMessageHandler:self name:@"Color"];
|
|
// [self.configuration.userContentController addScriptMessageHandler:self name:@"Color"];
|
|
@@ -183,20 +171,6 @@
|
|
|
|
|
|
|
|
[self.ra_viewController.navigationController pushViewController:scanVC animated:YES];
|
|
[self.ra_viewController.navigationController pushViewController:scanVC animated:YES];
|
|
|
}
|
|
}
|
|
|
--(void) webPageCallback:(NSDictionary*)params caller:(NSString*) callerid value:(NSObject*)value
|
|
|
|
|
-{
|
|
|
|
|
- NSString *jsStr = [NSString stringWithFormat:params[@"callback"],callerid,value];
|
|
|
|
|
- [self.wkwebView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
|
|
|
- NSLog(@"%@----%@",result, error);
|
|
|
|
|
- }];
|
|
|
|
|
-}
|
|
|
|
|
--(void) webPageReturn:(NSString*) returnid value:(NSObject*)value
|
|
|
|
|
-{
|
|
|
|
|
- NSString *jsStr = [NSString stringWithFormat:@"document.getElementById(\"%@\").value = %@;",returnid,value];
|
|
|
|
|
- [self.wkwebView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
|
|
|
- NSLog(@"%@----%@",result, error);
|
|
|
|
|
- }];
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
- (void)ra_previewDocument:(NSDictionary *)params {
|
|
- (void)ra_previewDocument:(NSDictionary *)params {
|
|
|
/**
|
|
/**
|
|
@@ -330,40 +304,6 @@
|
|
|
|
|
|
|
|
// 选中分享类型
|
|
// 选中分享类型
|
|
|
[activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
|
|
[activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
|
|
|
-
|
|
|
|
|
-//<<<<<<< .mine
|
|
|
|
|
-// } completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
-//
|
|
|
|
|
-// int code = [[result objectForKey:@"result"] intValue];
|
|
|
|
|
-// if (code == RESULT_TRUE) {
|
|
|
|
|
-//
|
|
|
|
|
-// NSString *path = [result objectForKey:@"path"];
|
|
|
|
|
-//
|
|
|
|
|
-// NSArray *activityItems = @[[NSURL URLWithString:url]];
|
|
|
|
|
-//
|
|
|
|
|
-// // 服务类型控制器
|
|
|
|
|
-// UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:@[]];
|
|
|
|
|
-// // _activityViewController = activityViewController;
|
|
|
|
|
-// // activityViewController.excludedActivityTypes = @[UIActivityTypeMail];
|
|
|
|
|
-// activityViewController.modalInPopover = true;
|
|
|
|
|
-//
|
|
|
|
|
-// // 选中分享类型
|
|
|
|
|
-// [activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
|
|
|
|
|
-//
|
|
|
|
|
-// // 显示选中的分享类型
|
|
|
|
|
-// NSLog(@"act type %@",activityType);
|
|
|
|
|
-//
|
|
|
|
|
-// if (completed) {
|
|
|
|
|
-// NSLog(@"ok");
|
|
|
|
|
-// }else {
|
|
|
|
|
-// NSLog(@"not ok");
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }];
|
|
|
|
|
-//
|
|
|
|
|
-// [self.ra_viewController presentViewController:activityViewController animated:YES completion:nil];
|
|
|
|
|
-//
|
|
|
|
|
-//=======
|
|
|
|
|
// 显示选中的分享类型
|
|
// 显示选中的分享类型
|
|
|
NSLog(@"act type %@",activityType);
|
|
NSLog(@"act type %@",activityType);
|
|
|
|
|
|
|
@@ -371,7 +311,7 @@
|
|
|
NSLog(@"ok");
|
|
NSLog(@"ok");
|
|
|
}else {
|
|
}else {
|
|
|
NSLog(@"not ok");
|
|
NSLog(@"not ok");
|
|
|
-//>>>>>>> .r39012
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}];
|
|
}];
|
|
@@ -381,14 +321,6 @@
|
|
|
|
|
|
|
|
- (void)ra_viewPhotos:(NSDictionary *)params {
|
|
- (void)ra_viewPhotos:(NSDictionary *)params {
|
|
|
|
|
|
|
|
-// NSArray *arr = @[
|
|
|
|
|
-// @"http://192.168.0.130/s1.jpg",
|
|
|
|
|
-// @"http://192.168.0.130/s2.jpg",
|
|
|
|
|
-// @"http://192.168.0.130/s3.jpg",
|
|
|
|
|
-// @"http://192.168.0.130/s4.jpg",
|
|
|
|
|
-// @"http://192.168.0.130/s5.jpg"
|
|
|
|
|
-// ];
|
|
|
|
|
-
|
|
|
|
|
NSArray *urlArr = [params objectForKey:@"images"];
|
|
NSArray *urlArr = [params objectForKey:@"images"];
|
|
|
NSUInteger index = [[params objectForKey:@"index"] integerValue];
|
|
NSUInteger index = [[params objectForKey:@"index"] integerValue];
|
|
|
|
|
|
|
@@ -407,7 +339,33 @@
|
|
|
[self.ra_viewController presentViewController:previewController animated:YES completion:nil];
|
|
[self.ra_viewController presentViewController:previewController animated:YES completion:nil];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#pragma mark -MFMailComposeViewControllerDelegate delegate
|
|
|
|
|
|
|
+- (void)ra_navigate:(NSDictionary *)params {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *name = [params objectForKey:@"name"];
|
|
|
|
|
+ NSString *addr = [params objectForKey:@"address"];
|
|
|
|
|
+
|
|
|
|
|
+ [RAMapNavigateHandler ra_navigate:addr withTitle:name viewController:self.ra_viewController];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark - Web Callback
|
|
|
|
|
+
|
|
|
|
|
+-(void) webPageCallback:(NSDictionary*)params caller:(NSString*) callerid value:(NSObject*)value
|
|
|
|
|
+{
|
|
|
|
|
+ NSString *jsStr = [NSString stringWithFormat:params[@"callback"],callerid,value];
|
|
|
|
|
+ [self.wkwebView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
|
|
|
+ NSLog(@"%@----%@",result, error);
|
|
|
|
|
+ }];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(void) webPageReturn:(NSString*) returnid value:(NSObject*)value
|
|
|
|
|
+{
|
|
|
|
|
+ NSString *jsStr = [NSString stringWithFormat:@"document.getElementById(\"%@\").value = %@;",returnid,value];
|
|
|
|
|
+ [self.wkwebView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
|
|
|
+ NSLog(@"%@----%@",result, error);
|
|
|
|
|
+ }];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark - MFMailComposeViewControllerDelegate delegate
|
|
|
|
|
|
|
|
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
|
|
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
|
|
|
switch (result)
|
|
switch (result)
|
|
@@ -605,7 +563,7 @@
|
|
|
|
|
|
|
|
- (void)handleNavigation:(NSDictionary *)params
|
|
- (void)handleNavigation:(NSDictionary *)params
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ [self ra_navigate:params];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)handleJumpTo:(NSDictionary *)params
|
|
- (void)handleJumpTo:(NSDictionary *)params
|