|
@@ -6,31 +6,37 @@
|
|
|
//
|
|
|
|
|
|
#import "KSBaseWKWebViewController.h"
|
|
|
-#import "JPUSHService.h"
|
|
|
-#import "LoginViewController.h"
|
|
|
-#import "AppDelegate.h"
|
|
|
-#import "CustomNavViewController.h"
|
|
|
-#import "UIDevice+TFDevice.h"
|
|
|
-#import "KSPremissionAlert.h"
|
|
|
-#import "RecordCheckManager.h"
|
|
|
+#import "WebViewBaseConfig.h" // 基础配置
|
|
|
+#import "UIDevice+TFDevice.h" // 横竖屏
|
|
|
+
|
|
|
+// 其他web
|
|
|
#import "KSLocalWebViewController.h"
|
|
|
#import "KSAccompanyWebViewController.h"
|
|
|
-#import "KSChatConversationViewController.h"
|
|
|
-#import "KSGroupConversationController.h"
|
|
|
+
|
|
|
+#import "AppDelegate+AppService.h"
|
|
|
+#import "UserInfoManager.h"
|
|
|
#import "KSMediaManager.h"
|
|
|
-#import <AVFoundation/AVFoundation.h>
|
|
|
-#import "KSDocumentViewController.h"
|
|
|
+#import "KSUMShareManager.h"
|
|
|
+#import "KSOrderManager.h"
|
|
|
+#import "KSEnterLiveroomManager.h"
|
|
|
+
|
|
|
+// 保存文件
|
|
|
#import "KSICloudManager.h"
|
|
|
+#import "KSDocumentViewController.h"
|
|
|
+
|
|
|
+// 聊天
|
|
|
+#import "KSChatConversationViewController.h"
|
|
|
+#import "KSGroupConversationController.h"
|
|
|
+// 业务页面
|
|
|
#import "AddressListViewController.h"
|
|
|
-#import "KSOrderManager.h"
|
|
|
-#import "KSUMShareManager.h"
|
|
|
-#import "TZImageManager.h"
|
|
|
#import "MusicRoomViewController.h"
|
|
|
-#import "KSEnterLiveroomManager.h"
|
|
|
-#import "KSWebLoadRefreshView.h"
|
|
|
-#import "UserInfoManager.h"
|
|
|
+
|
|
|
+// 视频封面选择
|
|
|
#import "KSVideoCropViewController.h"
|
|
|
|
|
|
+// 错误刷新web 页面
|
|
|
+#import "KSWebLoadRefreshView.h"
|
|
|
+
|
|
|
typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
CHOOSETYPE_XML,
|
|
|
CHOOSETYPE_MIDI,
|
|
@@ -44,14 +50,10 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
@property (nonatomic,weak) CALayer *progressLayer;
|
|
|
|
|
|
-@property (nonatomic, strong) NSString *currerntURL; // 当前web URL
|
|
|
-
|
|
|
@property (nonatomic, assign) BOOL hasModify;
|
|
|
|
|
|
@property (nonatomic, assign) BOOL hasChangeSource; // 是否切换了亮屏,横屏等配置
|
|
|
|
|
|
-@property (nonatomic, assign) BOOL landScape;
|
|
|
-
|
|
|
/// 选择本地文件 parm
|
|
|
@property (nonatomic, strong) NSMutableDictionary *chooseFileParm;
|
|
|
|
|
@@ -86,35 +88,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureViewTips:) name:UIScreenCapturedDidChangeNotification object:nil];
|
|
|
}
|
|
|
|
|
|
-- (void)captureViewTips:(NSNotification *)notification {
|
|
|
- [self checkCaptured];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)checkCaptured {
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- if ([self checkIsCaptured]) {
|
|
|
- [self didCapturedView];
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-#pragma mark ---- 镜像和投屏检测
|
|
|
-- (BOOL)checkIsCaptured {
|
|
|
- if ([UIScreen mainScreen].isCaptured && [UIScreen screens].count < 2) {
|
|
|
- return YES;
|
|
|
- }
|
|
|
- return NO;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)didCapturedView {
|
|
|
-
|
|
|
- NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
- [sendParm setValue:@"setVideoPlayer" forKey:@"api"];
|
|
|
- NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
- [content setValue:@"pause" forKey:@"status"];
|
|
|
- [sendParm setValue:content forKey:@"content"];
|
|
|
- [self postMessage:sendParm];
|
|
|
-}
|
|
|
-
|
|
|
- (void)operationDealCallbackMessage:(NSNotification *)notification {
|
|
|
NSString *status = [notification object];
|
|
|
NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
@@ -139,7 +112,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
|
|
|
- (void)changeOrientation:(BOOL)isLandScape {
|
|
|
- self.landScape = isLandScape;
|
|
|
if (isLandScape) {
|
|
|
// 切换到横屏
|
|
|
AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
@@ -163,9 +135,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
self.isFirstLoad = NO;
|
|
|
|
|
|
- if ([UIScreen mainScreen].isCaptured) {
|
|
|
- [self didCapturedView];
|
|
|
- }
|
|
|
+ [self checkCaptured];
|
|
|
}
|
|
|
|
|
|
- (void)sendResumeMessage {
|
|
@@ -220,7 +190,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
WeakWebViewScriptMessageDelegate *weakScriptMessageDelegate = [[WeakWebViewScriptMessageDelegate alloc] initWithDelegate:self];
|
|
|
//这个类主要用来做native与JavaScript的交互管理
|
|
|
WKUserContentController * wkUController = [[WKUserContentController alloc] init];
|
|
|
- [wkUController addScriptMessageHandler:weakScriptMessageDelegate name:@"COLEXIU"];
|
|
|
+ [wkUController addScriptMessageHandler:weakScriptMessageDelegate name:SCRIPT_NAME];
|
|
|
config.userContentController = wkUController;
|
|
|
|
|
|
WKPreferences *preferences = [WKPreferences new];
|
|
@@ -233,19 +203,22 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
_myWebView.UIDelegate = self;
|
|
|
_myWebView.navigationDelegate = self;
|
|
|
_myWebView.scrollView.bounces = NO;
|
|
|
+#ifdef DEBUG
|
|
|
+ if (@available(iOS 16.4, *)) {
|
|
|
+ _myWebView.inspectable = YES;
|
|
|
+ }
|
|
|
+#endif
|
|
|
// 加载进度条和title
|
|
|
[_myWebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
|
|
|
+ [_myWebView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
|
|
|
[self.view addSubview:_myWebView];
|
|
|
[_myWebView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.right.mas_equalTo(self.view);
|
|
|
make.top.mas_equalTo(self.view.mas_top);
|
|
|
make.bottom.mas_equalTo(self.view.mas_bottom);
|
|
|
}];
|
|
|
- if (@available(iOS 11.0, *)) {
|
|
|
- _myWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
- } else {
|
|
|
- // Fallback on earlier versions
|
|
|
- }
|
|
|
+ _myWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
+
|
|
|
[self setupProgress];
|
|
|
|
|
|
[self loadRequest];
|
|
@@ -257,7 +230,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)configUserAgent:(WKWebViewConfiguration *)config {
|
|
|
NSString *oldUserAgent = config.applicationNameForUserAgent;
|
|
|
- NSString *newAgent = [NSString stringWithFormat:@"%@ %@ %@",oldUserAgent,@"COLEXIUAPPI",@"COLEXIUTEACHER"];
|
|
|
+ NSString *newAgent = [NSString stringWithFormat:@"%@ %@ %@",oldUserAgent,AGENT_NAME,AGENT_DOMAIN];
|
|
|
config.applicationNameForUserAgent = newAgent;
|
|
|
}
|
|
|
|
|
@@ -286,6 +259,22 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
|
|
|
#pragma mark --- 返回按钮的处理
|
|
|
+
|
|
|
+- (void)backPreViewAction {
|
|
|
+ [self.myWebView stopLoading];
|
|
|
+ if (_backRootView) {
|
|
|
+ [self.navigationController popToRootViewControllerAnimated:NO];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (_isBackPreView) {
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)backAction {
|
|
|
[self.myWebView stopLoading];
|
|
|
if (_backRootView) {
|
|
@@ -309,7 +298,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
- (void)userContentController:(WKUserContentController *)userContentController
|
|
|
didReceiveScriptMessage:(WKScriptMessage *)message {
|
|
|
|
|
|
- if ([message.name isEqualToString:@"COLEXIU"]) {
|
|
|
+ if ([message.name isEqualToString:SCRIPT_NAME]) {
|
|
|
NSDictionary *parm = [self convertJsonStringToNSDictionary:message.body];
|
|
|
// 回到主线程
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -320,7 +309,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)handleScriptMessageSource:(NSDictionary *)parm {
|
|
|
if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"back"]) { // 返回
|
|
|
- [self.navigationController popViewControllerAnimated:YES];
|
|
|
+ [self backPreViewAction];
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"goBack"]) { // 逐级返回
|
|
|
[self backAction];
|
|
@@ -337,10 +326,8 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
detailCtrl.parmDic = valueDic;
|
|
|
NSInteger orientation = [valueDic ks_integerValueForKey:@"orientation"];
|
|
|
BOOL isLandScape = orientation == 0 ? YES : NO;
|
|
|
- if (isLandScape == self.landScape) {
|
|
|
- self.keepOrientation = YES;
|
|
|
- detailCtrl.keepOrientation = YES;
|
|
|
- }
|
|
|
+ detailCtrl.ks_landScape = isLandScape;
|
|
|
+
|
|
|
[self postMessage:parm];
|
|
|
[self.navigationController pushViewController:detailCtrl animated:YES];
|
|
|
}
|
|
@@ -349,6 +336,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
// 横竖屏
|
|
|
NSInteger orientation = [valueDic ks_integerValueForKey:@"orientation"];
|
|
|
BOOL isLandScape = orientation == 0 ? YES : NO;
|
|
|
+ self.ks_landScape = isLandScape;
|
|
|
[self changeOrientation:isLandScape];
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"keepScreenLongLight"]) {
|
|
@@ -401,10 +389,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
NSInteger orientation = [valueDic ks_integerValueForKey:@"orientation"];
|
|
|
BOOL isLandScape = orientation == 0 ? YES : NO;
|
|
|
detailCtrl.ks_landScape = isLandScape;
|
|
|
- if (isLandScape == self.landScape) {
|
|
|
- self.keepOrientation = YES;
|
|
|
- detailCtrl.keepOrientation = YES;
|
|
|
- }
|
|
|
[self postMessage:parm];
|
|
|
[self.navigationController pushViewController:detailCtrl animated:YES];
|
|
|
}
|
|
@@ -431,45 +415,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
//
|
|
|
[self shareFunctionWithParm:parm];
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getNavHeight"]) { // 获取状态栏高度和 title heigt
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- [valueDic setValue:[NSNumber numberWithFloat:STATUS_GAP*2] forKey:@"navHeight"];
|
|
|
- [valueDic setValue:@(44*2) forKey:@"titleHeight"];
|
|
|
- [parm setValue:valueDic forKey:@"content"];
|
|
|
- [self postMessage:parm];
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"backIconChange"]) {
|
|
|
- /*
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *backColor = [valueDic ks_stringValueForKey:@"iconStyle"];
|
|
|
- NSString *backImage = @"";
|
|
|
- if ([backColor isEqualToString:@"black"]) {
|
|
|
- backImage = @"back_black";
|
|
|
- }
|
|
|
- else {
|
|
|
- backImage = @"back_button_white";
|
|
|
- }
|
|
|
- [self.webBackButton.backButton setImage:[UIImage imageNamed:backImage] forState:UIControlStateNormal];
|
|
|
- // 是否隐藏按钮
|
|
|
- BOOL hideButton = [valueDic ks_boolValueForKey:@"backIconHide"];
|
|
|
- self.webBackButton.hidden = hideButton;
|
|
|
- */
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setBarStatus"]) { // 顶部是否隐藏
|
|
|
- /*
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- BOOL isShow = [valueDic ks_boolValueForKey:@"status"]; // 0 隐藏 1 显示
|
|
|
- self.hiddenNavBar = !isShow;
|
|
|
- CGFloat navHeight = isShow ? kNaviBarHeight : 0;
|
|
|
- [self.navView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.height.mas_equalTo(navHeight);
|
|
|
- }];
|
|
|
-
|
|
|
- [self.myWebView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
|
|
|
- }];
|
|
|
- */
|
|
|
- }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setStatusBarTextColor"]) { // 设置状态栏颜色
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
BOOL whiteColor = [valueDic ks_boolValueForKey:@"statusBarTextColor"];
|
|
@@ -485,6 +430,38 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getNavHeight"]) { // 获取状态栏高度和 title heigt
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ [valueDic setValue:[NSNumber numberWithFloat:STATUS_GAP*2] forKey:@"navHeight"];
|
|
|
+ [valueDic setValue:@(44*2) forKey:@"titleHeight"];
|
|
|
+ [parm setValue:valueDic forKey:@"content"];
|
|
|
+ [self postMessage:parm];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinChatGroup"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *targetId = [valueDic ks_stringValueForKey:@"id"];
|
|
|
+ if ([[valueDic ks_stringValueForKey:@"type"] isEqualToString:@"single"]) { // 单聊
|
|
|
+
|
|
|
+
|
|
|
+ TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
|
|
|
+ model.userID = targetId;
|
|
|
+ KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
|
|
|
+ ctrl.conversation = model;
|
|
|
+ [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if ([[valueDic ks_stringValueForKey:@"type"] isEqualToString:@"multi"]) { // 群聊
|
|
|
+ if ([NSString isEmptyString:targetId]) {
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
|
|
|
+ model.groupID = targetId;
|
|
|
+ KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
|
|
|
+ ctrl.conversation = model;
|
|
|
+ [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
+ }
|
|
|
+ }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"chooseFile"]) {
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
self.chooseFileParm = [NSMutableDictionary dictionaryWithDictionary:valueDic];
|
|
@@ -503,24 +480,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}];
|
|
|
[self.navigationController pushViewController:ctrl animated:YES];
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"paymentOrder"]) {
|
|
|
- NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *channel = [content ks_stringValueForKey:@"payChannel"];
|
|
|
- if ([channel isEqualToString:@"ali_app"]) {
|
|
|
- NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
- [KSOrderManager dealWithAliSDK:infoMessage];
|
|
|
- }
|
|
|
- else if ([channel isEqualToString:@"wx_app"]) {
|
|
|
- NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
- [KSOrderManager dealWithWXSDK:infoMessage];
|
|
|
- }
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinLiveRoom"]) { // 进入直播间
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *roomId = [valueDic ks_stringValueForKey:@"roomId"];
|
|
|
- [self joinLiveRoomWithRoomId:roomId];
|
|
|
-
|
|
|
- }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"savePicture"]) { // 保存图片到相册
|
|
|
// 判断相册权限
|
|
|
PREMISSIONTYPE albumEnable = [RecordCheckManager checkPhotoLibraryPremissionAvaiable:NO showInView:nil];
|
|
@@ -543,44 +502,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openCourseDetail"]) {
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
- if ([type isEqualToString:@"pianoRoom"]) { // 琴房
|
|
|
- NSString *courseId = [valueDic ks_stringValueForKey:@"courseId"];
|
|
|
- MusicRoomViewController *ctrl = [[MusicRoomViewController alloc] init];
|
|
|
- ctrl.courseId = courseId;
|
|
|
- [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
- }
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinChatGroup"]) {
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *targetId = [valueDic ks_stringValueForKey:@"id"];
|
|
|
- if ([[valueDic ks_stringValueForKey:@"type"] isEqualToString:@"single"]) { // 单聊
|
|
|
-
|
|
|
-
|
|
|
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
|
|
|
- model.userID = targetId;
|
|
|
- KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
|
|
|
- ctrl.conversation = model;
|
|
|
- [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
-
|
|
|
- }
|
|
|
- else if ([[valueDic ks_stringValueForKey:@"type"] isEqualToString:@"multi"]) { // 群聊
|
|
|
- if ([NSString isEmptyString:targetId]) {
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
|
|
|
- return;
|
|
|
- }
|
|
|
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
|
|
|
- model.groupID = targetId;
|
|
|
- KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
|
|
|
- ctrl.conversation = model;
|
|
|
- [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
- }
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openPageSuccess"]) {
|
|
|
- [self backAction];
|
|
|
- }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getVersion"]) {
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
@@ -595,23 +516,83 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
if ([type isEqualToString:@"video"]) {
|
|
|
- NSString *status = [UIScreen mainScreen].isCaptured ? @"1" : @"0";
|
|
|
- NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
- [sendParm setValue:@"getDeviceStatus" forKey:@"api"];
|
|
|
- NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
- [content setValue:[valueDic ks_stringValueForKey:@"type"] forKey:@"type"];
|
|
|
- [content setValue:[valueDic ks_stringValueForKey:@"uuid"] forKey:@"uuid"];
|
|
|
- [content setValue:status forKey:@"status"];
|
|
|
- [sendParm setValue:content forKey:@"content"];
|
|
|
- [self postMessage:sendParm];
|
|
|
- if ([status isEqualToString:@"1"]) {
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"为了保证数据安全,请不要录屏"];
|
|
|
- }
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ NSString *status;
|
|
|
+ if ([self checkIsCaptured]) {
|
|
|
+ status = @"1";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ status = @"0";
|
|
|
+ }
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"getDeviceStatus" forKey:@"api"];
|
|
|
+ NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
+ [content setValue:[valueDic ks_stringValueForKey:@"type"] forKey:@"type"];
|
|
|
+ [content setValue:[valueDic ks_stringValueForKey:@"uuid"] forKey:@"uuid"];
|
|
|
+ [content setValue:status forKey:@"status"];
|
|
|
+ [sendParm setValue:content forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+ if ([status isEqualToString:@"1"]) {
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"为了保证数据安全,请不要录屏"];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setEventTracking"]) {
|
|
|
- NSString *type = [[parm ks_dictionaryValueForKey:@"content"] ks_stringValueForKey:@"type"];
|
|
|
- [USER_MANAGER sendUMEvent:type];
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"callPhone"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *phone = [valueDic ks_stringValueForKey:@"phone"];
|
|
|
+ [self CallPhoneWith:phone];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setCache"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *key = [valueDic ks_stringValueForKey:@"key"];
|
|
|
+ NSString *value = [valueDic ks_stringValueForKey:@"value"];
|
|
|
+ UserDefaultSetObjectForKey(value, key);
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getCache"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *key = [valueDic ks_stringValueForKey:@"key"];
|
|
|
+ NSString *value = UserDefault(key);
|
|
|
+
|
|
|
+ NSMutableDictionary *parm = [NSMutableDictionary dictionaryWithDictionary:valueDic];
|
|
|
+ [parm setValue:value forKey:@"value"];
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"getCache" forKey:@"api"];
|
|
|
+ [sendParm setValue:parm forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"isInstall"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
+
|
|
|
+ NSURL *url = [NSURL URLWithString:type];
|
|
|
+ BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
|
|
|
+ NSInteger installStatus = canOpen ? 1 : 0;
|
|
|
+
|
|
|
+ NSMutableDictionary *parm = [NSMutableDictionary dictionaryWithDictionary:valueDic];
|
|
|
+ [parm setValue:@(installStatus) forKey:@"installStatus"];
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"isInstall" forKey:@"api"];
|
|
|
+ [sendParm setValue:parm forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openApp"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
+
|
|
|
+ NSURL *url = [NSURL URLWithString:type];
|
|
|
+ if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
|
|
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"downloadApp"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *openUrl = [valueDic ks_stringValueForKey:@"url"];
|
|
|
+ bool can = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:openUrl]];
|
|
|
+ if(can){
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:openUrl] options:@{} completionHandler:nil];
|
|
|
+ }
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"shareTripartite"]) { // 分享到微信
|
|
|
[self shareToWeChat:parm];
|
|
@@ -635,6 +616,41 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
ctrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
[self.navigationController presentViewController:ctrl animated:YES completion:nil];
|
|
|
}
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"paymentOrder"]) {
|
|
|
+ NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *channel = [content ks_stringValueForKey:@"payChannel"];
|
|
|
+ if ([channel isEqualToString:@"ali_app"]) {
|
|
|
+ NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
+ [KSOrderManager dealWithAliSDK:infoMessage];
|
|
|
+ }
|
|
|
+ else if ([channel isEqualToString:@"wx_app"]) {
|
|
|
+ NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
+ [KSOrderManager dealWithWXSDK:infoMessage];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinLiveRoom"]) { // 进入直播间
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *roomId = [valueDic ks_stringValueForKey:@"roomId"];
|
|
|
+ [self joinLiveRoomWithRoomId:roomId];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openCourseDetail"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
+ if ([type isEqualToString:@"pianoRoom"]) { // 琴房
|
|
|
+ NSString *courseId = [valueDic ks_stringValueForKey:@"courseId"];
|
|
|
+ MusicRoomViewController *ctrl = [[MusicRoomViewController alloc] init];
|
|
|
+ ctrl.courseId = courseId;
|
|
|
+ [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openPageSuccess"]) {
|
|
|
+ [self backAction];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setEventTracking"]) {
|
|
|
+ NSString *type = [[parm ks_dictionaryValueForKey:@"content"] ks_stringValueForKey:@"type"];
|
|
|
+ [USER_MANAGER sendUMEvent:type];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)videCropImage:(UIImage *)cover content:(NSDictionary *)content {
|
|
@@ -1045,14 +1061,18 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *_Nullable))completionHandler
|
|
|
{
|
|
|
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
|
|
- if (challenge.previousFailureCount == 0) {
|
|
|
- NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
|
|
- completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
|
|
|
- } else {
|
|
|
- completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
|
|
|
+
|
|
|
+ dispatch_queue_t queue = dispatch_queue_create("webViewChallengeQueue", NULL);
|
|
|
+ dispatch_async(queue, ^{
|
|
|
+ if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
|
|
+ if (challenge.previousFailureCount == 0) {
|
|
|
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
|
|
+ completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
|
|
|
+ } else {
|
|
|
+ completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
//当因为某些问题,导致webView进程终止时触发
|
|
@@ -1524,6 +1544,36 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#pragma mark ---- 镜像和投屏检测
|
|
|
+- (void)captureViewTips:(NSNotification *)notification {
|
|
|
+ [self checkCaptured];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)checkCaptured {
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ if ([self checkIsCaptured]) {
|
|
|
+ [self didCapturedView];
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+- (BOOL)checkIsCaptured {
|
|
|
+ if ([UIScreen mainScreen].isCaptured && [UIScreen screens].count < 2) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ return NO;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)didCapturedView {
|
|
|
+
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"setVideoPlayer" forKey:@"api"];
|
|
|
+ NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
+ [content setValue:@"pause" forKey:@"status"];
|
|
|
+ [sendParm setValue:content forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|