Commit 83cc703f authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

1.push config

2.h5 webView
parent 53ddfa42
This diff is collapsed.
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#import <UserNotifications/UserNotifications.h> #import <UserNotifications/UserNotifications.h>
#endif #endif
#import "DESTool.h"
@interface AppDelegate ()<WXApiDelegate, GeTuiSdkDelegate, UNUserNotificationCenterDelegate> @interface AppDelegate ()<WXApiDelegate, GeTuiSdkDelegate, UNUserNotificationCenterDelegate>
@end @end
...@@ -52,7 +54,7 @@ ...@@ -52,7 +54,7 @@
BuglyConfig * config = [[BuglyConfig alloc] init]; BuglyConfig * config = [[BuglyConfig alloc] init];
config.blockMonitorEnable = YES; config.blockMonitorEnable = YES;
config.blockMonitorTimeout = 1; config.blockMonitorTimeout = 1;
[Bugly startWithAppId:@"560c1b40a9" config:config]; [Bugly startWithAppId:@"3339c2079b" config:config];
Data * data = [[Data alloc]init]; Data * data = [[Data alloc]init];
[data InitPlist]; [data InitPlist];
......
...@@ -21,9 +21,8 @@ ...@@ -21,9 +21,8 @@
@property (nonatomic, copy) NSString * tradeNo; @property (nonatomic, copy) NSString * tradeNo;
@property (nonatomic, copy) void (^goodsResultCallback)(id); @property (nonatomic, copy) void (^goodsResultCallback)(id);
@property (nonatomic, copy) NSString * schemes; @property (nonatomic, copy) NSString * schemes;
//@property (nonatomic, copy) void (^orderVerifyCallback)(id);
// @property (nonatomic, copy) NSString * goodsInfo;
//@property (nonatomic, copy) NSString * orderVerifyResult;
- (void)isLoadGoodsUrl; - (void)isLoadGoodsUrl;
......
...@@ -82,9 +82,9 @@ ...@@ -82,9 +82,9 @@
_requestW = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:_url]]; _requestW = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:_url]];
if (_payInfo) { // if (_payInfo) {
[_requestW addValue:_schemes forHTTPHeaderField:@"Referer"]; // [_requestW addValue:_schemes forHTTPHeaderField:@"Referer"];
} // }
[self.webView loadRequest:_requestW]; [self.webView loadRequest:_requestW];
} }
...@@ -126,14 +126,27 @@ ...@@ -126,14 +126,27 @@
if (_payInfo){ if (_payInfo){
NSString * jsonStr = [NSString stringWithFormat:@"{\"agree\":\"%@\",\"payUrl\":\"%@\",\"price\":\"%@\",\"serviceUrl\":\"%@\",\"hintStyle\":\"%@\",\"hintStyleDes\":\"%@\"}", [_payInfo objectForKey:@"agree"], [_payInfo objectForKey:@"payUrl"], [_payInfo objectForKey:@"price"], [_payInfo objectForKey:@"serviceUrl"], [_payInfo objectForKey:@"hintStyle"], [_payInfo objectForKey:@"hintStyleDes"]]; NSDictionary * switchDic = [[self.data Read] objectForKey:@"switch"];
NSString * jsonStr;
if ([[switchDic objectForKey:@"isLadderPay"] isEqual:@1]) {
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:_payInfo
options:0
error:&error];
jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}else{
jsonStr = [NSString stringWithFormat:@"{\"agree\":\"%@\",\"payUrl\":\"%@\",\"price\":\"%@\",\"serviceUrl\":\"%@\",\"hintStyle\":\"%@\",\"hintStyleDes\":\"%@\"}", [_payInfo objectForKey:@"agree"], [_payInfo objectForKey:@"payUrl"], [_payInfo objectForKey:@"price"], [_payInfo objectForKey:@"serviceUrl"], [_payInfo objectForKey:@"hintStyle"], [_payInfo objectForKey:@"hintStyleDes"]];
}
NSString *inputValueJS = [NSString stringWithFormat:@"getPayJson('%@')", jsonStr]; NSString *inputValueJS = [NSString stringWithFormat:@"getPayJson('%@')", jsonStr];
[webView evaluateJavaScript:inputValueJS completionHandler:^(id _Nullable response, NSError * _Nullable error) { [webView evaluateJavaScript:inputValueJS completionHandler:^(id _Nullable response, NSError * _Nullable error) {
//打印如果error为null,表示已调通 //打印如果error为null,表示已调通
NSLog(@"value: %@ error: %@", response, error); NSLog(@"value: %@ error: %@", response, error);
}]; }];
} }
} }
...@@ -209,7 +222,12 @@ ...@@ -209,7 +222,12 @@
if([message.name isEqualToString:@"OCJSBridge"]){ if([message.name isEqualToString:@"OCJSBridge"]){
[self share]; [self share];
}else if ([message.name isEqualToString:@"payResultCallBack"]){ }else if ([message.name isEqualToString:@"payResultCallBack"]){
[self orderVerify]; NSDictionary * switchDic = [[self.data Read] objectForKey:@"switch"];
if ([[switchDic objectForKey:@"isLadderPay"] isEqual:@1]) {
[self orderVerify:message.body];
}else{
[self orderVerify:nil];
}
}else if ([message.name isEqualToString:@"protocolSelectedResultCallBack"]){ }else if ([message.name isEqualToString:@"protocolSelectedResultCallBack"]){
NSString * result = message.body; NSString * result = message.body;
[_payInfo setValue:result forKey:@"agree"]; [_payInfo setValue:result forKey:@"agree"];
...@@ -327,10 +345,14 @@ ...@@ -327,10 +345,14 @@
} }
#pragma mark 校验 #pragma mark 校验
- (void)orderVerify{ - (void)orderVerify:(NSString *)tradeNo{
if (!tradeNo) {
tradeNo = self.tradeNo;
}
[MBProgressHUD showLoading:@"正在查询结果..." toView:self.view]; [MBProgressHUD showLoading:@"正在查询结果..." toView:self.view];
[[TQNetworkTools shared] getWithAction:userPayOrder parameters:@{@"outTradeNo":self.tradeNo, @"payPlatform":@"1", @"payType":@"2"} success:^(id _Nonnull response) { [[TQNetworkTools shared] getWithAction:userPayOrder parameters:@{@"outTradeNo":tradeNo, @"payPlatform":@"1", @"payType":@"2"} success:^(id _Nonnull response) {
NSLog(@"response=========%@",response); NSLog(@"response=========%@",response);
[MBProgressHUD hideHUDForView:self.view]; [MBProgressHUD hideHUDForView:self.view];
if ([[response objectForKey:@"status"] intValue] == 200 && [[[[response objectForKey:@"result"] objectForKey:@"data"] objectForKey:@"status"] intValue] == 200) { if ([[response objectForKey:@"status"] intValue] == 200 && [[[[response objectForKey:@"result"] objectForKey:@"data"] objectForKey:@"status"] intValue] == 200) {
......
...@@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic ,strong) NSString *productId; @property (nonatomic ,strong) NSString *productId;
@property (nonatomic ,strong) NSString *redBgStr; @property (nonatomic ,strong) NSString *redBgStr;
@property (nonatomic ,strong) NSString *voucher; @property (nonatomic ,strong) NSString *voucher;
@property (nonatomic ,strong) NSString *desc;
@property (nonatomic ,strong) NSString *originalPrice;
+(instancetype)modelWithDic:(NSDictionary *)dict; +(instancetype)modelWithDic:(NSDictionary *)dict;
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
@property (nonatomic, strong) NSMutableArray * products; @property (nonatomic, strong) NSMutableArray * products;
@property (nonatomic, strong) NSMutableArray * goodsInfo;
@property (nonatomic, assign) NSInteger goodsCount; @property (nonatomic, assign) NSInteger goodsCount;
@property (nonatomic, assign) NSInteger tradeNoCount; @property (nonatomic, assign) NSInteger tradeNoCount;
...@@ -98,7 +100,14 @@ static ZJGoodsMagager * manager; ...@@ -98,7 +100,14 @@ static ZJGoodsMagager * manager;
_callBack = callBack; _callBack = callBack;
_currentVC = currentVC; _currentVC = currentVC;
if ([self.products firstObject]) { if ([self.products firstObject]) {
[self getUrl:[self.products firstObject]];
NSDictionary * switchDic = [[self.data Read] objectForKey:@"switch"];
if ([[switchDic objectForKey:@"isLadderPay"] isEqual:@1]) {
[self getUrl:0];
}else{
[self getUrl:[self.products firstObject]];
}
}else{ }else{
[self getGoods]; [self getGoods];
} }
...@@ -115,6 +124,11 @@ static ZJGoodsMagager * manager; ...@@ -115,6 +124,11 @@ static ZJGoodsMagager * manager;
{ {
NSArray *goodList = response[@"result"][@"data"][@"goodsList"]; NSArray *goodList = response[@"result"][@"data"][@"goodsList"];
self.goodsInfo = [[NSMutableArray alloc] initWithCapacity:goodList.count];
for (int count = 0; count<goodList.count; count++) {
[self.goodsInfo addObject:[NSNull null]];
}
self.products = [[NSMutableArray alloc] init]; self.products = [[NSMutableArray alloc] init];
for (NSDictionary *good in goodList) { for (NSDictionary *good in goodList) {
ZJIPAProductModel *model = [ZJIPAProductModel modelWithDic:good]; ZJIPAProductModel *model = [ZJIPAProductModel modelWithDic:good];
...@@ -123,7 +137,13 @@ static ZJGoodsMagager * manager; ...@@ -123,7 +137,13 @@ static ZJGoodsMagager * manager;
} }
} }
if ([self.products firstObject]) { if ([self.products firstObject]) {
[self getUrl:[self.products firstObject]]; NSDictionary * switchDic = [[self.data Read] objectForKey:@"switch"];
if ([[switchDic objectForKey:@"isLadderPay"] isEqual:@1]) {
[self getUrl_new:0];
}else{
[self getUrl:[self.products firstObject]];
}
} }
} }
} failure:^(NSError * _Nonnull error) { } failure:^(NSError * _Nonnull error) {
...@@ -168,6 +188,59 @@ static ZJGoodsMagager * manager; ...@@ -168,6 +188,59 @@ static ZJGoodsMagager * manager;
}]; }];
} }
- (void)getUrl_new:(NSInteger)index{
ZJIPAProductModel *model = self.products[index];
[MBProgressHUD showLoading:@"请稍后..." toView:_currentVC.view];
[[TQNetworkTools shared] postWithAction:userPay parameters:@{@"payPlatform":@"1", @"goodsId":[NSString stringWithFormat:@"%ld", (long)model.goodsId], @"payType":@"2", @"wxType":@"H5"} success:^(id _Nonnull response) {
[MBProgressHUD hideHUDForView:self.currentVC.view];
if ([response[@"status"] integerValue] == 200 && ![[[response objectForKey:@"result"] objectForKey:@"data"] isKindOfClass:[NSNull class]]) {
// [self webGoods:response good:model tradeNo:response[@"result"][@"data"][@"wakeup"][@"extData"]];
NSDictionary * dic = [ZJUserInfoManager shared].h5_url;
NSString * string = [NSString stringWithFormat:@"%@&redirect_url=%@", [[[response[@"result"] objectForKey:@"data"]objectForKey:@"wakeup"] objectForKey:@"mwebUrl"], [dic objectForKey:@"WXbackUrl"]];
// NSDictionary * goodDic = @{@"payUrl":string,@"price":[NSString stringWithFormat:@"%.2f", (float)model.fen/100],@"desc":model.desc,@"name":model.name,@"originalPrice":[NSString stringWithFormat:@"%.2f", [model.originalPrice floatValue]],@"tradeNo":response[@"result"][@"data"][@"wakeup"][@"extData"],@"id":[NSString stringWithFormat:@"%ld", (long)index]};
NSDictionary * goodDic = @{@"payUrl":string,@"price":@(model.fen/100),@"desc":model.desc,@"name":model.name,@"originalPrice":@([model.originalPrice floatValue]),@"tradeNo":[NSString stringWithFormat:@"%@", response[@"result"][@"data"][@"wakeup"][@"extData"]],@"id":[NSString stringWithFormat:@"%ld", (long)index]};
[self.goodsInfo replaceObjectAtIndex:index withObject:goodDic];
if (index<self.products.count-1) {
[self getUrl_new:index+1];
}else{
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.goodsInfo
options:0
error:&error];
NSString * jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[self webGoods_new:jsonStr];
}
}else{
if (self.tradeNoCount < 3) {
[self getUrl_new:index];
self.tradeNoCount++;
NSError * error = [NSError errorWithDomain:NSCocoaErrorDomain code:998 userInfo:nil];
[Bugly reportError:error];
}
}
} failure:^(NSError * _Nonnull error) {
[MBProgressHUD hideHUDForView:self.currentVC.view];
// [MBProgressHUD showError:@"商品信息获取失败,请稍后再试" toView:self.currentVC.view];
if (self.tradeNoCount < 3) {
[self getUrl_new:index];
self.tradeNoCount++;
NSError * error = [NSError errorWithDomain:NSCocoaErrorDomain code:999 userInfo:nil];
[Bugly reportError:error];
}
}];
}
- (void)webGoods:(id)response good:(ZJIPAProductModel *)model tradeNo:(NSString *)tradeNo{ - (void)webGoods:(id)response good:(ZJIPAProductModel *)model tradeNo:(NSString *)tradeNo{
NSDictionary * dic = [ZJUserInfoManager shared].h5_url; NSDictionary * dic = [ZJUserInfoManager shared].h5_url;
...@@ -195,6 +268,42 @@ static ZJGoodsMagager * manager; ...@@ -195,6 +268,42 @@ static ZJGoodsMagager * manager;
[weakSelf.web.navigationController popViewControllerAnimated:YES]; [weakSelf.web.navigationController popViewControllerAnimated:YES];
}; };
[[NSNotificationCenter defaultCenter] addObserver:_web selector:@selector(isLoadGoodsUrl) name:@"loadingGoodsUrl" object:nil];
}
- (void)webGoods_new:(id)response{
NSDictionary * dic = [ZJUserInfoManager shared].h5_url;
NSDictionary * switchDic = [[self.data Read] objectForKey:@"switch"];
NSString * serviceUrl = [dic objectForKey:@"pay"] ? : @"";
NSString * userUrl = [dic objectForKey:@"user"] ? : @"";
NSString * privacyUrl = [dic objectForKey:@"privacy"] ? : @"";
NSString * agree = [switchDic objectForKey:@"wd_agreement_selected"] ? : @"";
NSString * hintStyle = [[self.data Read] objectForKey:@"hintStyle"]?:@"99";
NSString * hintStyleDes = [[self.data Read] objectForKey:@"hintStyleDes"]?:@"";
_web = [[BaseWebViewController alloc] init];
_web.url = [dic objectForKey:@"appPayUrl"];
if ([[switchDic objectForKey:@"isLadderPay"] isEqual:@1]) {
_web.url = [dic objectForKey:@"LadderPayUrl"];
}else{
_web.url = [dic objectForKey:@"appPayUrl"];
}
_web.payInfo = @{@"goodsInfo":self.goodsInfo,@"serviceUrl":serviceUrl,@"userUrl":userUrl,@"privacyUrl":privacyUrl,@"agree":agree,@"hintStyle":hintStyle,@"hintStyleDes":hintStyleDes}.mutableCopy;
_web.schemes = [dic objectForKey:@"WXbackUrl"];
[_currentVC.navigationController pushViewController:_web animated:YES];
__weak typeof(self) weakSelf = self;
_web.goodsResultCallback = ^(id s) {
if (weakSelf.callBack) {
weakSelf.callBack(@"");
};
[weakSelf.web.navigationController popViewControllerAnimated:YES];
};
[[NSNotificationCenter defaultCenter] addObserver:_web selector:@selector(isLoadGoodsUrl) name:@"loadingGoodsUrl" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:_web selector:@selector(isLoadGoodsUrl) name:@"loadingGoodsUrl" object:nil];
} }
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
#define desT @"eJPB1HATUNI756zWUOPE+dPczxzN3HWa9DATylzXdO7FKBXnJsm8NFBd30+x6upr1wEJYuMyb3Q=" #define desT @"eJPB1HATUNI756zWUOPE+dPczxzN3HWa9DATylzXdO7FKBXnJsm8NFBd30+x6upr1wEJYuMyb3Q="
/// 个推开发者网站中申请App时,注册的AppId、AppKey、AppSecret /// 个推开发者网站中申请App时,注册的AppId、AppKey、AppSecret
#define kGtAppId @"DOXzblsxdbAPrxvxJFH5a1" #define kGtAppId @"HHjxMZXxdv7ohGYzfVeEN2"
#define kGtAppKey @"6bKiKrGtnv5gm313HrSxo1" #define kGtAppKey @"zvCOWs6vF1A4pUqCmO4Ou7"
#define kGtAppSecret @"cXsoWq3JKZ6ouW3dbsuXeA" #define kGtAppSecret @"pTQjZWnVT08vyYCtMZXgP2"
//#if DEBUG //#if DEBUG
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment