调试拉起支付
This commit is contained in:
@@ -184,11 +184,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)cellContent:(MessageBaseModel *)model {
|
|
||||||
// MessageHeadlinesTextModel *imageModel = (MessageHeadlinesTextModel *)model;
|
|
||||||
return @"123";//[NSString stringWithFormat:@"%@", model.f];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - 懒加载
|
#pragma mark - 懒加载
|
||||||
- (NetImageView *)avatarView{
|
- (NetImageView *)avatarView{
|
||||||
if(!_avatarView){
|
if(!_avatarView){
|
||||||
|
@@ -48,11 +48,14 @@
|
|||||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||||
NSString * deviceInfo = [YYUtility deviceID];
|
NSString * deviceInfo = [YYUtility deviceID];
|
||||||
NSString * clientIp= [YYUtility ipAddress];
|
NSString * clientIp= [YYUtility ipAddress];
|
||||||
|
@kWeakify(self);
|
||||||
[Api requestIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
[Api requestIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||||
|
@kStrongify(self);
|
||||||
NSString *orderId = (NSString *)data.data[@"recordId"];
|
NSString *orderId = (NSString *)data.data[@"recordId"];
|
||||||
NSString *uuid = (NSString *)data.data[@"appAccountToken"];
|
NSString *uuid = (NSString *)data.data[@"appAccountToken"];
|
||||||
[[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId uuid:uuid];
|
[[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId uuid:uuid];
|
||||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||||
|
@kStrongify(self);
|
||||||
if(code != 50000){
|
if(code != 50000){
|
||||||
[[self getView]showErrorToast:msg];
|
[[self getView]showErrorToast:msg];
|
||||||
}
|
}
|
||||||
|
@@ -92,6 +92,7 @@
|
|||||||
[self createUI];
|
[self createUI];
|
||||||
[self initHttpData];
|
[self initHttpData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)createUI {
|
- (void)createUI {
|
||||||
self.view.backgroundColor = UIColorFromRGB(0xF4F5FA);
|
self.view.backgroundColor = UIColorFromRGB(0xF4F5FA);
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@
|
|||||||
[self getRechargeList];
|
[self getRechargeList];
|
||||||
[self.presenter getBannerList];
|
[self.presenter getBannerList];
|
||||||
[self getUserWalletBalanceInfo];
|
[self getUserWalletBalanceInfo];
|
||||||
[self checkTranscationIds];
|
[self checkTransactionIds];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 返回
|
/// 返回
|
||||||
@@ -211,7 +212,7 @@
|
|||||||
[self.collectionView reloadData];
|
[self.collectionView reloadData];
|
||||||
}
|
}
|
||||||
///批量验证
|
///批量验证
|
||||||
- (void)checkTranscationIds {
|
- (void)checkTransactionIds {
|
||||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||||
NSArray * array = [RechargeStorage getAllReciptsWithUid:uid];
|
NSArray * array = [RechargeStorage getAllReciptsWithUid:uid];
|
||||||
|
|
||||||
@@ -282,10 +283,10 @@
|
|||||||
#pragma mark - XPIAPHelperDelegate
|
#pragma mark - XPIAPHelperDelegate
|
||||||
///当前充值的状态
|
///当前充值的状态
|
||||||
- (void)rechargeNewProcessStatus:(StoreConditionResult)status {
|
- (void)rechargeNewProcessStatus:(StoreConditionResult)status {
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (status == StoreConditionResultPay || status == StoreConditionResultStart || status == StoreConditionResultVerifiedServer) {
|
if (status == StoreConditionResultPay ||
|
||||||
|
status == StoreConditionResultStart ||
|
||||||
|
status == StoreConditionResultVerifiedServer) {
|
||||||
}else if (status == StoreConditionResultUnowned) {
|
}else if (status == StoreConditionResultUnowned) {
|
||||||
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
||||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
|
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
|
||||||
@@ -293,8 +294,7 @@
|
|||||||
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
||||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")];
|
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///充值成功回调id
|
///充值成功回调id
|
||||||
@@ -302,8 +302,7 @@
|
|||||||
///保存唯一凭证
|
///保存唯一凭证
|
||||||
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
|
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
|
||||||
///二次验证
|
///二次验证
|
||||||
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
|
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
#pragma mark - XPMineRechargeProtocol
|
#pragma mark - XPMineRechargeProtocol
|
||||||
- (void)requestRechargeListSucccess:(NSArray *)list {
|
- (void)requestRechargeListSucccess:(NSArray *)list {
|
||||||
@@ -333,27 +332,16 @@
|
|||||||
NSString *transactionId = result[@"transactionId"];
|
NSString *transactionId = result[@"transactionId"];
|
||||||
|
|
||||||
[self rechargeSuccess:transactionId];
|
[self rechargeSuccess:transactionId];
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
||||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController10")];
|
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController10")];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
[XNDJTDDLoadingTool hideHUDInView:kWindow];
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#import "XPHomeMineViewController.h"
|
#import "XPHomeMineViewController.h"
|
||||||
#import "XPRoomSearchContainerViewController.h"
|
#import "XPRoomSearchContainerViewController.h"
|
||||||
|
|
||||||
#import "FeedBackViewController.h"
|
#import "XPWebViewController.h"
|
||||||
|
|
||||||
@interface XPHomePagingViewController () <UIPageViewControllerDelegate, UIPageViewControllerDataSource>
|
@interface XPHomePagingViewController () <UIPageViewControllerDelegate, UIPageViewControllerDataSource>
|
||||||
|
|
||||||
@@ -146,10 +146,31 @@
|
|||||||
make.height.mas_equalTo(4);
|
make.height.mas_equalTo(4);
|
||||||
make.centerX.mas_equalTo(self.recommendButton.mas_centerX);
|
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 {
|
- (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];
|
[self.navigationController pushViewController:vc animated:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,7 +66,6 @@
|
|||||||
#pragma mark - Private Method
|
#pragma mark - Private Method
|
||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
[self addSubview:self.backImageView];
|
[self addSubview:self.backImageView];
|
||||||
|
|
||||||
|
|
||||||
[self.backImageView addSubview:self.senderAvatarView];
|
[self.backImageView addSubview:self.senderAvatarView];
|
||||||
[self.backImageView addSubview:self.pi_contentView];
|
[self.backImageView addSubview:self.pi_contentView];
|
||||||
@@ -75,13 +74,10 @@
|
|||||||
[self.backImageView addSubview:self.circuseeBtn];
|
[self.backImageView addSubview:self.circuseeBtn];
|
||||||
[self.backImageView addSubview:self.giftImageView];
|
[self.backImageView addSubview:self.giftImageView];
|
||||||
[self.backImageView addSubview:self.countLabel];
|
[self.backImageView addSubview:self.countLabel];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initSubViewConstraints {
|
- (void)initSubViewConstraints {
|
||||||
|
|
||||||
|
|
||||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.edges.equalTo(self);
|
make.edges.equalTo(self);
|
||||||
}];
|
}];
|
||||||
@@ -126,11 +122,6 @@
|
|||||||
make.leading.mas_equalTo(self.giftImageView.mas_trailing).offset(kGetScaleWidth(2));
|
make.leading.mas_equalTo(self.giftImageView.mas_trailing).offset(kGetScaleWidth(2));
|
||||||
make.centerY.mas_equalTo(self.backImageView);
|
make.centerY.mas_equalTo(self.backImageView);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initEvents {
|
- (void)initEvents {
|
||||||
@@ -141,59 +132,34 @@
|
|||||||
UIColor * lineColor;
|
UIColor * lineColor;
|
||||||
UIColor *bgBtnColor;
|
UIColor *bgBtnColor;
|
||||||
NSString * bgImageName;
|
NSString * bgImageName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case BroadCastLevel_Normal:
|
case BroadCastLevel_Normal:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
lineColor = UIColorFromRGB(0x66B5FF);
|
lineColor = UIColorFromRGB(0x66B5FF);
|
||||||
bgBtnColor = UIColorFromRGB(0x283889);
|
bgBtnColor = UIColorFromRGB(0x283889);
|
||||||
bgImageName = @"pi_room_gift_broadcast_low_bg";
|
bgImageName = @"pi_room_gift_broadcast_low_bg";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BroadCastLevel_Middle:
|
case BroadCastLevel_Middle:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lineColor = UIColorFromRGB(0xFE9FFF);
|
lineColor = UIColorFromRGB(0xFE9FFF);
|
||||||
bgBtnColor = UIColorFromRGB(0x49157D);
|
bgBtnColor = UIColorFromRGB(0x49157D);
|
||||||
|
|
||||||
bgImageName = @"pi_room_gift_broadcast_middle_bg";
|
bgImageName = @"pi_room_gift_broadcast_middle_bg";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BroadCastLevel_High:
|
case BroadCastLevel_High:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lineColor = UIColorFromRGB(0xFFED77);
|
lineColor = UIColorFromRGB(0xFFED77);
|
||||||
bgBtnColor = UIColorFromRGB(0x87152D);
|
bgBtnColor = UIColorFromRGB(0x87152D);
|
||||||
|
|
||||||
bgImageName = @"pi_room_gift_broadcast_high_bg";
|
bgImageName = @"pi_room_gift_broadcast_high_bg";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lineColor = UIColorFromRGB(0x66B5FF);
|
lineColor = UIColorFromRGB(0x66B5FF);
|
||||||
bgBtnColor = UIColorFromRGB(0x283889);
|
bgBtnColor = UIColorFromRGB(0x283889);
|
||||||
|
|
||||||
bgImageName = @"pi_room_gift_broadcast_low_bg";
|
bgImageName = @"pi_room_gift_broadcast_low_bg";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -205,6 +171,7 @@
|
|||||||
-(void)showRoomVC{
|
-(void)showRoomVC{
|
||||||
[self didClickEnterRoom];
|
[self didClickEnterRoom];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
- (void)setBroadcastModel:(GiftReceiveInfoModel *)broadcastModel {
|
- (void)setBroadcastModel:(GiftReceiveInfoModel *)broadcastModel {
|
||||||
_broadcastModel = broadcastModel;
|
_broadcastModel = broadcastModel;
|
||||||
|
@@ -116,7 +116,6 @@
|
|||||||
make.leading.mas_equalTo(self).offset(15);
|
make.leading.mas_equalTo(self).offset(15);
|
||||||
make.top.trailing.mas_equalTo(self);
|
make.top.trailing.mas_equalTo(self);
|
||||||
make.height.mas_equalTo(0);
|
make.height.mas_equalTo(0);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,6 @@
|
|||||||
[[self getView] updateRoomTopicFail:YMLocalizedString(@"XPRoomTopicPresenter0")];
|
[[self getView] updateRoomTopicFail:YMLocalizedString(@"XPRoomTopicPresenter0")];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -18,6 +18,10 @@
|
|||||||
#import "XCCurrentVCStackManager.h"
|
#import "XCCurrentVCStackManager.h"
|
||||||
#import "XPMineUserInfoViewController.h"
|
#import "XPMineUserInfoViewController.h"
|
||||||
|
|
||||||
|
#import "Api+Mine.h"
|
||||||
|
#import "YuMi-swift.h"
|
||||||
|
#import "RechargeStorage.h"
|
||||||
|
|
||||||
///vc
|
///vc
|
||||||
#import "XPMineDressUpViewController.h"
|
#import "XPMineDressUpViewController.h"
|
||||||
#import "XPDressUpShopViewController.h"
|
#import "XPDressUpShopViewController.h"
|
||||||
@@ -89,6 +93,10 @@ typedef NS_ENUM(NSUInteger, RightNavigationPushType){
|
|||||||
///
|
///
|
||||||
@property (nonatomic,assign) BOOL isCustom;
|
@property (nonatomic,assign) BOOL isCustom;
|
||||||
@property(nonatomic,strong) PIWebViewSavePhotoView *saveView;
|
@property(nonatomic,strong) PIWebViewSavePhotoView *saveView;
|
||||||
|
|
||||||
|
/// 订单编号
|
||||||
|
@property (nonatomic,copy) NSString *orderId;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NSString * const kJSOpenPurse = @"openPurse";
|
NSString * const kJSOpenPurse = @"openPurse";
|
||||||
@@ -113,6 +121,8 @@ NSString * const kJSOpenChatPage = @"geToChatPage";
|
|||||||
NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
|
NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
|
||||||
NSString * const kJSSavePictureShare = @"savePictureShare";
|
NSString * const kJSSavePictureShare = @"savePictureShare";
|
||||||
NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
|
NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
|
||||||
|
NSString * const kJSOpenPayment = @"openPayment";
|
||||||
|
NSString * const kJSOpenPaymentCallback = @"openPaymentCallback";
|
||||||
|
|
||||||
|
|
||||||
@implementation XPWebViewController
|
@implementation XPWebViewController
|
||||||
@@ -229,9 +239,6 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||||
[Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
[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 {
|
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
|
||||||
NSURL *URL = navigationAction.request.URL;
|
NSURL *URL = navigationAction.request.URL;
|
||||||
NSString *scheme = [URL scheme];
|
NSString *scheme = [URL scheme];
|
||||||
NSURLRequest *request = navigationAction.request;
|
NSURLRequest *request = navigationAction.request;
|
||||||
// Judge is whether to jump to other app.
|
// Judge is whether to jump to other app.
|
||||||
if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) {
|
if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) {
|
||||||
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL];
|
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL];
|
||||||
@@ -299,215 +306,394 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
|
|||||||
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
|
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
|
||||||
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
|
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
|
- (void)userContentController:(WKUserContentController *)userContentController
|
||||||
[self.webview evaluateJavaScript:@"document.location.href" completionHandler:^(id _Nullable response, NSError * _Nullable error) {
|
didReceiveScriptMessage:(WKScriptMessage *)message {
|
||||||
NSLog(@"%@", response);
|
[self.webview evaluateJavaScript:@"document.location.href"
|
||||||
NSString *currentUrl = [NSString stringWithFormat:@"%@", response];
|
completionHandler:^(id _Nullable response, NSError * _Nullable error) {
|
||||||
///测试环境只要有host就执行,方便h5连接本地调试
|
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
|
#ifdef DEBUG
|
||||||
if (currentUrl != nil) {
|
condition = currentUrl != nil;
|
||||||
#else
|
|
||||||
if (currentUrl != nil && [currentUrl containsString:API_HOST_URL]) {
|
|
||||||
#endif
|
#endif
|
||||||
if ([message.name isEqualToString:kJSOpenSharePage]) {
|
if(condition) {
|
||||||
if (message.body && message.body != [NSNull null]) {
|
if ([message.name isEqualToString:kJSOpenSharePage]) {
|
||||||
NSDictionary *body;
|
if (message.body && message.body != [NSNull null]) {
|
||||||
//不知道是哪个蓝精灵弄的,变成了个dic,所以我们要判断类型
|
NSDictionary *body;
|
||||||
if ([message.body isKindOfClass:[NSDictionary class]]) {
|
//不知道是哪个蓝精灵弄的,变成了个dic,所以我们要判断类型
|
||||||
body = message.body;
|
if ([message.body isKindOfClass:[NSDictionary class]]) {
|
||||||
} else if ([message.body isKindOfClass:[NSString class]]) {
|
body = message.body;
|
||||||
body = [message.body toJSONObject];
|
} 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;
|
|
||||||
}
|
}
|
||||||
|
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];
|
[TTPopup dismiss];
|
||||||
if(self.isPush){
|
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
|
||||||
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
|
userInfoVC.uid = uid.integerValue;
|
||||||
webVC.type = @"4";
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:userInfoVC animated:YES];
|
||||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
|
}
|
||||||
return;
|
} else if([message.name isEqualToString:kJSInitNav]) {
|
||||||
}
|
[self initNav:message.body];
|
||||||
UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC;
|
} else if([message.name isEqualToString:kJSGetRoomUid]) {
|
||||||
if (controller.presentingViewController) {
|
NSString *js = [NSString stringWithFormat:@"getMessage(\"roomUid\",\"%@\")",self.roomUid];
|
||||||
[controller dismissViewControllerAnimated:NO completion:nil];
|
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
NSLog(@"%@",error);
|
||||||
|
}];
|
||||||
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
|
} else if([message.name isEqualToString:kInitShowNav]) {
|
||||||
webVC.type = @"4";
|
if (((NSNumber *)message.body).intValue == 0) {
|
||||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
|
if (self.InitShowNavBlock) {
|
||||||
});
|
self.InitShowNavBlock(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);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self.navigationController) {
|
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
|
#pragma mark - private method
|
||||||
- (void)handleRouterType:(NSInteger)skyType message:(WKScriptMessage *)message {
|
- (void)handleRouterType:(NSInteger)skyType message:(WKScriptMessage *)message {
|
||||||
@@ -635,38 +821,37 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
|
|||||||
|
|
||||||
}
|
}
|
||||||
- (void)showSharePanel {
|
- (void)showSharePanel {
|
||||||
if (self.shareDic.allKeys.count <= 0) {
|
if (self.shareDic.allKeys.count <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSDictionary * dic = self.shareDic;
|
NSDictionary * dic = self.shareDic;
|
||||||
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
|
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
|
||||||
shareInfo.shareTitle = self.shareDic[@"title"];
|
shareInfo.shareTitle = self.shareDic[@"title"];
|
||||||
shareInfo.shareContent = dic[@"desc"];
|
shareInfo.shareContent = dic[@"desc"];
|
||||||
shareInfo.shareImageUrl = dic[@"imgUrl"];
|
shareInfo.shareImageUrl = dic[@"imgUrl"];
|
||||||
shareInfo.type = ShareType_H5;
|
shareInfo.type = ShareType_H5;
|
||||||
shareInfo.uid = [AccountInfoStorage instance].getUid;
|
shareInfo.uid = [AccountInfoStorage instance].getUid;
|
||||||
NSString *urlStr = ((NSString *)dic[@"url"]).length > 0 ? dic[@"url"] : dic[@"showUrl"];
|
NSString *urlStr = ((NSString *)dic[@"url"]).length > 0 ? dic[@"url"] : dic[@"showUrl"];
|
||||||
if (urlStr.length) {
|
if (urlStr.length) {
|
||||||
if ([urlStr containsString:@"?"]) {
|
if ([urlStr containsString:@"?"]) {
|
||||||
urlStr = [NSString stringWithFormat:@"%@&shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
|
urlStr = [NSString stringWithFormat:@"%@&shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
|
||||||
} else {
|
} else {
|
||||||
urlStr = [NSString stringWithFormat:@"%@?shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
|
urlStr = [NSString stringWithFormat:@"%@?shareUid=%@",urlStr,[AccountInfoStorage instance].getUid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shareInfo.shareUrl = urlStr;
|
shareInfo.shareUrl = urlStr;
|
||||||
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"];
|
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 *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 *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"];
|
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;
|
|
||||||
|
|
||||||
[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
|
#pragma mark - XCShareViewDelegate
|
||||||
@@ -856,8 +1041,10 @@ NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
|
|||||||
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSSavePictureShare];
|
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSSavePictureShare];
|
||||||
///兑换金币
|
///兑换金币
|
||||||
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGoToExchangeGold];
|
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGoToExchangeGold];
|
||||||
|
///周卡内购
|
||||||
|
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenPayment];
|
||||||
|
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenPaymentCallback];
|
||||||
|
|
||||||
}
|
}
|
||||||
return _pi_userContentController;
|
return _pi_userContentController;
|
||||||
|
|
||||||
|
@@ -70,13 +70,11 @@ public class PIIAPRegulate: NSObject {
|
|||||||
if let scene = await view.window?.windowScene{
|
if let scene = await view.window?.windowScene{
|
||||||
try await Transaction.beginRefundRequest(for:transactionId , in: scene)
|
try await Transaction.beginRefundRequest(for:transactionId , in: scene)
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch{
|
}catch{
|
||||||
print("iap error")
|
print("iap error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 购买某个产品
|
// 购买某个产品
|
||||||
@objc public func demandCommodityThing(productId:String, uuid: String) async throws {
|
@objc public func demandCommodityThing(productId:String, uuid: String) async throws {
|
||||||
if(ConditionBlock != nil ){
|
if(ConditionBlock != nil ){
|
||||||
|
Reference in New Issue
Block a user