调试拉起支付

This commit is contained in:
eggmanQQQ
2024-07-09 15:02:39 +08:00
parent 3dfc5c770e
commit e57895d3e3
9 changed files with 458 additions and 301 deletions

View File

@@ -184,11 +184,6 @@
}
}
- (NSString *)cellContent:(MessageBaseModel *)model {
// MessageHeadlinesTextModel *imageModel = (MessageHeadlinesTextModel *)model;
return @"123";//[NSString stringWithFormat:@"%@", model.f];
}
#pragma mark -
- (NetImageView *)avatarView{
if(!_avatarView){

View File

@@ -48,11 +48,14 @@
NSString * ticket = [AccountInfoStorage instance].getTicket;
NSString * deviceInfo = [YYUtility deviceID];
NSString * clientIp= [YYUtility ipAddress];
@kWeakify(self);
[Api requestIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
NSString *orderId = (NSString *)data.data[@"recordId"];
NSString *uuid = (NSString *)data.data[@"appAccountToken"];
[[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId uuid:uuid];
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if(code != 50000){
[[self getView]showErrorToast:msg];
}

View File

@@ -92,6 +92,7 @@
[self createUI];
[self initHttpData];
}
- (void)createUI {
self.view.backgroundColor = UIColorFromRGB(0xF4F5FA);
@@ -145,7 +146,7 @@
[self getRechargeList];
[self.presenter getBannerList];
[self getUserWalletBalanceInfo];
[self checkTranscationIds];
[self checkTransactionIds];
}
///
@@ -211,7 +212,7 @@
[self.collectionView reloadData];
}
///
- (void)checkTranscationIds {
- (void)checkTransactionIds {
NSString * uid = [AccountInfoStorage instance].getUid;
NSArray * array = [RechargeStorage getAllReciptsWithUid:uid];
@@ -282,10 +283,10 @@
#pragma mark - XPIAPHelperDelegate
///
- (void)rechargeNewProcessStatus:(StoreConditionResult)status {
dispatch_async(dispatch_get_main_queue(), ^{
if (status == StoreConditionResultPay || status == StoreConditionResultStart || status == StoreConditionResultVerifiedServer) {
if (status == StoreConditionResultPay ||
status == StoreConditionResultStart ||
status == StoreConditionResultVerifiedServer) {
}else if (status == StoreConditionResultUnowned) {
[XNDJTDDLoadingTool hideHUDInView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
@@ -293,8 +294,7 @@
[XNDJTDDLoadingTool hideHUDInView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")];
}
});
});
}
///id
@@ -302,8 +302,7 @@
///
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
///
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
}
#pragma mark - XPMineRechargeProtocol
- (void)requestRechargeListSucccess:(NSArray *)list {
@@ -333,27 +332,16 @@
NSString *transactionId = result[@"transactionId"];
[self rechargeSuccess:transactionId];
}
break;
default:
{
}
break;
}
};
} else {
[XNDJTDDLoadingTool hideHUDInView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController10")];
}
}else{
[XNDJTDDLoadingTool hideHUDInView:kWindow];
}

View File

@@ -11,7 +11,7 @@
#import "XPHomeMineViewController.h"
#import "XPRoomSearchContainerViewController.h"
#import "FeedBackViewController.h"
#import "XPWebViewController.h"
@interface XPHomePagingViewController () <UIPageViewControllerDelegate, UIPageViewControllerDataSource>
@@ -146,10 +146,31 @@
make.height.mas_equalTo(4);
make.centerX.mas_equalTo(self.recommendButton.mas_centerX);
}];
#if DEBUG
@kWeakify(self);
UIButton *b = [UIButton buttonWithType:UIButtonTypeClose primaryAction:[UIAction actionWithHandler:^(__kindof UIAction * _Nonnull action) {
@kStrongify(self);
[self __testMethod];
}]];
[self.topControlView addSubview:b];
[b mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.mineButton);
if (isMSRTL()) {
make.left.mas_equalTo(self.topControlView).offset(16);
} else {
make.right.mas_equalTo(self.topControlView).offset(-36);
}
make.width.height.mas_equalTo(36);
}];
#endif
}
- (void)__testMethod {
FeedBackViewController *vc = [[FeedBackViewController alloc] init];
// FeedBackViewController *vc = [[FeedBackViewController alloc] init];
// [self.navigationController pushViewController:vc animated:YES];
XPWebViewController *vc = [[XPWebViewController alloc]init];
vc.url = @"http://beta.api.molistar.xyz/molistar/modules/order/index.html";//[NSURL URLWithString:];
[self.navigationController pushViewController:vc animated:YES];
}

View File

@@ -66,7 +66,6 @@
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.senderAvatarView];
[self.backImageView addSubview:self.pi_contentView];
@@ -75,13 +74,10 @@
[self.backImageView addSubview:self.circuseeBtn];
[self.backImageView addSubview:self.giftImageView];
[self.backImageView addSubview:self.countLabel];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
@@ -126,11 +122,6 @@
make.leading.mas_equalTo(self.giftImageView.mas_trailing).offset(kGetScaleWidth(2));
make.centerY.mas_equalTo(self.backImageView);
}];
}
- (void)initEvents {
@@ -141,59 +132,34 @@
UIColor * lineColor;
UIColor *bgBtnColor;
NSString * bgImageName;
switch (level) {
case BroadCastLevel_Normal:
{
lineColor = UIColorFromRGB(0x66B5FF);
bgBtnColor = UIColorFromRGB(0x283889);
bgImageName = @"pi_room_gift_broadcast_low_bg";
}
break;
case BroadCastLevel_Middle:
{
lineColor = UIColorFromRGB(0xFE9FFF);
bgBtnColor = UIColorFromRGB(0x49157D);
bgImageName = @"pi_room_gift_broadcast_middle_bg";
}
break;
case BroadCastLevel_High:
{
lineColor = UIColorFromRGB(0xFFED77);
bgBtnColor = UIColorFromRGB(0x87152D);
bgImageName = @"pi_room_gift_broadcast_high_bg";
}
break;
default:
{
lineColor = UIColorFromRGB(0x66B5FF);
bgBtnColor = UIColorFromRGB(0x283889);
bgImageName = @"pi_room_gift_broadcast_low_bg";
}
break;
}
@@ -205,6 +171,7 @@
-(void)showRoomVC{
[self didClickEnterRoom];
}
#pragma mark - Getters And Setters
- (void)setBroadcastModel:(GiftReceiveInfoModel *)broadcastModel {
_broadcastModel = broadcastModel;

View File

@@ -116,7 +116,6 @@
make.leading.mas_equalTo(self).offset(15);
make.top.trailing.mas_equalTo(self);
make.height.mas_equalTo(0);
}];
}
}

View File

@@ -62,7 +62,6 @@
[[self getView] updateRoomTopicFail:YMLocalizedString(@"XPRoomTopicPresenter0")];
}
}];
}
@end

View File

@@ -18,6 +18,10 @@
#import "XCCurrentVCStackManager.h"
#import "XPMineUserInfoViewController.h"
#import "Api+Mine.h"
#import "YuMi-swift.h"
#import "RechargeStorage.h"
///vc
#import "XPMineDressUpViewController.h"
#import "XPDressUpShopViewController.h"
@@ -89,6 +93,10 @@ typedef NS_ENUM(NSUInteger, RightNavigationPushType){
///
@property (nonatomic,assign) BOOL isCustom;
@property(nonatomic,strong) PIWebViewSavePhotoView *saveView;
///
@property (nonatomic,copy) NSString *orderId;
@end
NSString * const kJSOpenPurse = @"openPurse";
@@ -113,6 +121,8 @@ NSString * const kJSOpenChatPage = @"geToChatPage";
NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
NSString * const kJSSavePictureShare = @"savePictureShare";
NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
NSString * const kJSOpenPayment = @"openPayment";
NSString * const kJSOpenPaymentCallback = @"openPaymentCallback";
@implementation XPWebViewController
@@ -229,9 +239,6 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
}];
}
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@@ -279,7 +286,7 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
NSURL *URL = navigationAction.request.URL;
NSString *scheme = [URL scheme];
NSURLRequest *request = navigationAction.request;
NSURLRequest *request = navigationAction.request;
// Judge is whether to jump to other app.
if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) {
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL];
@@ -299,215 +306,394 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
});
}
}
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
[self.webview evaluateJavaScript:@"document.location.href" completionHandler:^(id _Nullable response, NSError * _Nullable error) {
NSLog(@"%@", response);
NSString *currentUrl = [NSString stringWithFormat:@"%@", response];
///host,便h5
- (void)userContentController:(WKUserContentController *)userContentController
didReceiveScriptMessage:(WKScriptMessage *)message {
[self.webview evaluateJavaScript:@"document.location.href"
completionHandler:^(id _Nullable response, NSError * _Nullable error) {
NSLog(@"%@", response);
NSLog(@"-- -- - -- - -%@: %@", message.name, message.body);
NSString *currentUrl = [NSString stringWithFormat:@"%@", response];
///host,便h5
BOOL condition = currentUrl != nil && [currentUrl containsString:API_HOST_URL];
#ifdef DEBUG
if (currentUrl != nil) {
#else
if (currentUrl != nil && [currentUrl containsString:API_HOST_URL]) {
condition = currentUrl != nil;
#endif
if ([message.name isEqualToString:kJSOpenSharePage]) {
if (message.body && message.body != [NSNull null]) {
NSDictionary *body;
//dic
if ([message.body isKindOfClass:[NSDictionary class]]) {
body = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
body = [message.body toJSONObject];
}
self.shareDic = body[@"data"];
[self showSharePanel];
}
} else if ([message.name isEqualToString:kJSGetUid]) {
NSString *uid = [[AccountInfoStorage instance] getUid];
NSString *js = [NSString stringWithFormat:@"getMessage(\"uid\",%@)", uid];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetTicket]) {
NSString *ticket = [[AccountInfoStorage instance] getTicket];
NSString *js = [NSString stringWithFormat:@"getMessage(\"ticket\",\"%@\")",ticket];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceId]) {
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceId\",\"%@\")",[YYUtility deviceUniqueIdentification]];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceInfo]) {
NSDictionary *basicParmars = [HttpRequestHelper configBaseParmars:[[NSDictionary alloc] init]];
NSString *json = [basicParmars mj_JSONString];
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceInfo\",%@)", json];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable ohter, NSError * _Nullable error) {
NSLog(@"%@", error);
}];
} else if ([message.name isEqualToString:kJSOpenPurse]) {
}else if([message.name isEqualToString:kJSChargePayPage]){
// NSString *money = [NSString stringWithFormat:@"%@",message.body] ;
}else if([message.name isEqualToString:kJSChargePayClickPage]){
if(message.body != nil && self.model.diamonds != nil){
// NSString *type = [NSString stringWithFormat:@"%@",message.body];
}
}else if ([message.name isEqualToString:kJSOpenChargePage]) {
if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){
[self.delegate payHandler];
return;
if(condition) {
if ([message.name isEqualToString:kJSOpenSharePage]) {
if (message.body && message.body != [NSNull null]) {
NSDictionary *body;
//dic
if ([message.body isKindOfClass:[NSDictionary class]]) {
body = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
body = [message.body toJSONObject];
}
self.shareDic = body[@"data"];
[self showSharePanel];
}
} else if ([message.name isEqualToString:kJSGetUid]) {
NSString *uid = [[AccountInfoStorage instance] getUid];
NSString *js = [NSString stringWithFormat:@"getMessage(\"uid\",%@)", uid];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetTicket]) {
NSString *ticket = [[AccountInfoStorage instance] getTicket];
NSString *js = [NSString stringWithFormat:@"getMessage(\"ticket\",\"%@\")",ticket];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceId]) {
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceId\",\"%@\")",[YYUtility deviceUniqueIdentification]];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceInfo]) {
NSDictionary *basicParmars = [HttpRequestHelper configBaseParmars:[[NSDictionary alloc] init]];
NSString *json = [basicParmars mj_JSONString];
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceInfo\",%@)", json];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable ohter, NSError * _Nullable error) {
NSLog(@"%@", error);
}];
} else if ([message.name isEqualToString:kJSOpenPurse]) {
}else if([message.name isEqualToString:kJSChargePayPage]){
// NSString *money = [NSString stringWithFormat:@"%@",message.body] ;
}else if([message.name isEqualToString:kJSChargePayClickPage]){
if(message.body != nil && self.model.diamonds != nil){
// NSString *type = [NSString stringWithFormat:@"%@",message.body];
}
}else if ([message.name isEqualToString:kJSOpenChargePage]) {
if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){
[self.delegate payHandler];
return;
}
[TTPopup dismiss];
if(self.isPush){
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
return;
}
UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC;
if (controller.presentingViewController) {
[controller dismissViewControllerAnimated:NO completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
});
}else {
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
} else if ([message.name isEqualToString:kOpenPersonPage]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.integerValue > 0) {
[TTPopup dismiss];
if(self.isPush){
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
return;
}
UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC;
if (controller.presentingViewController) {
[controller dismissViewControllerAnimated:NO completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
});
}else {
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
} else if ([message.name isEqualToString:kOpenPersonPage]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.integerValue > 0) {
[TTPopup dismiss];
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = uid.integerValue;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:userInfoVC animated:YES];
}
} else if([message.name isEqualToString:kJSInitNav]) {
[self initNav:message.body];
} else if([message.name isEqualToString:kJSGetRoomUid]) {
NSString *js = [NSString stringWithFormat:@"getMessage(\"roomUid\",\"%@\")",self.roomUid];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if([message.name isEqualToString:kInitShowNav]) {
if (((NSNumber *)message.body).intValue == 0) {
if (self.InitShowNavBlock) {
self.InitShowNavBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController setNavigationBarHidden:YES];
}
}
} else if([message.name isEqualToString:kCloseWebView]) {
if (self.CloseWebViewBlock) {
self.CloseWebViewBlock(YES);
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = uid.integerValue;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:userInfoVC animated:YES];
}
} else if([message.name isEqualToString:kJSInitNav]) {
[self initNav:message.body];
} else if([message.name isEqualToString:kJSGetRoomUid]) {
NSString *js = [NSString stringWithFormat:@"getMessage(\"roomUid\",\"%@\")",self.roomUid];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if([message.name isEqualToString:kInitShowNav]) {
if (((NSNumber *)message.body).intValue == 0) {
if (self.InitShowNavBlock) {
self.InitShowNavBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController setNavigationBarHidden:YES];
}
} else if ([message.name isEqualToString:kJumpAppointPage]) {
// h5
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];
}
NSInteger skyType = [bodyDict[@"routerType"] integerValue];
[self handleRouterType:skyType message:message];
}else if ([message.name isEqualToString:kJSOpenChatPage]){
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES];
}
}else if([message.name isEqualToString:kJSOpenAppConcernedChat]){
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
sessionVC.isAttention = YES;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES];
}
}else if ([message.name isEqualToString:kJSOpenRoom]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO];
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
[rooomVC exitRoom];
*stop = YES;
}
}];
if(self.view.superview){
[TTPopup dismiss];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
} else if([message.name isEqualToString:kJSOpenRoomForGiftId]) {
NSLog(@"%@", message.body);
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];
}
// uid
NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"uid"]];
NSString *giftId = [NSString stringWithFormat:@"%@", bodyDict[@"giftId"]];
if (uid.length) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO];
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
[rooomVC exitRoom];
*stop = YES;
}
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
}else if ([message.name isEqualToString:kJSSavePictureShare]){
NSDictionary *bodyDic;
if ([message.body isKindOfClass:[NSDictionary class]]) {
bodyDic = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
bodyDic = [message.body toJSONObject];
}
NSString *type = [NSString stringWithFormat:@"%@",bodyDic[@"type"]];
if ([type isEqualToString:@"2"]){
[self saveImageToPhotoAlbum:bodyDic];
}else if ([type isEqualToString:@"1"]){
self.savePhotoDic = bodyDic;
[self showShareSavePhote];
}
}else if([message.name isEqualToString:kJSGoToExchangeGold]){
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:incomeRecordVC animated:YES];
}
}
}];
}
} else if([message.name isEqualToString:kCloseWebView]) {
if (self.CloseWebViewBlock) {
self.CloseWebViewBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController popViewControllerAnimated:YES];
}
} else if ([message.name isEqualToString:kJumpAppointPage]) {
// h5
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];
}
NSInteger skyType = [bodyDict[@"routerType"] integerValue];
[self handleRouterType:skyType message:message];
}else if ([message.name isEqualToString:kJSOpenChatPage]){
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES];
}
}else if([message.name isEqualToString:kJSOpenAppConcernedChat]){
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
sessionVC.isAttention = YES;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES];
}
}else if ([message.name isEqualToString:kJSOpenRoom]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO];
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
[rooomVC exitRoom];
*stop = YES;
}
}];
if(self.view.superview){
[TTPopup dismiss];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
} else if([message.name isEqualToString:kJSOpenRoomForGiftId]) {
NSLog(@"%@", message.body);
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];
}
// uid
NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"uid"]];
NSString *giftId = [NSString stringWithFormat:@"%@", bodyDict[@"giftId"]];
if (uid.length) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO];
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
[rooomVC exitRoom];
*stop = YES;
}
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
}else if ([message.name isEqualToString:kJSSavePictureShare]){
NSDictionary *bodyDic;
if ([message.body isKindOfClass:[NSDictionary class]]) {
bodyDic = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
bodyDic = [message.body toJSONObject];
}
NSString *type = [NSString stringWithFormat:@"%@",bodyDic[@"type"]];
if ([type isEqualToString:@"2"]){
[self saveImageToPhotoAlbum:bodyDic];
}else if ([type isEqualToString:@"1"]){
self.savePhotoDic = bodyDic;
[self showShareSavePhote];
}
}else if([message.name isEqualToString:kJSGoToExchangeGold]){
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:incomeRecordVC animated:YES];
}else if([message.name isEqualToString:kJSOpenPayment]) {
[self handleOpenPayment:message.body];
}
}
}];
}
#pragma mark - Payment Method
- (void)handleOpenPayment:(NSString *)chargeProdId {
#if DEBUG
chargeProdId = @"com.hflighting.yumi.first.10";
#endif
if (chargeProdId.length == 0) {
[self showErrorToast:@"no charge ID"];
return;
}
[self showLoading];
@kWeakify(self);
[Api requestIAPRecharge:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
[self showErrorToast:@"苹果下单 成功"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
switch (code) {
case 200: {
NSString *orderId = (NSString *)data.data[@"recordId"];
NSString *uuid = (NSString *)data.data[@"appAccountToken"];
[self handleGetIAPRechargeSuccess:orderId
uuid:uuid
chargeProdId:chargeProdId];
}
break;
case 50000:
[self showErrorToast:msg];
break;
default:
break;
}
});
}
chargeProdId:chargeProdId
uid:[AccountInfoStorage instance].getUid
ticket:[AccountInfoStorage instance].getTicket
deviceInfo:[YYUtility deviceID]
clientIp:[YYUtility ipAddress]];
}
- (void)handleGetIAPRechargeSuccess:(NSString *)orderID
uuid:(NSString *)uuid
chargeProdId:(NSString *)chargeProdId {
if (orderID.length > 0) {
self.orderId = orderID;
if (@available(iOS 15.0, *)) {
PIIAPRegulate *iap = [PIIAPRegulate shared];
[iap demandCommodityThingWithProductId:chargeProdId
uuid:uuid
completionHandler:^(NSError * _Nullable error) {
}];
@kWeakify(self);
iap.ConditionBlock = ^(enum StoreConditionResult state, NSDictionary<NSString *,id> * _Nullable result) {
@kStrongify(self);
switch (state) {
case StoreConditionResultVerifiedServer: {
NSString *transactionId = result[@"transactionId"];
NSLog(@"-- -- - -- - - transactionId: %@, orderID: %@", transactionId, orderID);
[self rechargeSuccess:transactionId];
}
break;
case StoreConditionResultUnowned: {
dispatch_async(dispatch_get_main_queue(), ^{
[XNDJTDDLoadingTool hideHUDInView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
});
}
break;
case StoreConditionResultPay:
case StoreConditionResultStart:
break;
default: {
dispatch_async(dispatch_get_main_queue(), ^{
[XNDJTDDLoadingTool hideHUDInView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
});
}
break;
}
};
} else {
[XNDJTDDLoadingTool hideHUDInView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController10")];
}
}else{
[XNDJTDDLoadingTool hideHUDInView:kWindow];
}
}
///id
- (void)rechargeSuccess:(NSString *)transactionIdentifier {
///
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
///
@kWeakify(self);
[Api checkReceipt:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if (code == 200) {
} else {
}
}
chooseEnv:@"true"
chargeRecordId:self.orderId
transcationId:transactionIdentifier
uid:[AccountInfoStorage instance].getUid
ticket:[AccountInfoStorage instance].getTicket];
}
///
- (void)saveRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier {
NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
NSString *encodeStr = [receipt base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
if(transactionIdentifier != nil){
[dictionary setObject:transactionIdentifier forKey:@"transcationId"];
}
if(encodeStr != nil){
[dictionary setObject:encodeStr forKey:@"recipt"];
}
if(self.orderId != nil){
[dictionary setObject:self.orderId forKey:@"orderId"];
}
if(dictionary.allKeys.count == 0)return;
NSString *reciptJson = [dictionary toJSONString];
NSString * uid = [AccountInfoStorage instance].getUid;
BOOL saveSuccess = [RechargeStorage saveTranscationId:transactionIdentifier recipt:reciptJson uid:uid];
if (!saveSuccess) {
NSLog(@"保存订单失败");
}
}
///
- (void)checkReceiptSuccess:(NSString *)transcationId {
[XNDJTDDLoadingTool hideHUDInView:kWindow];
if (@available(iOS 15.0, *)) {
PIIAPRegulate *iap = [PIIAPRegulate shared];
[iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
}];
}
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
[self triggerOpenPaymentCallback:200
orderID:self.orderId
productID:transcationId];
}
///
- (void)deleteRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier {
NSString * uid = [AccountInfoStorage instance].getUid;
BOOL deleteSuccess = [RechargeStorage delegateTranscationId:transactionIdentifier
uid:uid];
if (deleteSuccess) {
NSLog(@"删除本地账单失败");
}
}
- (void)triggerOpenPaymentCallback:(NSInteger)code
orderID:(NSString *)orderID
productID:(NSString *)productID {
NSDictionary *dic = @{@"code":@(code), @"orderId":orderID, @"productId":productID};
NSString *js = [NSString stringWithFormat:@"openPaymentCallback(%@)", dic.toJSONString];
[self.webview evaluateJavaScript:js
completionHandler:^(id _Nullable result, NSError * _Nullable error) {
}];
}
#pragma mark - private method
- (void)handleRouterType:(NSInteger)skyType message:(WKScriptMessage *)message {
@@ -635,38 +821,37 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
}
- (void)showSharePanel {
if (self.shareDic.allKeys.count <= 0) {
return;
}
NSDictionary * dic = self.shareDic;
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
shareInfo.shareTitle = self.shareDic[@"title"];
shareInfo.shareContent = dic[@"desc"];
shareInfo.shareImageUrl = dic[@"imgUrl"];
shareInfo.type = ShareType_H5;
shareInfo.uid = [AccountInfoStorage instance].getUid;
NSString *urlStr = ((NSString *)dic[@"url"]).length > 0 ? dic[@"url"] : dic[@"showUrl"];
if (urlStr.length) {
if ([urlStr containsString:@"?"]) {
urlStr = [NSString stringWithFormat:@"%@&shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
} else {
urlStr = [NSString stringWithFormat:@"%@?shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
}
}
shareInfo.shareUrl = urlStr;
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"];
XPShareItem *save = [XPShareItem itemWitTag:XPShareItemTagAppSaveAlbum title:YMLocalizedString(@"PIWebViewSavePhotoView4") imageName:@"share_save_icon" disableImageName:@"share_save_icon"];
NSArray * items = @[wechat,cycle, qq,save];
CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
shareView.delegate = self;
if (self.shareDic.allKeys.count <= 0) {
return;
}
NSDictionary * dic = self.shareDic;
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
shareInfo.shareTitle = self.shareDic[@"title"];
shareInfo.shareContent = dic[@"desc"];
shareInfo.shareImageUrl = dic[@"imgUrl"];
shareInfo.type = ShareType_H5;
shareInfo.uid = [AccountInfoStorage instance].getUid;
NSString *urlStr = ((NSString *)dic[@"url"]).length > 0 ? dic[@"url"] : dic[@"showUrl"];
if (urlStr.length) {
if ([urlStr containsString:@"?"]) {
urlStr = [NSString stringWithFormat:@"%@&shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
} else {
urlStr = [NSString stringWithFormat:@"%@?shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
}
}
shareInfo.shareUrl = urlStr;
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"];
XPShareItem *save = [XPShareItem itemWitTag:XPShareItemTagAppSaveAlbum title:YMLocalizedString(@"PIWebViewSavePhotoView4") imageName:@"share_save_icon" disableImageName:@"share_save_icon"];
[TTPopup popupView:shareView style:TTPopupStyleActionSheet];
NSArray * items = @[wechat,cycle, qq,save];
CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
shareView.delegate = self;
[TTPopup popupView:shareView style:TTPopupStyleActionSheet];
}
#pragma mark - XCShareViewDelegate
@@ -856,8 +1041,10 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSSavePictureShare];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGoToExchangeGold];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenPayment];
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenPaymentCallback];
}
return _pi_userContentController;

View File

@@ -70,13 +70,11 @@ public class PIIAPRegulate: NSObject {
if let scene = await view.window?.windowScene{
try await Transaction.beginRefundRequest(for:transactionId , in: scene)
}
}catch{
print("iap error")
}
}
//
@objc public func demandCommodityThing(productId:String, uuid: String) async throws {
if(ConditionBlock != nil ){