From c5d88e0d9ed528f8daaacda7710efb402cb733c6 Mon Sep 17 00:00:00 2001 From: chenshuanglin <1273934588@qq.com> Date: Thu, 23 Mar 2023 16:18:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=94=E7=BD=97=E5=8E=9F=E7=94=9F=E6=94=AF?= =?UTF-8?q?=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios/Main/XPWebViewController.m | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/xplan-ios/Main/XPWebViewController.m b/xplan-ios/Main/XPWebViewController.m index 0af3beed..522e15e5 100644 --- a/xplan-ios/Main/XPWebViewController.m +++ b/xplan-ios/Main/XPWebViewController.m @@ -22,6 +22,7 @@ #import "XPMineNewRechargeViewController.h" #import "NSMutableDictionary+Saft.h" #import "Base64.h" +#import ///vc #import "XPMineDressUpViewController.h" #import "XPDressUpShopViewController.h" @@ -108,6 +109,7 @@ NSString * const kProhibitRightSlip = @"prohibitRightSlip"; NSString * const kSaveBase64Image = @"saveBase64Image"; NSString * const kOpenDialogWebview = @"openDialogWebview"; NSString * const kCheckResultFinish = @"checkResultFinish"; +NSString * const kOpenNativeTarotPay = @"openNativeTarotPay"; @implementation XPWebViewController @@ -402,7 +404,39 @@ NSString * const kCheckResultFinish = @"checkResultFinish"; NSString * body = message.body; ///这个为什么不能直接调用下面的的方法?收到这个刷新的方法的是当前半屏的这个webview 但是刷新的话是刷新 打开塔罗牌的那个webView [[NSNotificationCenter defaultCenter] postNotificationName:kCheckResultFinish object:body]; - } + } else if([message.name isEqualToString:kOpenNativeTarotPay]) { + NSDictionary *bodyDict; + if ([message.body isKindOfClass:[NSDictionary class]]) { + bodyDict = message.body; + } else if ([message.body isKindOfClass:[NSString class]]) { + NSString *str = (NSString *)message.body; + bodyDict = [str toJSONObject]; + } + NSLog(@"%@",bodyDict); + // 微信支付 + [WXApi registerApp:bodyDict[@"appid"] universalLink:@"https://f02efc69cbad775287063e8ee37733a5.share2dlink.com/"]; + + PayReq *req = [[PayReq alloc] init]; + NSMutableString *stamp = [bodyDict objectForKey:@"timestamp"]; + req.partnerId = [bodyDict objectForKey:@"partnerid"]; + req.prepayId = [bodyDict objectForKey:@"prepayid"]; + req.nonceStr = [bodyDict objectForKey:@"noncestr"]; + req.timeStamp = stamp.intValue; + req.package = [bodyDict objectForKey:@"package"]; + req.sign = [bodyDict objectForKey:@"sign"]; + [WXApi sendReq:req completion:^(BOOL success) { + if (success) { + NSLog(@"********调起微信支付成功"); + } + }]; + + XPEnterpriseTarotPayView *alert = [[XPEnterpriseTarotPayView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth - 37 * 2, 200)]; + alert.url = bodyDict[@"url"]; + TTPopupService * service = [[TTPopupService alloc] init]; + service.shouldDismissOnBackgroundTouch = NO; + service.contentView = alert; + [TTPopup popupWithConfig:service]; + } } }]; } @@ -747,6 +781,7 @@ NSString * const kCheckResultFinish = @"checkResultFinish"; // 卡罗牌 [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kOpenDialogWebview]; [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCheckResultFinish]; + [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kOpenNativeTarotPay]; } return _userContentController; }