|
@@ -11,7 +11,7 @@
|
|
|
#import "JYTabBarController.h"
|
|
|
#import <CoreLocation/CoreLocation.h>
|
|
|
|
|
|
-@interface JYNewSubViewController ()<WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler,CLLocationManagerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
|
|
|
+@interface JYNewSubViewController ()<WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler,CLLocationManagerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,SKProductsRequestDelegate>
|
|
|
{
|
|
|
CGPoint startTouch;
|
|
|
BOOL _isMoving;
|
|
@@ -172,6 +172,8 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
//接收全新通知
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshNonCurVC:) name:RefreshNonCurVC object:nil];
|
|
|
|
|
|
+ //监听购买结果
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiptData:) name:@"receiptData" object:nil];
|
|
|
}
|
|
|
|
|
|
#pragma mark – Gesture Recognizer –
|
|
@@ -278,6 +280,10 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
[self jsSkipAlbum:message.body];
|
|
|
}else if ([message.name isEqualToString:@"openActivityPage"]) {
|
|
|
[self jsOpenActivityPage:message.body];
|
|
|
+ }else if ([message.name isEqualToString:@"callPhone"]) {
|
|
|
+ [self jsCallPhone:message.body];
|
|
|
+ }else if ([message.name isEqualToString:@"inPurchasingVip"]) {
|
|
|
+ [self jsInPurchasingVip:message.body];
|
|
|
}else {
|
|
|
|
|
|
}
|
|
@@ -367,7 +373,7 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
}];
|
|
|
}
|
|
|
-(void)executeCallJS:(NSString *)jsStr {
|
|
|
- NSLog(@"OC调JS交互%@:",jsStr);
|
|
|
+// NSLog(@"OC调JS交互%@:",jsStr);
|
|
|
[_webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
|
|
|
if (error!=nil) {
|
|
|
NSLog(@"result:%@,error:%@",result,error);
|
|
@@ -397,6 +403,9 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
|
|
|
//监听底部栏
|
|
|
[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(bottomTwoListening) userInfo:nil repeats:YES];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
-(void)bottomTwoListening {
|
|
|
if(self.tabBarController.selectedIndex == 1) {
|
|
@@ -807,12 +816,64 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
|
|
|
}
|
|
|
|
|
|
+//拨打电话
|
|
|
+-(void)jsCallPhone:(NSDictionary *)dict {
|
|
|
+ NSString *phone = [NSString stringWithFormat:@"%@",dict[@"phone"]];
|
|
|
+ NSMutableString *tel = [[NSMutableString alloc]initWithFormat:@"telprompt://%@",phone];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:tel]];
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+//内购VIP
|
|
|
+-(void)jsInPurchasingVip:(NSDictionary *)dict {
|
|
|
+ NSString *productid = [NSString stringWithFormat:@"%@",dict[@"productid"]];
|
|
|
+ //产品id
|
|
|
+ if ([productid isEqualToString:@""]) {
|
|
|
+ NSLog(@"订单号 有问题");
|
|
|
+ [[LXDataBaseManager shareDataBaseManager]showHudOnlyText:@"订单号异常,请重试" delay:1];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [[LXViewControllerManager shareViewControllerManager] showHudText:@"苹果支付中"];
|
|
|
+ if([SKPaymentQueue canMakePayments]){
|
|
|
+ [self requestProductData:productid];
|
|
|
+ }else{
|
|
|
+ [[LXViewControllerManager shareViewControllerManager]showHudOnlyText:@"不允许程序内付费" delay:1];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//去苹果服务器请求商品
|
|
|
+- (void)requestProductData:(NSString *)type {
|
|
|
+ NSArray *product = [[NSArray alloc] initWithObjects:type,nil];
|
|
|
+ NSSet *nsset = [NSSet setWithArray:product];
|
|
|
+ SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:nsset];
|
|
|
+ request.delegate = self;
|
|
|
+ [request start];
|
|
|
+}
|
|
|
+- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
|
|
|
+ NSArray *myProduct = response.products;
|
|
|
+ if (myProduct.count == 0) {
|
|
|
+ NSLog(@"无法获取产品信息,购买失败。");
|
|
|
+ [[LXViewControllerManager shareViewControllerManager]showHudOnlyText:@"无法获取产品信息,购买失败。" delay:1];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SKPayment * payment = [SKPayment paymentWithProduct:myProduct[0]];
|
|
|
+ [[SKPaymentQueue defaultQueue] addPayment:payment];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// web是否可退回上页面
|
|
|
-(int)jsIsCanBack:(NSString *)str{
|
|
|
return self.webView.canGoBack ? 1:0;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
#pragma mark *****其他方法
|
|
|
-(void)judgeIsHiddenBottom {
|
|
|
if(self.tabBarController.selectedIndex == 1) {
|
|
@@ -911,7 +972,6 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
if (iPhoneX) {
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
self.webView.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
|
|
|
- NSLog(@"%@",self.webView)
|
|
|
}
|
|
|
}else {
|
|
|
self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT+STATUS_BAR_HEIGHT);
|
|
@@ -1231,6 +1291,18 @@ NSString *const new_AesKey_2 = @"mGlAgnIBB8bx2nch";
|
|
|
|
|
|
|
|
|
|
|
|
+//内购相关
|
|
|
+-(void)receiptData:(NSNotification *)notificaition{
|
|
|
+ if(self.tabBarController.selectedIndex == 1) {
|
|
|
+ NSDictionary *infoDict = notificaition.userInfo;
|
|
|
+ if (infoDict) {
|
|
|
+ NSString *receipt = [NSString stringWithFormat:@"%@", infoDict[@"receipt"]];
|
|
|
+ [self isExitCallToJS:[NSString stringWithFormat:@"getReceipt('%@')", receipt] withMethodName:@"getReceipt"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-(void)clearWeb{
|
|
|
NSURLCache * cache = [NSURLCache sharedURLCache];
|