|
@@ -18,6 +18,7 @@
|
|
CGPoint startTouch;
|
|
CGPoint startTouch;
|
|
BOOL _isMoving;
|
|
BOOL _isMoving;
|
|
BOOL isExistNoNewWork;
|
|
BOOL isExistNoNewWork;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@property (nonatomic, strong) UIProgressView *progressView;
|
|
@property (nonatomic, strong) UIProgressView *progressView;
|
|
@@ -28,7 +29,7 @@
|
|
@property(nonatomic,strong)NSString *placeAdr;
|
|
@property(nonatomic,strong)NSString *placeAdr;
|
|
@property(nonatomic,strong)NSString *placeLli;
|
|
@property(nonatomic,strong)NSString *placeLli;
|
|
@property(nonatomic,assign)BOOL isLocation;
|
|
@property(nonatomic,assign)BOOL isLocation;
|
|
-
|
|
|
|
|
|
+@property(nonatomic,assign)BOOL isCanBack;
|
|
|
|
|
|
@property(nonatomic, strong)NoNetView *noNetView;
|
|
@property(nonatomic, strong)NoNetView *noNetView;
|
|
@property(nonatomic, strong)NoNetView *failNetView;
|
|
@property(nonatomic, strong)NoNetView *failNetView;
|
|
@@ -136,13 +137,19 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
@"refreshAppointTab",
|
|
@"refreshAppointTab",
|
|
@"sendMsgCount",
|
|
@"sendMsgCount",
|
|
@"downLoadFile",
|
|
@"downLoadFile",
|
|
- @"clearHistory"
|
|
|
|
-
|
|
|
|
|
|
+ @"clearHistory",
|
|
|
|
+ @"sideslipOpen",
|
|
|
|
+ @"sideslipClose",
|
|
|
|
+ @"getLogin",
|
|
|
|
+ @"checkLoginEnvAvailable",
|
|
|
|
+ @"getPhoneBind"
|
|
|
|
+
|
|
|
|
+
|
|
];
|
|
];
|
|
for (NSString*jsName in jsArr) {
|
|
for (NSString*jsName in jsArr) {
|
|
[config.userContentController addScriptMessageHandler:self name:jsName];
|
|
[config.userContentController addScriptMessageHandler:self name:jsName];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//高端的自定义配置创建WKWebView
|
|
//高端的自定义配置创建WKWebView
|
|
if (iPhoneX) {
|
|
if (iPhoneX) {
|
|
_webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) configuration:config];
|
|
_webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) configuration:config];
|
|
@@ -162,8 +169,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
}
|
|
}
|
|
|
|
|
|
-(void)webViewFirstRequest{
|
|
-(void)webViewFirstRequest{
|
|
- //去时间戳-拼接
|
|
|
|
- NSString *tmpUrl = [[NSString stringWithFormat:@"%@%@", kHost, @"jyapp/jylab/mainSearch"] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];;
|
|
|
|
|
|
+ NSString *tmpUrl = [[NSString stringWithFormat:@"%@jyapp/free/index?sign=%@&deviceid=%@", kHost,[LXUserDefaults token],[LXUserDefaults getDeviceID]] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
kMainQueue(^{
|
|
kMainQueue(^{
|
|
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:tmpUrl]]];
|
|
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:tmpUrl]]];
|
|
})
|
|
})
|
|
@@ -172,7 +178,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
#pragma mark - event response
|
|
#pragma mark - event response
|
|
// 计算wkWebView进度条
|
|
// 计算wkWebView进度条
|
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
|
-// NSLog(@"进度条加载中...");
|
|
|
|
|
|
+ // NSLog(@"进度条加载中...");
|
|
if (!self.isRuningLoad) {
|
|
if (!self.isRuningLoad) {
|
|
self.isRuningLoad = YES;
|
|
self.isRuningLoad = YES;
|
|
}
|
|
}
|
|
@@ -188,11 +194,11 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
delay:0.3f
|
|
delay:0.3f
|
|
options:UIViewAnimationOptionCurveEaseOut
|
|
options:UIViewAnimationOptionCurveEaseOut
|
|
animations:^{
|
|
animations:^{
|
|
- self.progressView.alpha = 0.0f;
|
|
|
|
- }
|
|
|
|
|
|
+ self.progressView.alpha = 0.0f;
|
|
|
|
+ }
|
|
completion:^(BOOL finished) {
|
|
completion:^(BOOL finished) {
|
|
- [self.progressView setProgress:0 animated:NO];
|
|
|
|
- }];
|
|
|
|
|
|
+ [self.progressView setProgress:0 animated:NO];
|
|
|
|
+ }];
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -206,7 +212,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openPushUrlOtherMethods:) name:OpenPushUrlOtherMethods object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openPushUrlOtherMethods:) name:OpenPushUrlOtherMethods object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openPushLinkUrlMethods:) name:OpenPushLinkUrlMethods object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openPushLinkUrlMethods:) name:OpenPushLinkUrlMethods object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jyReceiveNewsRedPoint:) name:JYReceiveNewsRedPoint object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jyReceiveNewsRedPoint:) name:JYReceiveNewsRedPoint object:nil];
|
|
-
|
|
|
|
|
|
+
|
|
//支付状态通知
|
|
//支付状态通知
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(alipayWXpayStatus:) name:AlipayWXpayStatus object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(alipayWXpayStatus:) name:AlipayWXpayStatus object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notNetReloadWebVIew:) name:NotNetReloadWebVIew object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notNetReloadWebVIew:) name:NotNetReloadWebVIew object:nil];
|
|
@@ -224,6 +230,11 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
|
|
|
|
#pragma mark – Gesture Recognizer –
|
|
#pragma mark – Gesture Recognizer –
|
|
-(void)paningGestureReceive:(UIPanGestureRecognizer *)recoginzer{
|
|
-(void)paningGestureReceive:(UIPanGestureRecognizer *)recoginzer{
|
|
|
|
+
|
|
|
|
+ if (!self.isCanBack){
|
|
|
|
+ NSLog(@"不可返回...");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
NSString *current_url = [self stringByEvaluatingJavaScriptFromString:@"document.location.href"];
|
|
NSString *current_url = [self stringByEvaluatingJavaScriptFromString:@"document.location.href"];
|
|
NSLog(@"%@",current_url);
|
|
NSLog(@"%@",current_url);
|
|
CGRect rect = self.view.bounds;
|
|
CGRect rect = self.view.bounds;
|
|
@@ -312,39 +323,37 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
}else if ([message.name isEqualToString:@"alert"]) {
|
|
}else if ([message.name isEqualToString:@"alert"]) {
|
|
[self jsAlert:message.body];
|
|
[self jsAlert:message.body];
|
|
}else if ([message.name isEqualToString:@"hiddenBottom"]) {
|
|
}else if ([message.name isEqualToString:@"hiddenBottom"]) {
|
|
-// [self jsHiddenBottom:message.body];
|
|
|
|
|
|
+ // [self jsHiddenBottom:message.body];
|
|
}else if ([message.name isEqualToString:@"checkLab"]) {
|
|
}else if ([message.name isEqualToString:@"checkLab"]) {
|
|
-// [self jsCheckLab:message.body];
|
|
|
|
|
|
+ // [self jsCheckLab:message.body];
|
|
}else if ([message.name isEqualToString:@"chooseTab"]) {
|
|
}else if ([message.name isEqualToString:@"chooseTab"]) {
|
|
-// [self jsChooseTab:message.body];
|
|
|
|
- }else if ([message.name isEqualToString:@"clearHistory"]) {
|
|
|
|
-// [self jsClearHistory:message.body];
|
|
|
|
|
|
+ // [self jsChooseTab:message.body];
|
|
}else if ([message.name isEqualToString:@"loginSuccess"]) {
|
|
}else if ([message.name isEqualToString:@"loginSuccess"]) {
|
|
[self jsLoginSuccess:message.body];
|
|
[self jsLoginSuccess:message.body];
|
|
}else if ([message.name isEqualToString:@"backUrl"]) {
|
|
}else if ([message.name isEqualToString:@"backUrl"]) {
|
|
- [self jsBackUrl:message.body];
|
|
|
|
|
|
+ // [self jsBackUrl:message.body];
|
|
}else if ([message.name isEqualToString:@"clearPushMessage"]) {
|
|
}else if ([message.name isEqualToString:@"clearPushMessage"]) {
|
|
[self jsClearPushMessage:message.body];
|
|
[self jsClearPushMessage:message.body];
|
|
}else if ([message.name isEqualToString:@"hideRedSpotOnMenu"]) {
|
|
}else if ([message.name isEqualToString:@"hideRedSpotOnMenu"]) {
|
|
-// [self jsHideRedSpotOnMenu:message.body];
|
|
|
|
|
|
+ // [self jsHideRedSpotOnMenu:message.body];
|
|
}else if ([message.name isEqualToString:@"showRedSpotOnMenu"]) {
|
|
}else if ([message.name isEqualToString:@"showRedSpotOnMenu"]) {
|
|
-// [self jsShowRedSpotOnMenu:message.body];
|
|
|
|
|
|
+ // [self jsShowRedSpotOnMenu:message.body];
|
|
}else if ([message.name isEqualToString:@"wxPay"]) {
|
|
}else if ([message.name isEqualToString:@"wxPay"]) {
|
|
[self jsWxPay:message.body];
|
|
[self jsWxPay:message.body];
|
|
}else if ([message.name isEqualToString:@"aliPay"]) {
|
|
}else if ([message.name isEqualToString:@"aliPay"]) {
|
|
[self jsAliPay:message.body];
|
|
[self jsAliPay:message.body];
|
|
}else if ([message.name isEqualToString:@"skipCameraWithParam"]) {
|
|
}else if ([message.name isEqualToString:@"skipCameraWithParam"]) {
|
|
- [self jsSkipCameraWithParam:message.body];
|
|
|
|
|
|
+ [self jsSkipCameraWithParam:message.body];
|
|
}else if ([message.name isEqualToString:@"skipAlbumWithParam"]) {
|
|
}else if ([message.name isEqualToString:@"skipAlbumWithParam"]) {
|
|
- [self jsSkipAlbumWithParam:message.body];
|
|
|
|
|
|
+ [self jsSkipAlbumWithParam:message.body];
|
|
}else if ([message.name isEqualToString:@"openActivityPage"]) {
|
|
}else if ([message.name isEqualToString:@"openActivityPage"]) {
|
|
- [self jsOpenActivityPage:message.body];
|
|
|
|
|
|
+ [self jsOpenActivityPage:message.body];
|
|
}else if ([message.name isEqualToString:@"callPhone"]) {
|
|
}else if ([message.name isEqualToString:@"callPhone"]) {
|
|
- [self jsCallPhone:message.body];
|
|
|
|
|
|
+ [self jsCallPhone:message.body];
|
|
}else if ([message.name isEqualToString:@"openOtherAppLinks"]) {
|
|
}else if ([message.name isEqualToString:@"openOtherAppLinks"]) {
|
|
- [self jsOpenOtherAppLinks:message.body];
|
|
|
|
|
|
+ [self jsOpenOtherAppLinks:message.body];
|
|
}else if ([message.name isEqualToString:@"inPurchasingVip"]) {
|
|
}else if ([message.name isEqualToString:@"inPurchasingVip"]) {
|
|
- [self jsInPurchasingVip:message.body];
|
|
|
|
|
|
+ [self jsInPurchasingVip:message.body];
|
|
}else if ([message.name isEqualToString:@"wirteRight"]) {
|
|
}else if ([message.name isEqualToString:@"wirteRight"]) {
|
|
[self jsWirteRight:message.body];
|
|
[self jsWirteRight:message.body];
|
|
}else if ([message.name isEqualToString:@"clearRight"]) {
|
|
}else if ([message.name isEqualToString:@"clearRight"]) {
|
|
@@ -352,13 +361,25 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
}else if ([message.name isEqualToString:@"savePic"]) {
|
|
}else if ([message.name isEqualToString:@"savePic"]) {
|
|
[self jsSavePic:message.body];
|
|
[self jsSavePic:message.body];
|
|
}else if ([message.name isEqualToString:@"skipAppointTab"]) {
|
|
}else if ([message.name isEqualToString:@"skipAppointTab"]) {
|
|
-// [self jsSkipAppointTab:message.body];
|
|
|
|
|
|
+ // [self jsSkipAppointTab:message.body];
|
|
}else if ([message.name isEqualToString:@"refreshAppointTab"]) {
|
|
}else if ([message.name isEqualToString:@"refreshAppointTab"]) {
|
|
-// [self jsRefreshAppointTab:message.body];
|
|
|
|
|
|
+ // [self jsRefreshAppointTab:message.body];
|
|
}else if ([message.name isEqualToString:@"sendMsgCount"]) {
|
|
}else if ([message.name isEqualToString:@"sendMsgCount"]) {
|
|
-// [self jsSendMsgCount:message.body];
|
|
|
|
|
|
+ // [self jsSendMsgCount:message.body];
|
|
}else if ([message.name isEqualToString:@"downLoadFile"]) {
|
|
}else if ([message.name isEqualToString:@"downLoadFile"]) {
|
|
[self jsDownLoadFile:message.body];
|
|
[self jsDownLoadFile:message.body];
|
|
|
|
+ }else if ([message.name isEqualToString:@"clearHistory"]) {
|
|
|
|
+ [self jsClearHistory:message.body];
|
|
|
|
+ }else if ([message.name isEqualToString:@"sideslipOpen"]) {
|
|
|
|
+ [self jsSideslipOpen:message.body];
|
|
|
|
+ }else if ([message.name isEqualToString:@"sideslipClose"]) {
|
|
|
|
+ [self jsSideslipClose:message.body];
|
|
|
|
+ }else if ([message.name isEqualToString:@"getLogin"]) {
|
|
|
|
+ [self jsGetLogin:message.body];
|
|
|
|
+ }else if ([message.name isEqualToString:@"checkLoginEnvAvailable"]) {
|
|
|
|
+ [self jsCheckLoginEnvAvailable:message.body];
|
|
|
|
+ }else if ([message.name isEqualToString:@"getPhoneBind"]) {
|
|
|
|
+ [self jsGetPhoneBind:message.body];
|
|
}else {
|
|
}else {
|
|
|
|
|
|
}
|
|
}
|
|
@@ -369,7 +390,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSError *err = nil;
|
|
NSError *err = nil;
|
|
NSData *dataFromString = [prompt dataUsingEncoding:NSUTF8StringEncoding];
|
|
NSData *dataFromString = [prompt dataUsingEncoding:NSUTF8StringEncoding];
|
|
NSDictionary *paramdict = [NSJSONSerialization JSONObjectWithData:dataFromString options:NSJSONReadingMutableContainers error:&err];
|
|
NSDictionary *paramdict = [NSJSONSerialization JSONObjectWithData:dataFromString options:NSJSONReadingMutableContainers error:&err];
|
|
-// NSLog(@"拦截prompt:%@",paramdict);
|
|
|
|
|
|
+ // NSLog(@"拦截prompt:%@",paramdict);
|
|
if (!err){
|
|
if (!err){
|
|
NSString *type = [paramdict objectForKey:@"jsName"];
|
|
NSString *type = [paramdict objectForKey:@"jsName"];
|
|
if (type && [type isEqualToString:@"getUserToken"]) {
|
|
if (type && [type isEqualToString:@"getUserToken"]) {
|
|
@@ -424,16 +445,16 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
completionHandler(@"");
|
|
completionHandler(@"");
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{
|
|
-(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{
|
|
//假如是重新打开窗口的话
|
|
//假如是重新打开窗口的话
|
|
if (!navigationAction.targetFrame.isMainFrame) {
|
|
if (!navigationAction.targetFrame.isMainFrame) {
|
|
-
|
|
|
|
|
|
+
|
|
[webView loadRequest:navigationAction.request];
|
|
[webView loadRequest:navigationAction.request];
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
return nil;
|
|
return nil;
|
|
}
|
|
}
|
|
@@ -443,7 +464,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
//如果当前页面是三级页面-
|
|
//如果当前页面是三级页面-
|
|
NSString *curUrl = [webView.URL absoluteString];
|
|
NSString *curUrl = [webView.URL absoluteString];
|
|
if (navigationAction.targetFrame==nil) {
|
|
if (navigationAction.targetFrame==nil) {
|
|
- [webView loadRequest:navigationAction.request];
|
|
|
|
|
|
+ [webView loadRequest:navigationAction.request];
|
|
}
|
|
}
|
|
if ([curUrl containsString:@"jyapp/article/content"]) {
|
|
if ([curUrl containsString:@"jyapp/article/content"]) {
|
|
//当前页面是三级页面--判断待跳转页面是否符合内置跳转
|
|
//当前页面是三级页面--判断待跳转页面是否符合内置跳转
|
|
@@ -475,7 +496,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
ctr.url = nextUrl;
|
|
ctr.url = nextUrl;
|
|
ctr.titleShow = @"公告信息";
|
|
ctr.titleShow = @"公告信息";
|
|
kMainQueue(^{
|
|
kMainQueue(^{
|
|
- [self presentViewController:ctr animated:YES completion:nil];
|
|
|
|
|
|
+ [self presentViewController:ctr animated:YES completion:nil];
|
|
});
|
|
});
|
|
// 不允许跳转-并跳转新页面
|
|
// 不允许跳转-并跳转新页面
|
|
decisionHandler(WKNavigationActionPolicyCancel);
|
|
decisionHandler(WKNavigationActionPolicyCancel);
|
|
@@ -494,7 +515,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
//通过js alert 显示一个警告面板,调用原生会走此方法。
|
|
//通过js alert 显示一个警告面板,调用原生会走此方法。
|
|
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
|
|
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
|
|
{
|
|
{
|
|
-// NSLog(@"显示一个JavaScript警告面板, message = %@",message);
|
|
|
|
|
|
+ // NSLog(@"显示一个JavaScript警告面板, message = %@",message);
|
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
[alertController addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
[alertController addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
completionHandler();
|
|
completionHandler();
|
|
@@ -504,7 +525,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
//通过 js confirm 显示一个确认面板,调用原生会走此方法。
|
|
//通过 js confirm 显示一个确认面板,调用原生会走此方法。
|
|
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
|
|
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
|
|
{
|
|
{
|
|
-// NSLog(@"运行JavaScript确认面板, message = %@", message);
|
|
|
|
|
|
+ // NSLog(@"运行JavaScript确认面板, message = %@", message);
|
|
UIAlertController *action = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertController *action = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
[action addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
[action addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
completionHandler(NO);
|
|
completionHandler(NO);
|
|
@@ -521,7 +542,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
WeakSelf;
|
|
WeakSelf;
|
|
[self->_webView evaluateJavaScript:jsName completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
[self->_webView evaluateJavaScript:jsName completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
-// NSLog(@"是否存在 result:%@,error:%@",result,error);
|
|
|
|
|
|
+ // NSLog(@"是否存在 result:%@,error:%@",result,error);
|
|
if ([result intValue]==0) {
|
|
if ([result intValue]==0) {
|
|
[weakSelf executeCallJS:jsStr];
|
|
[weakSelf executeCallJS:jsStr];
|
|
}else {
|
|
}else {
|
|
@@ -548,9 +569,8 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSLog(@"首页初始化");
|
|
NSLog(@"首页初始化");
|
|
self.placeAdr = [NSString new];
|
|
self.placeAdr = [NSString new];
|
|
self.placeLli = [NSString new];
|
|
self.placeLli = [NSString new];
|
|
|
|
+ self.isCanBack = YES;
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
-
|
|
|
|
-
|
|
|
|
[self.view addSubview:self.webView];
|
|
[self.view addSubview:self.webView];
|
|
[self.view addSubview:self.progressView];
|
|
[self.view addSubview:self.progressView];
|
|
[self webViewFirstRequest];
|
|
[self webViewFirstRequest];
|
|
@@ -560,14 +580,17 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
[self.recognizer delaysTouchesBegan];
|
|
[self.recognizer delaysTouchesBegan];
|
|
[self.view addGestureRecognizer:self.recognizer];
|
|
[self.view addGestureRecognizer:self.recognizer];
|
|
|
|
|
|
-
|
|
|
|
-//
|
|
|
|
-
|
|
|
|
//监听购买结果
|
|
//监听购买结果
|
|
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
|
|
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
|
|
|
|
|
|
|
|
+
|
|
|
|
+// UIButton *btn = [ZKControl createButtonWithFrame:CGRectMake(100, 100, 100, 100) title:@"点我点我" imageName:nil bgImageName:nil target:self method:@selector(click)];
|
|
|
|
+// [self.view addSubview:btn];
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+//-(void)click{
|
|
|
|
+// [self jsGetPhoneBind:@{}];
|
|
|
|
+//}
|
|
|
|
|
|
#pragma mark - WKNavigationDelegate
|
|
#pragma mark - WKNavigationDelegate
|
|
/* 页面加载完成 */
|
|
/* 页面加载完成 */
|
|
@@ -741,7 +764,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
}
|
|
}
|
|
// 跳转到系统设置
|
|
// 跳转到系统设置
|
|
-(void)jsOpenSystemNotification:(NSDictionary *)dict{
|
|
-(void)jsOpenSystemNotification:(NSDictionary *)dict{
|
|
- [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
|
|
|
|
+ [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
}
|
|
}
|
|
// 获取推送id
|
|
// 获取推送id
|
|
-(NSString *)jsGetPushRid:(NSDictionary *)dict{
|
|
-(NSString *)jsGetPushRid:(NSDictionary *)dict{
|
|
@@ -839,7 +862,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSString *content = [UIPasteboard generalPasteboard].string;
|
|
NSString *content = [UIPasteboard generalPasteboard].string;
|
|
[self popPasteVIew:content];
|
|
[self popPasteVIew:content];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -863,7 +886,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
NSString *jsonString = [NSString stringWithFormat:@"%@",dict[@"order"]];
|
|
NSString *jsonString = [NSString stringWithFormat:@"%@",dict[@"order"]];
|
|
-
|
|
|
|
|
|
+
|
|
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
|
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
|
NSError *err;
|
|
NSError *err;
|
|
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
|
|
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
|
|
@@ -956,7 +979,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
//拍照上传图片
|
|
//拍照上传图片
|
|
-(void)jsSkipCameraWithParam:(NSDictionary *)dict {
|
|
-(void)jsSkipCameraWithParam:(NSDictionary *)dict {
|
|
[GlobalData shareInstance].isSkipPath = [NSString stringWithFormat:@"%@",dict[@"type"]];
|
|
[GlobalData shareInstance].isSkipPath = [NSString stringWithFormat:@"%@",dict[@"type"]];
|
|
-
|
|
|
|
|
|
+
|
|
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
|
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
|
picker.delegate = self;
|
|
picker.delegate = self;
|
|
picker.allowsEditing = YES;
|
|
picker.allowsEditing = YES;
|
|
@@ -968,7 +991,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
//相册选择照片
|
|
//相册选择照片
|
|
-(void)jsSkipAlbumWithParam:(NSDictionary *)dict {
|
|
-(void)jsSkipAlbumWithParam:(NSDictionary *)dict {
|
|
[GlobalData shareInstance].isSkipPath = [NSString stringWithFormat:@"%@",dict[@"type"]];
|
|
[GlobalData shareInstance].isSkipPath = [NSString stringWithFormat:@"%@",dict[@"type"]];
|
|
-
|
|
|
|
|
|
+
|
|
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
|
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
|
picker.delegate = self;
|
|
picker.delegate = self;
|
|
picker.allowsEditing = YES;
|
|
picker.allowsEditing = YES;
|
|
@@ -982,7 +1005,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSDictionary * infoDic = @{@"url":[NSString stringWithFormat:@"%@",dict[@"url"]],
|
|
NSDictionary * infoDic = @{@"url":[NSString stringWithFormat:@"%@",dict[@"url"]],
|
|
@"rectype":[NSString stringWithFormat:@"%@",dict[@"rectype"]],
|
|
@"rectype":[NSString stringWithFormat:@"%@",dict[@"rectype"]],
|
|
@"openid":[NSString stringWithFormat:@"%@",dict[@"openid"]],
|
|
@"openid":[NSString stringWithFormat:@"%@",dict[@"openid"]],
|
|
- };
|
|
|
|
|
|
+ };
|
|
//post请求
|
|
//post请求
|
|
NSLog(@"%@",[NSString stringWithFormat:@"%@jyapp/free/message/receive",kHost]);
|
|
NSLog(@"%@",[NSString stringWithFormat:@"%@jyapp/free/message/receive",kHost]);
|
|
[[LXNetworkManager shareLXNetworkManager]postWithURLStr:[NSString stringWithFormat:@"%@jyapp/free/message/receive",kHost] parameters:infoDic progress:^(NSProgress *progress) {
|
|
[[LXNetworkManager shareLXNetworkManager]postWithURLStr:[NSString stringWithFormat:@"%@jyapp/free/message/receive",kHost] parameters:infoDic progress:^(NSProgress *progress) {
|
|
@@ -991,7 +1014,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSLog(@"responseObject=%@",responseObject);
|
|
NSLog(@"responseObject=%@",responseObject);
|
|
} failure:^(NSError *error) {
|
|
} failure:^(NSError *error) {
|
|
NSLog(@"error=%@",error);
|
|
NSLog(@"error=%@",error);
|
|
-
|
|
|
|
|
|
+
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1016,25 +1039,25 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSLog(@"appName:%@",appName);
|
|
NSLog(@"appName:%@",appName);
|
|
NSURL *url = [NSURL URLWithString:appLink];
|
|
NSURL *url = [NSURL URLWithString:appLink];
|
|
if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
|
if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
|
- if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) {
|
|
|
|
- //iOS 10.0+
|
|
|
|
- NSLog(@"iOS 10+");
|
|
|
|
- if (@available(iOS 10.0, *)) {
|
|
|
|
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
|
|
|
- if (!success) {
|
|
|
|
- [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:appName delay:2];
|
|
|
|
- }
|
|
|
|
- }];
|
|
|
|
- } else {
|
|
|
|
- // Fallback on earlier versions
|
|
|
|
- [[UIApplication sharedApplication] openURL:url];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- NSLog(@"iOS 2~10");
|
|
|
|
- //iOS 2~10
|
|
|
|
- [[UIApplication sharedApplication] openURL:url];
|
|
|
|
- }
|
|
|
|
|
|
+ if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) {
|
|
|
|
+ //iOS 10.0+
|
|
|
|
+ NSLog(@"iOS 10+");
|
|
|
|
+ if (@available(iOS 10.0, *)) {
|
|
|
|
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
|
|
|
+ if (!success) {
|
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:appName delay:2];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ // Fallback on earlier versions
|
|
|
|
+ [[UIApplication sharedApplication] openURL:url];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ NSLog(@"iOS 2~10");
|
|
|
|
+ //iOS 2~10
|
|
|
|
+ [[UIApplication sharedApplication] openURL:url];
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
//一般是没有安装
|
|
//一般是没有安装
|
|
NSLog(@"跳转下载app链接");
|
|
NSLog(@"跳转下载app链接");
|
|
@@ -1051,7 +1074,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
UIImage *saveImg = [UIImage imageWithData:data];
|
|
UIImage *saveImg = [UIImage imageWithData:data];
|
|
UIImageWriteToSavedPhotosAlbum(saveImg, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
|
|
UIImageWriteToSavedPhotosAlbum(saveImg, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
#pragma mark 系统的完成保存图片的方法
|
|
#pragma mark 系统的完成保存图片的方法
|
|
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
|
|
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
|
|
{
|
|
{
|
|
@@ -1129,7 +1152,7 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
SKPayment * payment = [SKPayment paymentWithProduct:myProduct[0]];
|
|
SKPayment * payment = [SKPayment paymentWithProduct:myProduct[0]];
|
|
[[SKPaymentQueue defaultQueue] addPayment:payment];
|
|
[[SKPaymentQueue defaultQueue] addPayment:payment];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//监听购买结果
|
|
//监听购买结果
|
|
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
|
|
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
|
|
NSLog(@"收到支付回调");
|
|
NSLog(@"收到支付回调");
|
|
@@ -1163,37 +1186,37 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
NSError *error = nil;
|
|
NSError *error = nil;
|
|
receiptData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:&error];
|
|
receiptData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:&error];
|
|
NSString *receipt = [receiptData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
|
|
NSString *receipt = [receiptData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
|
|
- if ([productIdentifier length] > 0) {
|
|
|
|
- // 向自己的服务器验证购买凭证
|
|
|
|
-
|
|
|
|
- if(self.tabBarController.selectedIndex == 0) {
|
|
|
|
- [self isExitCallToJS:[NSString stringWithFormat:@"getReceipt('%@')", receipt] withMethodName:@"getReceipt"];
|
|
|
|
- }else {
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:@"receiptData" object:nil userInfo:@{@"receipt":receipt}];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // Remove the transaction from the payment queue.
|
|
|
|
- [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
|
|
|
|
-
|
|
|
|
|
|
+ if ([productIdentifier length] > 0) {
|
|
|
|
+ // 向自己的服务器验证购买凭证
|
|
|
|
+
|
|
|
|
+ if(self.tabBarController.selectedIndex == 0) {
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getReceipt('%@')", receipt] withMethodName:@"getReceipt"];
|
|
|
|
+ }else {
|
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"receiptData" object:nil userInfo:@{@"receipt":receipt}];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Remove the transaction from the payment queue.
|
|
|
|
+ [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)failedTransaction:(SKPaymentTransaction *)transaction {
|
|
- (void)failedTransaction:(SKPaymentTransaction *)transaction {
|
|
- [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
|
- if(transaction.error.code != SKErrorPaymentCancelled) {
|
|
|
|
- NSLog(@"购买失败");
|
|
|
|
- [[LXViewControllerManager shareViewControllerManager]showHudOnlyText:@"购买失败,请重新尝试。" delay:1];
|
|
|
|
- } else {
|
|
|
|
- NSLog(@"用户取消交易");
|
|
|
|
- [[LXViewControllerManager shareViewControllerManager]showHudOnlyText:@"取消交易" delay:1];
|
|
|
|
- }
|
|
|
|
- [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
|
|
|
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
|
+ if(transaction.error.code != SKErrorPaymentCancelled) {
|
|
|
|
+ NSLog(@"购买失败");
|
|
|
|
+ [[LXViewControllerManager shareViewControllerManager]showHudOnlyText:@"购买失败,请重新尝试。" delay:1];
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"用户取消交易");
|
|
|
|
+ [[LXViewControllerManager shareViewControllerManager]showHudOnlyText:@"取消交易" delay:1];
|
|
|
|
+ }
|
|
|
|
+ [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
|
|
}
|
|
}
|
|
- (void)restoreTransaction:(SKPaymentTransaction *)transaction {
|
|
- (void)restoreTransaction:(SKPaymentTransaction *)transaction {
|
|
- // 对于已购商品,处理恢复购买的逻辑
|
|
|
|
- NSLog(@"对于已购商品,处理恢复购买的逻辑");
|
|
|
|
- [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
|
- [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
|
|
|
|
|
|
+ // 对于已购商品,处理恢复购买的逻辑
|
|
|
|
+ NSLog(@"对于已购商品,处理恢复购买的逻辑");
|
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
|
+ [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1234,6 +1257,215 @@ NSString *const new_AesKey = @"mGlAgnIBB8bx2nch";
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//清除历史返回列表
|
|
|
|
+-(void)jsClearHistory:(NSDictionary *)dict {
|
|
|
|
+ [_webView.backForwardList performSelector:NSSelectorFromString(@"_removeAllItems")];
|
|
|
|
+}
|
|
|
|
+//开启侧滑
|
|
|
|
+-(void)jsSideslipOpen:(NSDictionary *)dict {
|
|
|
|
+ self.isCanBack = YES;
|
|
|
|
+}
|
|
|
|
+//关闭侧滑
|
|
|
|
+-(void)jsSideslipClose:(NSDictionary *)dict {
|
|
|
|
+ self.isCanBack = NO;
|
|
|
|
+}
|
|
|
|
+//返回登录有效
|
|
|
|
+-(void)jsCheckLoginEnvAvailable:(NSDictionary *)dict {
|
|
|
|
+ __block BOOL support = NO;
|
|
|
|
+ __block NSString *sup = @"0";
|
|
|
|
+ [[TXCommonHandler sharedInstance] checkEnvAvailableWithAuthType:PNSAuthTypeLoginToken complete:^(NSDictionary * _Nullable resultDic) {
|
|
|
|
+ support = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
|
|
|
|
+ if (support){
|
|
|
|
+ sup = @"1";
|
|
|
|
+ }
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"checkLoginEnvAvailableCallback('%@')",sup] withMethodName:@"checkLoginEnvAvailableCallback"];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+-(void)jsGetLogin:(NSDictionary *)dict {
|
|
|
|
+ TXCustomModel *model = [[TXCustomModel alloc] init];
|
|
|
|
+ model.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
|
|
|
|
+ //导航栏配置
|
|
|
|
+ model.navColor = UIColor.whiteColor;
|
|
|
|
+ NSDictionary *attributes = @{
|
|
|
|
+ NSForegroundColorAttributeName : [UIColor whiteColor],
|
|
|
|
+ NSFontAttributeName : [UIFont systemFontOfSize:18.0]
|
|
|
|
+ };
|
|
|
|
+ model.navTitle = [[NSAttributedString alloc] initWithString:@"" attributes:attributes];
|
|
|
|
+ model.navBackImage = [UIImage imageNamed:@"arrowLeft"];
|
|
|
|
+
|
|
|
|
+ //logo配置
|
|
|
|
+ model.logoImage = [UIImage imageNamed:@"logo"];
|
|
|
|
+ model.logoFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ return CGRectMake((WIDTH-80)*0.5, 30, 80, 80);
|
|
|
|
+ };
|
|
|
|
+ model.numberColor = UIColorFromRGB(0x171826);
|
|
|
|
+ model.numberFont = [UIFont systemFontOfSize:24.0];
|
|
|
|
+ model.numberFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ frame.origin.y = 110+30;
|
|
|
|
+ return frame;
|
|
|
|
+ };
|
|
|
|
+ model.sloganFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ frame.origin.y = 150+30;
|
|
|
|
+ return frame;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ model.loginBtnText = [[NSAttributedString alloc] initWithString:@"一键登录/注册" attributes:@{NSForegroundColorAttributeName : UIColor.whiteColor,NSFontAttributeName : [UIFont systemFontOfSize:18.0]}];
|
|
|
|
+ NSArray *BtnBgImgs = [NSArray arrayWithObjects:[UIImage imageNamed:@"authbtn_nor"],[UIImage imageNamed:@"authbtn_dis"],[UIImage imageNamed:@"authbtn_nor"], nil];
|
|
|
|
+ model.loginBtnBgImgs = BtnBgImgs;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ model.changeBtnTitle = [[NSAttributedString alloc] initWithString:@"其他手机号登录/注册" attributes:@{NSForegroundColorAttributeName : UIColorFromRGB(0x2ABED1),NSFontAttributeName : [UIFont systemFontOfSize:16.0]}];
|
|
|
|
+ model.changeBtnFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ return CGRectMake(10, frame.origin.y, WIDTH - 20, 30);
|
|
|
|
+ };
|
|
|
|
+ model.preferredStatusBarStyle = UIStatusBarStyleLightContent;
|
|
|
|
+ model.privacyNavBackImage = [UIImage imageNamed:@"arrowLeft"];
|
|
|
|
+ NSArray *boxImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"unchoose"],[UIImage imageNamed:@"choose"], nil];
|
|
|
|
+ model.checkBoxImages = boxImages;
|
|
|
|
+
|
|
|
|
+ model.privacyColors = @[UIColor.blackColor, UIColorFromRGB(0x2ABED1)];
|
|
|
|
+ model.privacyAlignment = NSTextAlignmentCenter;
|
|
|
|
+ model.privacyFont = [UIFont fontWithName:@"PingFangSC-Regular" size:13.0];
|
|
|
|
+ model.privacyOperatorPreText = @"《";
|
|
|
|
+ model.privacyOperatorSufText = @"》";
|
|
|
|
+ model.privacyPreText = @"已阅读并同意";
|
|
|
|
+
|
|
|
|
+ NSString *onePrivacy = [NSString stringWithFormat:@"%@jyapp/free/staticPage/permission_rules.html",kHost];
|
|
|
|
+ NSString *twoPrivacy = [NSString stringWithFormat:@"%@/jyapp/free/staticPage/privacy_rules.html",kHost];
|
|
|
|
+ model.privacyOne = [NSArray arrayWithObjects:@"《使用协议》",onePrivacy,nil];
|
|
|
|
+ model.privacyTwo = [NSArray arrayWithObjects:@"《隐私政策》",twoPrivacy, nil];
|
|
|
|
+ [[TXCommonHandler sharedInstance] getLoginTokenWithTimeout:3.0 controller:self model:model complete:^(NSDictionary * _Nonnull resultDic) {
|
|
|
|
+// NSLog(@"一键登录结果:%@", resultDic);
|
|
|
|
+ NSString *code = [resultDic objectForKey:@"resultCode"];
|
|
|
|
+ if ([PNSCodeLoginControllerPresentSuccess isEqualToString:code]) {
|
|
|
|
+ NSLog(@"弹起授权页成功");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getLoginCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getLoginCallback"];
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickCancel isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击了授权页的返回");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getLoginCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getLoginCallback"];
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickChangeBtn isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击切换其他登录方式按钮");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getLoginCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getLoginCallback"];
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ [[TXCommonHandler sharedInstance] cancelLoginVCAnimated:YES complete:nil];
|
|
|
|
+ });
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickLoginBtn isEqualToString:code]) {
|
|
|
|
+ if ([[resultDic objectForKey:@"isChecked"] boolValue] == YES) {
|
|
|
|
+ NSLog(@"已勾选···点击登录···");
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"未勾选···点击登录···");
|
|
|
|
+ }
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickCheckBoxBtn isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击check box");
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickProtocol isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击了协议富文本");
|
|
|
|
+ } else if ([PNSCodeSuccess isEqualToString:code]) {
|
|
|
|
+ //点击登录按钮获取登录Token成功回调
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getLoginCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getLoginCallback"];
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ [[TXCommonHandler sharedInstance] cancelLoginVCAnimated:YES complete:nil];
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"获取登录Token失败");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getLoginCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getLoginCallback"];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+-(void)jsGetPhoneBind:(NSDictionary *)dict {
|
|
|
|
+ TXCustomModel *model = [[TXCustomModel alloc] init];
|
|
|
|
+ model.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
|
|
|
|
+ //导航栏配置
|
|
|
|
+ model.navColor = UIColor.whiteColor;
|
|
|
|
+ NSDictionary *attributes = @{
|
|
|
|
+ NSForegroundColorAttributeName : [UIColor blackColor],
|
|
|
|
+ NSFontAttributeName : [UIFont systemFontOfSize:18.0]
|
|
|
|
+ };
|
|
|
|
+ model.navTitle = [[NSAttributedString alloc] initWithString:@"绑定手机号" attributes:attributes];
|
|
|
|
+ model.navBackImage = [UIImage imageNamed:@"arrowLeft"];
|
|
|
|
+
|
|
|
|
+ //logo配置
|
|
|
|
+ model.logoIsHidden = YES;
|
|
|
|
+// model.logoImage = [UIImage imageNamed:@""];
|
|
|
|
+// model.logoFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+// return CGRectMake((WIDTH-80)*0.5, 30, 80, 80);
|
|
|
|
+// };
|
|
|
|
+ model.numberColor = UIColorFromRGB(0x171826);
|
|
|
|
+ model.numberFont = [UIFont systemFontOfSize:24.0];
|
|
|
|
+ model.numberFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ frame.origin.y = 110+30;
|
|
|
|
+ return frame;
|
|
|
|
+ };
|
|
|
|
+ model.sloganFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ frame.origin.y = 150+30;
|
|
|
|
+ return frame;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ model.loginBtnText = [[NSAttributedString alloc] initWithString:@"一键绑定手机号" attributes:@{NSForegroundColorAttributeName : UIColor.whiteColor,NSFontAttributeName : [UIFont systemFontOfSize:18.0]}];
|
|
|
|
+ NSArray *BtnBgImgs = [NSArray arrayWithObjects:[UIImage imageNamed:@"authbtn_nor"],[UIImage imageNamed:@"authbtn_dis"],[UIImage imageNamed:@"authbtn_nor"], nil];
|
|
|
|
+ model.loginBtnBgImgs = BtnBgImgs;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ model.changeBtnTitle = [[NSAttributedString alloc] initWithString:@"绑定其他手机号" attributes:@{NSForegroundColorAttributeName : UIColorFromRGB(0x2ABED1),NSFontAttributeName : [UIFont systemFontOfSize:16.0]}];
|
|
|
|
+ model.changeBtnFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
|
|
|
|
+ return CGRectMake(10, frame.origin.y, WIDTH - 20, 30);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ model.preferredStatusBarStyle = UIStatusBarStyleLightContent;
|
|
|
|
+ model.privacyNavBackImage = [UIImage imageNamed:@"arrowLeft"];
|
|
|
|
+ NSArray *boxImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"unchoose"],[UIImage imageNamed:@"choose"], nil];
|
|
|
|
+ model.checkBoxImages = boxImages;
|
|
|
|
+
|
|
|
|
+ model.privacyColors = @[UIColor.blackColor, UIColorFromRGB(0x2ABED1)];
|
|
|
|
+ model.privacyAlignment = NSTextAlignmentCenter;
|
|
|
|
+ model.privacyFont = [UIFont fontWithName:@"PingFangSC-Regular" size:13.0];
|
|
|
|
+ model.privacyOperatorPreText = @"《";
|
|
|
|
+ model.privacyOperatorSufText = @"》";
|
|
|
|
+ model.privacyPreText = @"已阅读并同意";
|
|
|
|
+
|
|
|
|
+ [[TXCommonHandler sharedInstance] getLoginTokenWithTimeout:3.0 controller:self model:model complete:^(NSDictionary * _Nonnull resultDic) {
|
|
|
|
+// NSLog(@"一键登录结果:%@", resultDic);
|
|
|
|
+ NSString *code = [resultDic objectForKey:@"resultCode"];
|
|
|
|
+ if ([PNSCodeLoginControllerPresentSuccess isEqualToString:code]) {
|
|
|
|
+ NSLog(@"弹起授权页成功");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getPhoneBindCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getPhoneBindCallback"];
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickCancel isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击了授权页的返回");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getPhoneBindCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getPhoneBindCallback"];
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickChangeBtn isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击切换其他登录方式按钮");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getPhoneBindCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getPhoneBindCallback"];
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ [[TXCommonHandler sharedInstance] cancelLoginVCAnimated:YES complete:nil];
|
|
|
|
+ });
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickLoginBtn isEqualToString:code]) {
|
|
|
|
+ if ([[resultDic objectForKey:@"isChecked"] boolValue] == YES) {
|
|
|
|
+ NSLog(@"已勾选···点击登录···");
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"未勾选···点击登录···");
|
|
|
|
+ }
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickCheckBoxBtn isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击check box");
|
|
|
|
+ } else if ([PNSCodeLoginControllerClickProtocol isEqualToString:code]) {
|
|
|
|
+ NSLog(@"点击了协议富文本");
|
|
|
|
+ } else if ([PNSCodeSuccess isEqualToString:code]) {
|
|
|
|
+ //点击登录按钮获取登录Token成功回调
|
|
|
|
+ NSString *token = [resultDic objectForKey:@"token"];
|
|
|
|
+ NSLog(@"成功获取Token:%@",token);
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getPhoneBindCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getPhoneBindCallback"];
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ [[TXCommonHandler sharedInstance] cancelLoginVCAnimated:YES complete:nil];
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"获取登录Token失败");
|
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getPhoneBindCallback('%@')",[self convertToJsonData:resultDic]] withMethodName:@"getPhoneBindCallback"];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
#pragma mark *****其他方法
|
|
#pragma mark *****其他方法
|