提交web的修改
This commit is contained in:
@@ -2705,7 +2705,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.4.1;
|
MARKETING_VERSION = 1.0.0;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "linyudan.yinmeng-ios";
|
PRODUCT_BUNDLE_IDENTIFIER = "linyudan.yinmeng-ios";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
@@ -2750,7 +2750,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.4.1;
|
MARKETING_VERSION = 1.0.0;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "linyudan.yinmeng-ios";
|
PRODUCT_BUNDLE_IDENTIFIER = "linyudan.yinmeng-ios";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)appName {
|
+ (NSString *)appName {
|
||||||
return @"yinmeng";
|
return @"mew";
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)appBuild{
|
+ (NSString *)appBuild{
|
||||||
@@ -109,12 +109,12 @@ static NSString *_from = nil;
|
|||||||
&& ![from isEqualToString:@""]) {
|
&& ![from isEqualToString:@""]) {
|
||||||
_from = from;
|
_from = from;
|
||||||
} else {
|
} else {
|
||||||
if (isEnterprise) {
|
// if (isEnterprise) {
|
||||||
_from = @"yinmeng_Enterprise"; // 企业包
|
// _from = @"yinmeng_Enterprise"; // 企业包
|
||||||
}else {
|
// }else {
|
||||||
_from = @"yinmeng_appstore"; // App Store包
|
// _from = @"mew_appstore"; // App Store包
|
||||||
}
|
// }
|
||||||
_from = @"yinmeng_Enterprise"; // 企业包
|
_from = @"mew_appstore"; // 企业包
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,22 +6,23 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "YMWebViewController.h"
|
#import "YMWebViewController.h"
|
||||||
|
#import "MewLoginViewController.h"
|
||||||
|
#import "BaseNavigationController.h"
|
||||||
/// Tool
|
/// Tool
|
||||||
#import "ApiHost.h"
|
#import "ApiHost.h"
|
||||||
|
#import "Api+Mine.h"
|
||||||
#import "YYUtility.h"
|
#import "YYUtility.h"
|
||||||
#import "AccountInfoStorage.h"
|
#import "AccountInfoStorage.h"
|
||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
#import "YMMacro.h"
|
#import "YMMacro.h"
|
||||||
#import "NewEncryptTool.h"
|
#import "NewEncryptTool.h"
|
||||||
|
#import "HttpRequestHelper.h"
|
||||||
|
#import "AccountModel.h"
|
||||||
|
#import "YMHUDTool.h"
|
||||||
|
#import "ClientConfig.h"
|
||||||
/// Third
|
/// Third
|
||||||
#import <Masonry/Masonry.h>
|
#import <Masonry/Masonry.h>
|
||||||
|
#import <MJExtension/MJExtension.h>
|
||||||
|
|
||||||
//#ifdef DEBUG
|
|
||||||
//static const NSString *CompanyFirstDomainByWeChatRegister = @"api.uat.lecheng163.com";
|
|
||||||
//#else
|
|
||||||
//static const NSString *CompanyFirstDomainByWeChatRegister = @"api.lecheng163.com";
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
|
|
||||||
@interface WeakWebViewScriptMessageDelegate : NSObject<WKScriptMessageHandler>
|
@interface WeakWebViewScriptMessageDelegate : NSObject<WKScriptMessageHandler>
|
||||||
@@ -54,40 +55,41 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSString * const kJSGetUid = @"getUid";
|
NSString * const kJSGetUid = @"getUid";
|
||||||
|
NSString * const kJSGetDeviceId = @"getDeviceId";
|
||||||
|
NSString * const kJSGetTicket = @"getTicket";
|
||||||
|
NSString * const kJSGetDeviceInfo = @"getDeviceInfo";
|
||||||
|
NSString * const kInitShowNav = @"initShowNav";
|
||||||
|
NSString * const kCloseWebView = @"closeWebView";
|
||||||
|
NSString * const kCancelAccount = @"cancelAccount";
|
||||||
@interface YMWebViewController ()<WKNavigationDelegate, WKScriptMessageHandler>
|
@interface YMWebViewController ()<WKNavigationDelegate, WKScriptMessageHandler>
|
||||||
@property (strong, nonatomic) WKWebView *webview;
|
@property (strong, nonatomic) WKWebView *webview;
|
||||||
|
@property (nonatomic, strong) WKUserContentController *userContentController;
|
||||||
|
///是否隐藏导航栏
|
||||||
|
@property (nonatomic,assign) BOOL isHiddenNav;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation YMWebViewController
|
@implementation YMWebViewController
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
// Do any additional setup after loading the view.
|
self.isHiddenNav = NO;
|
||||||
[self initView];
|
[self initView];
|
||||||
NSString *urlString = [NSString stringWithFormat:@"%@/%@", [NewEncryptTool MEW_aesDecrypt: API_HOST_H5_URL], self.url];
|
|
||||||
[self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)viewWillDisappear:(BOOL)animated {
|
||||||
|
[super viewWillDisappear:animated];
|
||||||
- (void)backButtonClick {
|
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
||||||
BOOL canGoBack = YES;
|
|
||||||
if (self.webview.backForwardList.backList.count <= 1) {
|
|
||||||
canGoBack = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([self.webview canGoBack]) {
|
|
||||||
[self.webview goBack];
|
|
||||||
} else {
|
|
||||||
[self.navigationController popViewControllerAnimated:YES];
|
|
||||||
// [self.userContentController removeAllUserScripts];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
|
[super viewDidAppear:animated];
|
||||||
|
[self.navigationController setNavigationBarHidden:self.isHiddenNav animated:animated];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - InitView
|
|
||||||
- (void)initView {
|
- (void)initView {
|
||||||
if (@available(iOS 11.0, *)) {
|
if (@available(iOS 11.0, *)) {
|
||||||
self.webview.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
self.webview.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||||
@@ -99,19 +101,115 @@ NSString * const kJSGetUid = @"getUid";
|
|||||||
make.left.right.top.bottom.mas_equalTo(self.view);
|
make.left.right.top.bottom.mas_equalTo(self.view);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Set
|
|
||||||
|
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
|
||||||
|
[self.webview evaluateJavaScript:@"document.location.href" completionHandler:^(id _Nullable response, NSError * _Nullable error) {
|
||||||
|
NSLog(@"%@", response);
|
||||||
|
NSString *currentUrl = [NSString stringWithFormat:@"%@", response];
|
||||||
|
///测试环境只要有host就执行,方便h5连接本地调试
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (currentUrl != nil) {
|
||||||
|
#else
|
||||||
|
if (currentUrl != nil) {
|
||||||
|
#endif
|
||||||
|
if ([message.name isEqualToString:kJSGetUid]) {
|
||||||
|
NSString *uid = [[AccountInfoStorage instance] getUid];
|
||||||
|
NSString *js = [NSString stringWithFormat:@"getMessage(\"uid\",%@)", uid];
|
||||||
|
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
|
||||||
|
NSLog(@"%@",error);
|
||||||
|
}];
|
||||||
|
} else if ([message.name isEqualToString:kJSGetTicket]) {
|
||||||
|
NSString *ticket = [[AccountInfoStorage instance] getTicket];
|
||||||
|
NSString *js = [NSString stringWithFormat:@"getMessage(\"ticket\",\"%@\")",ticket];
|
||||||
|
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
|
||||||
|
NSLog(@"%@",error);
|
||||||
|
}];
|
||||||
|
} else if ([message.name isEqualToString:kJSGetDeviceId]) {
|
||||||
|
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceId\",\"%@\")",[YYUtility deviceUniqueIdentification]];
|
||||||
|
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
|
||||||
|
NSLog(@"%@",error);
|
||||||
|
}];
|
||||||
|
} else if ([message.name isEqualToString:kJSGetDeviceInfo]) {
|
||||||
|
NSDictionary *basicParmars = [HttpRequestHelper configBaseParmars:[[NSDictionary alloc] init]];
|
||||||
|
NSString *json = [basicParmars mj_JSONString];
|
||||||
|
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceInfo\",%@)", json];
|
||||||
|
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable ohter, NSError * _Nullable error) {
|
||||||
|
NSLog(@"%@", error);
|
||||||
|
}];
|
||||||
|
} else if([message.name isEqualToString:kInitShowNav]) {
|
||||||
|
if (((NSNumber *)message.body).intValue == 0) {
|
||||||
|
self.isHiddenNav = YES;
|
||||||
|
if (self.navigationController) {
|
||||||
|
[self.navigationController setNavigationBarHidden:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if([message.name isEqualToString:kCloseWebView]) {
|
||||||
|
if (self.navigationController) {
|
||||||
|
[self.navigationController popViewControllerAnimated:YES];
|
||||||
|
}
|
||||||
|
} else if ([message.name isEqualToString:kCancelAccount]) {
|
||||||
|
[YMHUDTool showLoadingWithMessage:@"正在注销中,请稍等"];
|
||||||
|
AccountModel *model = [[AccountInfoStorage instance] accountModel];
|
||||||
|
[Api logoutCurrentAccount:^(BaseModel * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
|
||||||
|
[YMHUDTool showSuccessWithMessage:@"注销成功"];
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||||
|
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
||||||
|
[[AccountInfoStorage instance] saveTicket:nil];
|
||||||
|
///关闭心跳
|
||||||
|
[[ClientConfig shareConfig] resetHeartBratTimer];
|
||||||
|
MewLoginViewController *loginVC = [[MewLoginViewController alloc] init];
|
||||||
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:loginVC];
|
||||||
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||||
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
||||||
|
});
|
||||||
|
|
||||||
|
} access_token:model.access_token];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)setUrl:(NSString *)urlString{
|
- (void)setUrl:(NSString *)urlString{
|
||||||
_url = urlString;
|
_url = urlString;
|
||||||
if (_url == nil) {
|
if (_url == nil) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){
|
||||||
|
_url = [NSString stringWithFormat:@"%@/%@", [NewEncryptTool MEW_aesDecrypt:API_HOST_H5_URL], _url];
|
||||||
|
}
|
||||||
|
if (![_url containsString:@"alipayh5"]) {
|
||||||
|
if (![_url containsString:@"?"]) {
|
||||||
|
_url = [NSString stringWithFormat:@"%@?platform=%@", _url, [YYUtility appName]];
|
||||||
|
} else {
|
||||||
|
_url = [NSString stringWithFormat:@"%@&platform=%@", _url, [YYUtility appName]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去掉 urlString 中的空格。
|
||||||
|
NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""];
|
||||||
|
|
||||||
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]];
|
||||||
|
[self.webview loadRequest:request];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)backButtonClick {
|
||||||
#pragma mark - Get
|
BOOL canGoBack = YES;
|
||||||
|
if (self.webview.backForwardList.backList.count <= 1) {
|
||||||
|
canGoBack = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([self.webview canGoBack]) {
|
||||||
|
[self.webview goBack];
|
||||||
|
} else {
|
||||||
|
[self.navigationController popViewControllerAnimated:YES];
|
||||||
|
[self.userContentController removeAllUserScripts];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (WKWebView *)webview {
|
- (WKWebView *)webview {
|
||||||
if (_webview == nil) {
|
if (_webview == nil) {
|
||||||
@@ -122,18 +220,76 @@ NSString * const kJSGetUid = @"getUid";
|
|||||||
} else {
|
} else {
|
||||||
// Fallback on earlier versions
|
// Fallback on earlier versions
|
||||||
}
|
}
|
||||||
|
configuration.allowsInlineMediaPlayback = YES;
|
||||||
_webview = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
|
||||||
|
|
||||||
|
NSString *uid = [[AccountInfoStorage instance] getUid];
|
||||||
|
NSString *realCookie = [NSString stringWithFormat:@"%@=%@",@"uid",uid];
|
||||||
|
|
||||||
|
WKUserScript *cookieScript = [[WKUserScript alloc] initWithSource: [NSString stringWithFormat:@"document.cookie = '%@';", realCookie] injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
|
||||||
|
[self.userContentController addUserScript:cookieScript];
|
||||||
|
///禁止缩放
|
||||||
|
NSString *scaleJs = @"$('meta[name=description]').remove(); $('head').append( '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1,user-scalable=no\">' );";
|
||||||
|
WKUserScript *scaleScript = [[WKUserScript alloc] initWithSource:scaleJs injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
|
||||||
|
[self.userContentController addUserScript:scaleScript];
|
||||||
|
|
||||||
|
//根据生成的WKUserScript对象,初始化WKWebViewConfiguration
|
||||||
|
configuration.preferences.javaScriptEnabled = YES;
|
||||||
|
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
|
||||||
|
configuration.preferences.minimumFontSize = 10;
|
||||||
|
configuration.selectionGranularity = WKSelectionGranularityCharacter;
|
||||||
|
configuration.userContentController = self.userContentController;
|
||||||
|
|
||||||
|
CGSize size = [UIScreen mainScreen].bounds.size;
|
||||||
|
_webview = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, size.width,size.height) configuration:configuration];
|
||||||
|
|
||||||
|
_webview.navigationDelegate = self;
|
||||||
|
|
||||||
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(backButtonClick)];
|
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(backButtonClick)];
|
||||||
[_webview addGestureRecognizer:swipeGesture];
|
[_webview addGestureRecognizer:swipeGesture];
|
||||||
|
|
||||||
[_webview.scrollView setShowsVerticalScrollIndicator:NO];
|
[_webview.scrollView setShowsVerticalScrollIndicator:NO];
|
||||||
[_webview.scrollView setShowsHorizontalScrollIndicator:NO];
|
[_webview.scrollView setShowsHorizontalScrollIndicator:NO];
|
||||||
|
|
||||||
|
//set useragent
|
||||||
|
__weak typeof(self) weakSelf = self;
|
||||||
|
[_webview evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) {
|
||||||
|
NSString *userAgent = result;
|
||||||
|
|
||||||
|
if (![userAgent containsString:@"tutuAppIos erbanAppIos"]){
|
||||||
|
NSString *newUserAgent = [userAgent stringByAppendingString:@" tutuAppIos erbanAppIos"];
|
||||||
|
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];
|
||||||
|
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
[weakSelf.webview setCustomUserAgent:newUserAgent];
|
||||||
|
}
|
||||||
|
|
||||||
|
}];
|
||||||
_webview.scrollView.bounces = NO;
|
_webview.scrollView.bounces = NO;
|
||||||
}
|
}
|
||||||
return _webview;
|
return _webview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (WKUserContentController *)userContentController{
|
||||||
|
if (!_userContentController) {
|
||||||
|
//自定义的WKScriptMessageHandler 是为了解决内存不释放的问题
|
||||||
|
WeakWebViewScriptMessageDelegate *weakScriptMessageDelegate = [[WeakWebViewScriptMessageDelegate alloc] initWithDelegate:self];
|
||||||
|
_userContentController = [[WKUserContentController alloc] init];
|
||||||
|
// 获取uid
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetUid];
|
||||||
|
// 获取设备id
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetDeviceId];
|
||||||
|
// 获取Ticket
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetTicket];
|
||||||
|
// 获取设备info
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetDeviceInfo];
|
||||||
|
// 隐藏导航栏
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kInitShowNav];
|
||||||
|
// 隐藏导航栏
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCloseWebView];
|
||||||
|
// 注销账号
|
||||||
|
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCancelAccount];
|
||||||
|
}
|
||||||
|
return _userContentController;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Reference in New Issue
Block a user