|
@@ -29,7 +29,7 @@
|
|
|
#import "TZImageManager.h"
|
|
|
#import "MusicRoomViewController.h"
|
|
|
#import "KSEnterLiveroomManager.h"
|
|
|
-
|
|
|
+#import "KSWebLoadRefreshView.h"
|
|
|
|
|
|
#import "UserInfoManager.h"
|
|
|
typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
@@ -66,6 +66,8 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isFirstLoad;
|
|
|
|
|
|
+@property (nonatomic, strong) KSWebLoadRefreshView *errorView;
|
|
|
+
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -83,9 +85,22 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
|
|
|
- (void)captureViewTips:(NSNotification *)notification {
|
|
|
- if ([UIScreen mainScreen].isCaptured) {
|
|
|
- [self didCapturedView];
|
|
|
+ [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 {
|
|
@@ -96,17 +111,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[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];
|
|
|
- [sendParm setValue:@"paymentOperation" forKey:@"api"];
|
|
|
- NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
- [content setValue:status forKey:@"status"];
|
|
|
- [sendParm setValue:content forKey:@"content"];
|
|
|
- [self postMessage:sendParm];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -117,13 +121,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[[UIApplication sharedApplication] setIdleTimerDisabled:isOpenLight];
|
|
|
// 横竖屏
|
|
|
NSInteger orientation = [parmDic ks_integerValueForKey:@"orientation"];
|
|
|
-
|
|
|
BOOL isLandScape = orientation == 0 ? YES : NO;
|
|
|
- if (_landScape != isLandScape) {
|
|
|
- [self changeOrientation:isLandScape];
|
|
|
- }
|
|
|
- // 是否隐藏头部导航条
|
|
|
- self.hideTop = [parmDic ks_boolValueForKey:@"isHideTitle"];
|
|
|
+ self.ks_landScape = isLandScape;
|
|
|
+ [self changeOrientation:isLandScape];
|
|
|
}
|
|
|
|
|
|
- (void)changeOrientation:(BOOL)isLandScape {
|
|
@@ -165,40 +165,29 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
[super viewWillDisappear:animated];
|
|
|
- if (_hasChangeSource && self.keepOrientation == NO && self.landScape == YES) {
|
|
|
- [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
- [self changeOrientation:NO];
|
|
|
+ BOOL isBack = [self isViewPopDismiss];
|
|
|
+ if (isBack) {
|
|
|
+ if (self.preCtrl) {
|
|
|
+ if (self.ks_landScape != self.preCtrl.ks_landScape) {
|
|
|
+ [self changeOrientation:self.preCtrl.ks_landScape];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (![self.preCtrl isKindOfClass:[KSBaseWKWebViewController class]]) {
|
|
|
+ [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ KSBaseViewController *nextCtrl = [self getNextViewController];
|
|
|
+ if (nextCtrl) {
|
|
|
+ if (nextCtrl.ks_landScape != self.ks_landScape) {
|
|
|
+ [self changeOrientation:NO];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- self.keepOrientation = NO;
|
|
|
}
|
|
|
|
|
|
- (void)initWebView {
|
|
|
[self.scrollView removeFromSuperview];
|
|
|
- [self.view addSubview:self.navView];
|
|
|
- CGFloat topHeight = kNaviBarHeight;
|
|
|
- if (self.hideTop) {
|
|
|
- topHeight = 0.0f;
|
|
|
- }
|
|
|
- [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.top.mas_equalTo(self.view);
|
|
|
- make.height.mas_equalTo(topHeight);
|
|
|
- }];
|
|
|
-
|
|
|
- [self.view addSubview:self.webBackButton];
|
|
|
- [self.webBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.top.mas_equalTo(self.view);
|
|
|
- make.height.mas_equalTo(kNaviBarHeight);
|
|
|
- make.width.mas_equalTo(44);
|
|
|
- }];
|
|
|
- if (self.hideTop) {
|
|
|
- self.webBackButton.hidden = YES;
|
|
|
- }
|
|
|
- if (_hiddenNavBar) {
|
|
|
- topHeight = 0.0f;
|
|
|
- }
|
|
|
- if (self.headTitle) {
|
|
|
- [self.navView.topTitleLabel setText:_headTitle];
|
|
|
- }
|
|
|
|
|
|
if (_myWebView == nil) {
|
|
|
|
|
@@ -229,11 +218,10 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
_myWebView.scrollView.bounces = NO;
|
|
|
// 加载进度条和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).offset(topHeight);
|
|
|
+ make.top.mas_equalTo(self.view.mas_top);
|
|
|
make.bottom.mas_equalTo(self.view.mas_bottom);
|
|
|
}];
|
|
|
if (@available(iOS 11.0, *)) {
|
|
@@ -244,9 +232,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[self setupProgress];
|
|
|
|
|
|
[self loadRequest];
|
|
|
-
|
|
|
- [self.view bringSubviewToFront:self.navView];
|
|
|
- [self.view bringSubviewToFront:self.webBackButton];
|
|
|
}
|
|
|
else {
|
|
|
[_myWebView reload];
|
|
@@ -320,6 +305,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"back"]) { // 返回
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
}
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"goBack"]) { // 逐级返回
|
|
|
+ [self backAction];
|
|
|
+ }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"login"]) {
|
|
|
// 回到登录页面
|
|
|
[self backLoginView];
|
|
@@ -393,9 +381,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
|
|
|
detailCtrl.url = [valueDic ks_stringValueForKey:@"url"];
|
|
|
detailCtrl.parmDic = valueDic;
|
|
|
- detailCtrl.hiddenNavBar = [valueDic ks_boolValueForKey:@"isHideTitle"];
|
|
|
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;
|
|
@@ -434,6 +422,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[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 = @"";
|
|
@@ -447,8 +436,10 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
// 是否隐藏按钮
|
|
|
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;
|
|
@@ -460,6 +451,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[self.myWebView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
|
|
|
}];
|
|
|
+ */
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"chooseFile"]) {
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
@@ -731,11 +723,8 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
|
|
|
- (void)openSettingView {
|
|
|
- if (@available(iOS 10, *)) {
|
|
|
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
- } else {
|
|
|
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
|
- }
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)displaySource:(NSURL *)localUrl {
|
|
@@ -868,6 +857,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
// 6 页面加载失败时调用
|
|
|
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation {
|
|
|
NSLog(@"6-------页面加载失败时调用");
|
|
|
+ [self showErrorView];
|
|
|
}
|
|
|
|
|
|
// 接收到服务器跳转请求之后调用
|
|
@@ -958,12 +948,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
self.progressLayer.frame = CGRectMake(0, 0, 0, 3);
|
|
|
});
|
|
|
}
|
|
|
- }else if ([keyPath isEqualToString:@"title"]) {
|
|
|
- // 顶部title
|
|
|
- self.headTitle = change[@"new"];
|
|
|
- if (self.hiddenNavBar == NO) {
|
|
|
- self.navView.topTitleLabel.text = self.headTitle;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1024,40 +1008,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
-- (void)setHiddenNavBar:(BOOL)hiddenNavBar {
|
|
|
- _hiddenNavBar = hiddenNavBar;
|
|
|
- if (hiddenNavBar) {
|
|
|
- self.navView.topTitleLabel.text = @"";
|
|
|
- }
|
|
|
- else {
|
|
|
- self.navView.topTitleLabel.text = self.headTitle;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark --- lazying
|
|
|
-- (KSWebNavView *)navView {
|
|
|
- if (!_navView) {
|
|
|
- _navView = [[KSWebNavView alloc] init];
|
|
|
-
|
|
|
- }
|
|
|
- return _navView;
|
|
|
-}
|
|
|
-
|
|
|
-- (KSWebBackButton *)webBackButton {
|
|
|
- if (!_webBackButton) {
|
|
|
- _webBackButton = [[KSWebBackButton alloc] init];
|
|
|
- MJWeakSelf;
|
|
|
- [_webBackButton webViewBackAction:^{
|
|
|
- [weakSelf backAction];
|
|
|
- }];
|
|
|
- }
|
|
|
- return _webBackButton;
|
|
|
-}
|
|
|
-
|
|
|
- (void)dealloc {
|
|
|
[[_myWebView configuration].userContentController removeScriptMessageHandlerForName:@"COLEXIU"];
|
|
|
[_myWebView removeObserver:self forKeyPath:@"estimatedProgress"];
|
|
|
- [_myWebView removeObserver:self forKeyPath:@"title"];
|
|
|
[_myWebView loadHTMLString:@"" baseURL:nil];
|
|
|
[_myWebView removeFromSuperview];
|
|
|
_myWebView = nil;
|
|
@@ -1340,6 +1293,38 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
return filesize;
|
|
|
}
|
|
|
|
|
|
+- (KSWebLoadRefreshView *)errorView {
|
|
|
+ if (!_errorView) {
|
|
|
+ _errorView = [KSWebLoadRefreshView shareInstance];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_errorView failViewActionCallback:^(BOOL isBack) {
|
|
|
+ [weakSelf hideErrorView];
|
|
|
+ if (isBack) {
|
|
|
+ [weakSelf backAction];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [weakSelf loadRequest];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _errorView;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showErrorView {
|
|
|
+ if (![self.view.subviews containsObject:self.errorView]) {
|
|
|
+ [self.view addSubview:self.errorView];
|
|
|
+ [self.errorView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.top.bottom.mas_equalTo(self.view);
|
|
|
+ }];
|
|
|
+ [self.view bringSubviewToFront:self.errorView];
|
|
|
+ }
|
|
|
+}
|
|
|
+- (void)hideErrorView {
|
|
|
+ if ([self.view.subviews containsObject:self.errorView]) {
|
|
|
+ [self.errorView removeFromSuperview];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|