2.4.1代码上传,增加微信支付功能

This commit is contained in:
CYH 2023-07-31 16:12:40 +08:00
parent f30140a3d7
commit b020b9c196
14 changed files with 156 additions and 102 deletions

View File

@ -39,7 +39,7 @@ target 'TreeHole' do
# 手机一键登录
# pod 'CL_ShanYanSDK', '= 2.3.4.8'
# 微信sdk
# pod 'WechatOpenSDK', '= 1.8.7.1'
# Toast
pod 'Toast', '4.0.0'
# 腾讯IMSDK
@ -93,6 +93,8 @@ target 'TreeHole' do
pod 'TXLiteAVSDK_Professional'
# pod 'WechatOpenSDK', '1.8.7.1'
end
target 'HoleNotification' do

View File

@ -4319,7 +4319,11 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.4.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/TreeHole/Code/WechatSDK/OpenSDK2.0.2",
);
MARKETING_VERSION = 2.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.zncdts.app123;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -4377,7 +4381,11 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.4.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/TreeHole/Code/WechatSDK/OpenSDK2.0.2",
);
MARKETING_VERSION = 2.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.zncdts.app123;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -57,6 +57,12 @@
[TUILogin initWithSdkAppID:TIM_APPID]; // SDKAppID IM
[Bugly startWithAppId:BUGLY_APPID];
[WXApi startLogByLevel:WXLogLevelNormal logBlock:^(NSString *log) {
NSLog(@"weixin - log : %@", log);
}];
//
[WXApi registerApp:@"wx6f74f7bdf0f9ea4f" universalLink:@"https://xidi.iquanpai.com/app/"];
// apple pay
[[ApplePayService sharedInstance] autoHandleUpdatedTransactions];
//

View File

@ -69,10 +69,10 @@
[WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
NSLog(@"WeChatSDK: %@", log);
}];
//
[WXApi registerApp:WEIXIN_APP_ID
universalLink:UNIVERSAL_LINK];
//
// //
// [WXApi registerApp:WEIXIN_APP_ID
// universalLink:UNIVERSAL_LINK];
//// //
// [WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
// NSLog(@"%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);

View File

@ -91,7 +91,9 @@ typedef NS_ENUM(NSUInteger, AuthorizationType) {
+ (AppConfig *)appConfig;
+ (void)getAppConfigWithCompletion:(void(^)(AppConfig *config))completion;
/// 发起微信支付
//+ (void)payByWetChatPayWithOrderId:(NSString *)orderId payInfo:(NSDictionary *)payInfo;
+ (void)payByWetChatPayWithOrderId:(NSString *)orderId payInfo:(NSDictionary *)payInfo;
+ (void)payByWetChatPayWithOrderId:(NSString *)orderId payInfo:(NSDictionary *)payInfo userId:(NSString *)userId;
/// 跳转用户资料卡页面
+ (void)showUserCardVCWithUserID:(int)userID;

View File

@ -673,52 +673,81 @@ static AppConfig *gAppConfig;
static NSString *currentOrderId = nil;
//+ (void)payByWetChatPayWithOrderId:(NSString *)orderId payInfo:(NSDictionary *)payInfo
//{
// currentOrderId = orderId;
// PayReq *request = [[PayReq alloc] init];
// request.partnerId = payInfo[@"partnerId"];
// request.prepayId= payInfo[@"prepayId"];
// request.package = payInfo[@"package"];
// request.nonceStr= payInfo[@"nonceStr"];
// request.timeStamp= [payInfo[@"timeStamp"] intValue];
// request.sign = payInfo[@"sign"];
// [WXApi sendReq:request completion:^(BOOL success) {
// if (!success) {
// [SVProgressHUD showErrorWithStatus:@"唤起微信支付失败"];
// }
// }];
//}
static NSString *currentUserId = nil;
+ (void)payByWetChatPayWithOrderId:(NSString *)orderId payInfo:(NSDictionary *)payInfo
{
currentOrderId = orderId;
currentUserId = @"";
PayReq *request = [[PayReq alloc] init];
request.partnerId = payInfo[@"partnerId"];
request.prepayId= payInfo[@"prepayId"];
request.package = payInfo[@"package"];
request.nonceStr= payInfo[@"nonceStr"];
request.timeStamp= [payInfo[@"timeStamp"] intValue];
request.sign = payInfo[@"sign"];
[WXApi sendReq:request completion:^(BOOL success) {
if (!success) {
[SVProgressHUD showErrorWithStatus:@"唤起微信支付失败"];
}
}];
}
+ (void)payByWetChatPayWithOrderId:(NSString *)orderId payInfo:(NSDictionary *)payInfo userId:(NSString *)userId {
currentUserId = userId;
currentOrderId = orderId;
PayReq *request = [[PayReq alloc] init];
request.partnerId = payInfo[@"partnerId"];
request.prepayId= payInfo[@"prepayId"];
request.package = payInfo[@"package"];
request.nonceStr= payInfo[@"nonceStr"];
request.timeStamp= [payInfo[@"timeStamp"] intValue];
request.sign = payInfo[@"sign"];
[WXApi sendReq:request completion:^(BOOL success) {
if (!success) {
[SVProgressHUD showErrorWithStatus:@"唤起微信支付失败"];
}
}];
}
- (void)onAppDidBecomeActive {
// [self checkWXOrderIFNeed];
}
//- (void)checkWXOrderIFNeed {
// if (!currentOrderId) {
// return;
// }
// [PYHTTPManager postWithPath:@"wxcheckorder" params:@{
// @"order_no": currentOrderId ?: @""
// } callback:^(id _Nullable rsp, NSError * _Nullable error) {
// if (!error) {
// [SVProgressHUD dismiss];
// if ([rsp[@"is_pay_succeed"] boolValue]) {
// currentOrderId = nil;
// [[NSNotificationCenter defaultCenter] postNotificationName:BuyVIPSuccessNotification object:nil];
// [MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
// config.title = @"VIP购买成功";
// config.message = @"你现在是我们小酒馆最尊贵的客人";
// config.otherTitle = @"确定";
// }];
// } else {
//// [SVProgressHUD showErrorWithStatus:@"支付失败"];
// }
// } else {
//// [SVProgressHUD showErrorWithStatus:@"支付失败"];
// }
// }];
//}
- (void)checkWXOrderIFNeed {
if (!currentOrderId) {
return;
}
[PYHTTPManager postWithPath:@"wxcheckorder" params:@{
@"order_uuid": currentOrderId ?: @""
} callback:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
[SVProgressHUD dismiss];
if ([rsp[@"is_pay_succeed"] boolValue]) {
if (currentUserId.length > 0) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"receivedVipMsgnotifi" object:currentUserId];
currentOrderId = nil;
currentUserId = nil;
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:BuyVIPSuccessNotification object:nil];
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
config.title = @"VIP购买成功";
config.message = @"你现在是我们小酒馆最尊贵的客人";
config.otherTitle = @"确定";
}];
}
} else {
// [SVProgressHUD showErrorWithStatus:@"支付失败"];
}
} else {
[SVProgressHUD showErrorWithStatus:@"支付失败"];
}
}];
}
+ (void)showBadgeOnTabBarItemAtIndex:(int)index number:(int)number {
@ -786,9 +815,9 @@ static NSString *currentOrderId = nil;
///
- (void)onResp:(BaseResp *)resp
{
// if ([resp isKindOfClass:[PayResp class]]) { //
// [self checkWXOrderIFNeed];
// }
if ([resp isKindOfClass:[PayResp class]]) { //
[self checkWXOrderIFNeed];
}
}
@end

View File

@ -195,7 +195,7 @@
-(void)setDataModel:(userNearbyModel *)dataModel{
_dataModel = dataModel;
[_userImgV sd_setImageWithURL:[NSURL URLWithString:_dataModel.avatar] placeholderImage:[UIImage imageNamed:@"TH_defalut_avatar"]];
if ([_dataModel.user_vip_kind isEqualToString:@"1"]) {
if ([_dataModel.user_vip_kind isEqualToString:@"1"] || [_dataModel.user_vip_kind isEqualToString:@"10"] ) {
_userNameLab.textColor = COLOR_WITH_RGB(0xF8D07D);
_userVipImgV.hidden = NO;
}else{

View File

@ -173,7 +173,7 @@
return;
*/
if ([UserService currentUser].isVIP) {
// if ([UserService currentUser].isVIP) {
[PYAppService sendVipVC:@"vip_page" forUserID:self.convData.userID];
@ -181,9 +181,9 @@
// [[NSNotificationCenter defaultCenter] removeObserver:self name:@"sendVipMsgnotifi" object:nil];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sengVipMsg:) name:@"sendVipMsgnotifi" object:nil];
}else {
[ToastUtil showToast:@"需要成为会员才可以赠送VIP哦~"];
}
// }else {
// [ToastUtil showToast:@"需要成为会员才可以赠送VIP哦~"];
// }
}

View File

@ -71,7 +71,7 @@
}];
}];
[logoutItem addSubview:logoutLabel];
logoutItem.bottom = SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT;
logoutItem.bottom = SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT + 20;
[self.view addSubview:logoutItem];
self.tableView.contentSize = CGSizeMake(0, logoutItem.bottom);

View File

@ -93,30 +93,32 @@ static NSString * const kDidReportPayActionCacheKey = @"kDidReportPayActionCache
extraTotalDay = @(exExtraDay.intValue + storeExtraDay.intValue);
}
// [PYHTTPManager postWithPath:@"wxgoodprepay" params:@{
// @"vip_good_id": ID
// } callback:^(id _Nullable rsp, NSError * _Nullable error) {
// if (error) {
// [SVProgressHUD showErrorWithStatus:@"创建订单失败"];
// return;
// }
// [PYAppService payByWetChatPayWithOrderId:rsp[@"trade_no"] payInfo:rsp];
// }];
NSString *goodsID = ID;
NSMutableDictionary *paramsM = [@{
@"apple_good_id": goodsID,
@"extra_vip_day": extraTotalDay
} mutableCopy];
[PYHTTPManager postWithPath:@"wxgoodprepay" params:@{
@"vip_good_id": @([ID intValue]),@"vip_source":@"",@"extra_vip_day":extraTotalDay
[paramsM addEntriesFromDictionary:extInfo];
[PYHTTPManager postWithPath:@"iaporder" params:paramsM callback:^(id _Nullable rsp, NSError * _Nullable error) {
} callback:^(id _Nullable rsp, NSError * _Nullable error) {
if (error) {
[SVProgressHUD showSuccessWithStatus:error.userInfo[@"message"]];
[SVProgressHUD showErrorWithStatus:@"创建订单失败"];
return;
}
[ApplePayService payProductWithId:goodsID orderId:rsp[@"trade_uuid"] restoreProduct:NO isFastBuy:isFastBuy];
[PYAppService payByWetChatPayWithOrderId:rsp[@"trade_no"] payInfo:rsp];
}];
// NSString *goodsID = ID;
// NSMutableDictionary *paramsM = [@{
// @"apple_good_id": goodsID,
// @"extra_vip_day": extraTotalDay
// } mutableCopy];
//
// [paramsM addEntriesFromDictionary:extInfo];
//
// [PYHTTPManager postWithPath:@"iaporder" params:paramsM callback:^(id _Nullable rsp, NSError * _Nullable error) {
// if (error) {
// [SVProgressHUD showSuccessWithStatus:error.userInfo[@"message"]];
// return;
// }
// [ApplePayService payProductWithId:goodsID orderId:rsp[@"trade_uuid"] restoreProduct:NO isFastBuy:isFastBuy];
// }];
}
+ (void)SendStartPay:(NSString *)ID UserID:(NSString *)userID isFastBuy:(BOOL)isFastBuy extInfo:(NSDictionary *)extInfo
@ -146,7 +148,7 @@ static NSString * const kDidReportPayActionCacheKey = @"kDidReportPayActionCache
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];//app
NSMutableDictionary *paramsM = [@{
@"ios_good_id": goodsID,
@"vip_good_id": @([goodsID intValue]),
@"give_user_id": @(VuserID),
@"extra_vip_day": extraTotalDay,
// @"device_platform" :@"iOS",
@ -156,15 +158,15 @@ static NSString * const kDidReportPayActionCacheKey = @"kDidReportPayActionCache
[paramsM addEntriesFromDictionary:extInfo];
[PYHTTPManager postWithPath:@"ios/givevip" params:paramsM callback:^(id _Nullable rsp1, NSError * _Nullable error) {
[PYHTTPManager postWithPath:@"android/givevip" params:paramsM callback:^(id _Nullable rsp1, NSError * _Nullable error) {
NSLog(@"rsp===%@,goodsID===%@",rsp1,paramsM);
NSString *vipType ;
if ([goodsID containsString:@"68"]) {
if ([goodsID containsString:@"1"]) {
vipType = @"赠送你一个月会员";
}else if ([goodsID containsString:@"128"])
}else if ([goodsID containsString:@"13"])
{
vipType = @"赠送你三个月会员";
}else{
@ -173,7 +175,7 @@ static NSString * const kDidReportPayActionCacheKey = @"kDidReportPayActionCache
if (error) {
if (!error) {
// [SVProgressHUD showSuccessWithStatus:error.userInfo[@"message"]];
[SVProgressHUD showSuccessWithStatus:error.userInfo[@"message"]];
NSLog(@"message===%@",error.userInfo[@"message"]);
@ -181,11 +183,11 @@ static NSString * const kDidReportPayActionCacheKey = @"kDidReportPayActionCache
int code = [error.userInfo[@"code"] intValue];
if (code==0) {
[PYAppService payByWetChatPayWithOrderId:rsp1[@"trade_no"] payInfo:rsp1 userId:vipType];
// [ApplePayService payProductWithId:goodsID orderId:rsp1[@"trade_uuid"] restoreProduct:NO isFastBuy:isFastBuy];
//
[ApplePayService payProductWithId:goodsID orderId:rsp1[@"trade_uuid"] restoreProduct:NO isFastBuy:isFastBuy];
[[NSNotificationCenter defaultCenter] postNotificationName:@"receivedVipMsgnotifi" object:vipType];
}else if (code==1100)

View File

@ -174,12 +174,12 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"receivedVipMsgnotifi" object:nil];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:ImageNamed(@"TH_down_btn") style:UIBarButtonItemStyleDone target:self action:@selector(close)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"恢复购买" style:UIBarButtonItemStylePlain target:self action:@selector(restore)];
// self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"恢复购买" style:UIBarButtonItemStylePlain target:self action:@selector(restore)];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:BuyVIPSuccessNotification object:nil];
}
- (void)refresh {
[PYHTTPManager getWithPath:@"vipconfig" params:nil callback:^(id _Nullable rsp, NSError * _Nullable error) {
[PYHTTPManager getWithPath:self.userID.length > 0 ? @"vipconfig" : @"vipconfig/experience" params:nil callback:^(id _Nullable rsp, NSError * _Nullable error) {
NSLog(@"会员页面 : %@",rsp);
[self endLoading:error];
if (!error) {
@ -286,18 +286,19 @@
NSString *userID = [self.userID stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"hole_"]];
NSLog(@"userID%@",userID);
[ApplePayService sendStartVipPay:goodsID isFastBuy:NO source:self.vipSource UserID:userID];
[ApplePayService sendStartVipPay:[NSString stringWithFormat:@"%@",@(weakself.selectedGoodsInfo.good.vip_good_id)] isFastBuy:NO source:self.vipSource UserID:userID];
}
} else {
[ApplePayService startVipPay:[NSString stringWithFormat:@"%@",@(weakself.selectedGoodsInfo.good.vip_good_id)] isFastBuy:NO source:self.vipSource];
}
[ApplePayService startVipPay:goodsID isFastBuy:NO source:self.vipSource];
}];
[bottomView addSubview:buyButton];
RichTextLabel *richLabel = [RichTextLabel richTextFullString:[NSString stringWithFormat:@"查阅服务协议·隐私协议·会员服务协议购买后你可以随时在iTunes商店设置页取消订阅点击右上角也可恢复之前的购买"] items:@[
RichTextLabel *richLabel = [RichTextLabel richTextFullString:[NSString stringWithFormat:@"查阅服务协议·隐私协议·会员服务协议"] items:@[
[RichLabelItem itemWithText:@"服务协议" action:^{
[PYAppService openWebVCWithTitle:@"服务协议" url:@"http://iquanpai.com/app-h5/4_131.html"];
}],

View File

@ -257,13 +257,16 @@
CGSize itemSize = config.itemSize;
if (CGSizeEqualToSize(itemSize, CGSizeZero)) {
itemSize.width = (config.contentWidth - config.contentInset.left - config.contentInset.right - config.columnSpacing * (config.maxColumn - 1)) / config.maxColumn;
itemSize.height = config.itemHeight > 0 ? config.itemHeight : itemSize.width * config.itemRatio;
itemSize.width = (config.contentWidth - config.contentInset.left - config.contentInset.right - config.columnSpacing * (self.itemModels.count- 1)) / self.itemModels.count;
itemSize.height = config.itemHeight > 0 ? config.itemHeight : itemSize.width * (self.itemModels.count == 4 ? 0.25 : config.itemRatio);
}
flowLayout.itemSize = itemSize;
itemSize.width = (config.contentWidth - config.contentInset.left - config.contentInset.right - config.columnSpacing * (self.itemModels.count- 1)) / self.itemModels.count;
CGFloat contentHeight = config.contentInset.top + config.contentInset.bottom + (itemSize.height + config.rowSpacing) * (self.itemModels.count / config.maxColumn + 1) - config.rowSpacing;
CGFloat contentWidth = config.contentInset.left + config.contentInset.right + (itemSize.width + config.columnSpacing) * config.maxColumn - config.columnSpacing;
CGFloat contentHeight = config.contentInset.top + config.contentInset.bottom + (itemSize.height + config.rowSpacing)- config.rowSpacing;
CGFloat contentWidth = config.contentInset.left + config.contentInset.right + (itemSize.width + config.columnSpacing) * self.itemModels.count - config.columnSpacing;
flowLayout.itemSize = CGSizeMake(itemSize.width, contentHeight);
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, config.contentWidth, contentHeight) collectionViewLayout:flowLayout];
[self layoutSubviews];

View File

@ -11,7 +11,7 @@
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>wx1f7c5b876fffd4e1</string>
<string>wx6f74f7bdf0f9ea4f</string>
</array>
</dict>
<dict>

View File

@ -7,6 +7,7 @@
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:h5.diandi.club</string>
<string>applinks:https://xidi.iquanpai.com/app/</string>
</array>
</dict>
</plist>