From 46c9203d57a1fd76c850b00e01c1fe8ebfcbf91a Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Sat, 14 May 2022 19:26:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=8C=85=E5=8D=A1=E7=BD=97?= =?UTF-8?q?=E7=89=8C=E5=85=85=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios/Info.plist | 16 +++++++++ xplan-ios/Main/XPWebViewController.m | 50 ++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/xplan-ios/Info.plist b/xplan-ios/Info.plist index e28ba19a..591e7850 100644 --- a/xplan-ios/Info.plist +++ b/xplan-ios/Info.plist @@ -60,6 +60,22 @@ daeplayapp + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + xdx.api.lecheng163.com + + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + xdx.api.uat.lecheng163.com + + CFBundleVersion 2022111001 diff --git a/xplan-ios/Main/XPWebViewController.m b/xplan-ios/Main/XPWebViewController.m index 80020256..de556289 100644 --- a/xplan-ios/Main/XPWebViewController.m +++ b/xplan-ios/Main/XPWebViewController.m @@ -28,6 +28,13 @@ #import "XPRoomViewController.h" #import "RoomHostDelegate.h" #import "XPMonentTopicContainerViewController.h" +#import "XPRoomHalfWebView.h" + +#ifdef DEBUG +static const NSString *CompanyFirstDomainByWeChatRegister = @"api.uat.lecheng163.com"; +#else +static const NSString *CompanyFirstDomainByWeChatRegister = @"api.lecheng163.com"; +#endif typedef NS_ENUM(NSUInteger, RightNavigationPushType){ ///跳转h5页面 @@ -98,6 +105,8 @@ NSString * const kJSOpenRoom = @"openRoom"; NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId"; NSString * const kProhibitRightSlip = @"prohibitRightSlip"; NSString * const kSaveBase64Image = @"saveBase64Image"; +NSString * const kOpenDialogWebview = @"openDialogWebview"; +NSString * const kCheckResultFinish = @"checkResultFinish"; @implementation XPWebViewController @@ -161,6 +170,28 @@ NSString * const kSaveBase64Image = @"saveBase64Image"; NSURL *URL = navigationAction.request.URL; NSString *scheme = [URL scheme]; NSURLRequest *request = navigationAction.request; + + ///卡罗牌 + NSString *absoluteString = [navigationAction.request.URL.absoluteString stringByRemovingPercentEncoding]; + static NSString *endPayRedirectURL = nil; + if ([absoluteString hasPrefix:@"https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb"] && ![absoluteString hasSuffix:[NSString stringWithFormat:@"redirect_url=xdx.%@://",CompanyFirstDomainByWeChatRegister]]) { + NSString *redirectUrl = nil; + if ([absoluteString containsString:@"redirect_url="]) { + NSRange redirectRange = [absoluteString rangeOfString:@"redirect_url"]; + endPayRedirectURL = [absoluteString substringFromIndex:redirectRange.location+redirectRange.length+1]; + // stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@"?!@#$^&%*+,:;='\"`<>()[]{}/\\| "] invertedSet]] + redirectUrl = [[absoluteString substringToIndex:redirectRange.location] stringByAppendingString:[NSString stringWithFormat:@"redirect_url=xdx.%@://",CompanyFirstDomainByWeChatRegister]]; + }else { + redirectUrl = [absoluteString stringByAppendingString:[NSString stringWithFormat:@"&redirect_url=xdx.%@://",CompanyFirstDomainByWeChatRegister]]; + } + + NSMutableURLRequest *newRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:redirectUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10]; + newRequest.allHTTPHeaderFields = request.allHTTPHeaderFields; + newRequest.URL = [NSURL URLWithString:redirectUrl]; + [webView loadRequest:newRequest]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } // Judge is whether to jump to other app. if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) { BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL]; @@ -343,7 +374,6 @@ NSString * const kSaveBase64Image = @"saveBase64Image"; [XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; }); } - } else if([message.name isEqualToString:kSaveBase64Image]) { NSString * base64 = message.body; NSArray * array = [base64 componentsSeparatedByString:@","]; @@ -352,6 +382,16 @@ NSString * const kSaveBase64Image = @"saveBase64Image"; UIImage * image = [UIImage imageWithData:data]; UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), (__bridge void *)self); } + } else if([message.name isEqualToString:kOpenDialogWebview]) { + XPRoomHalfWebView *alert = [[XPRoomHalfWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth - 37 * 2, 200)]; + alert.url = message.body; + TTPopupService * service = [[TTPopupService alloc] init]; + service.shouldDismissOnBackgroundTouch = NO; + service.contentView = alert; + service.style = TTPopupStyleAlert; + [TTPopup popupWithConfig:service]; + } else if([message.name isEqualToString:kCheckResultFinish]) { + [TTPopup dismiss]; } } }]; @@ -436,7 +476,10 @@ NSString * const kSaveBase64Image = @"saveBase64Image"; // 去掉 urlString 中的空格。 NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""]; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]]; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]]; + if ([_url containsString:@"wx.tenpay"]) { + [request setValue:[NSString stringWithFormat:@"xdx.%@://", CompanyFirstDomainByWeChatRegister] forHTTPHeaderField:@"Referer"]; + } [self.webview loadRequest:request]; } @@ -683,6 +726,9 @@ NSString * const kSaveBase64Image = @"saveBase64Image"; [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kProhibitRightSlip]; ///保存图片到本地 [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kSaveBase64Image]; + // 卡罗牌 + [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kOpenDialogWebview]; + [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCheckResultFinish]; } return _userContentController; }