处理vip逻辑
This commit is contained in:
@@ -1019,9 +1019,13 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
||||
if (!self) return;
|
||||
|
||||
if (!response.success) {
|
||||
NSLog(@"[KB] ❌ 请求失败: %@", response.errorMessage);
|
||||
if (response.code == 50030) {
|
||||
|
||||
return;
|
||||
}
|
||||
NSLog(@"[KB] ❌ 请求失败: %@", response.message);
|
||||
[self.chatPanelView kb_removeLoadingAssistantMessage];
|
||||
[KBHUD showInfo:response.errorMessage ?: KBLocalized(@"请求失败")];
|
||||
[KBHUD showInfo:response.message ?: KBLocalized(@"请求失败")];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface KBChatResponse : NSObject
|
||||
@property (nonatomic, copy, nullable) NSString *text;
|
||||
@property (nonatomic, copy, nullable) NSString *audioId;
|
||||
@property (nonatomic, copy, nullable) NSString *errorMessage;
|
||||
@property (nonatomic, copy, nullable) NSString *message;
|
||||
@property (nonatomic, assign) BOOL success;
|
||||
@property (nonatomic, assign) NSInteger code;
|
||||
|
||||
@end
|
||||
|
||||
/// 音频响应模型
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#import "KBNetworkManager.h"
|
||||
#import "KBConfig.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <MJExtension/MJExtension.h>
|
||||
|
||||
@implementation KBChatResponse
|
||||
@end
|
||||
@@ -46,7 +47,7 @@
|
||||
if (completion) {
|
||||
KBChatResponse *response = [[KBChatResponse alloc] init];
|
||||
response.success = NO;
|
||||
response.errorMessage = @"内容为空";
|
||||
response.message = @"内容为空";
|
||||
completion(response);
|
||||
}
|
||||
return;
|
||||
@@ -66,24 +67,24 @@
|
||||
headers:nil
|
||||
completion:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
KBChatResponse *chatResponse = [[KBChatResponse alloc] init];
|
||||
KBChatResponse *chatResponse = [KBChatResponse mj_objectWithKeyValues:json];
|
||||
|
||||
if (error) {
|
||||
chatResponse.success = NO;
|
||||
chatResponse.errorMessage = error.localizedDescription ?: @"请求失败";
|
||||
// chatResponse.errorMessage = error.localizedDescription ?: @"请求失败";
|
||||
if (completion) completion(chatResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
// 解析文本
|
||||
chatResponse.text = [self p_parseTextFromJSON:json];
|
||||
// 解析 audioId
|
||||
chatResponse.audioId = [self p_parseAudioIdFromJSON:json];
|
||||
// // 解析文本
|
||||
// chatResponse.text = [self p_parseTextFromJSON:json];
|
||||
// // 解析 audioId
|
||||
// chatResponse.audioId = [self p_parseAudioIdFromJSON:json];
|
||||
|
||||
chatResponse.success = (chatResponse.text.length > 0);
|
||||
if (!chatResponse.success) {
|
||||
chatResponse.errorMessage = @"未获取到回复内容";
|
||||
}
|
||||
// chatResponse.success = (chatResponse.text.length > 0);
|
||||
// if (!chatResponse.success) {
|
||||
// chatResponse.errorMessage = @"未获取到回复内容";
|
||||
// }
|
||||
|
||||
if (completion) completion(chatResponse);
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#import "KBLoginPopView.h"
|
||||
#import "KBSexSelVC.h"
|
||||
#import "KBKeyboardPermissionManager.h"
|
||||
#import "KBVipPay.h"
|
||||
#import "KBPayMainVC.h"
|
||||
#import "KBUserSessionManager.h"
|
||||
#import "KBLoginVC.h"
|
||||
#import "KBConfig.h"
|
||||
@@ -220,7 +220,7 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0;
|
||||
}
|
||||
}
|
||||
|
||||
KBVipPay *vc = [[KBVipPay alloc] init];
|
||||
KBPayMainVC *vc = [[KBPayMainVC alloc] init];
|
||||
if ([prefillPayload isKindOfClass:NSDictionary.class]) {
|
||||
NSArray *productsJSON = prefillPayload[@"products"];
|
||||
NSNumber *selectedIndexNumber = prefillPayload[@"selectedIndex"];
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#import "BaseTabBarController.h"
|
||||
#import "HomeMainVC.h"
|
||||
#import "KBAiMainVC.h"
|
||||
//#import "KBAiMainVC.h"
|
||||
#import "KBShopVC.h"
|
||||
#import "MyVC.h"
|
||||
#import "KBAIHomeVC.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "KBPersonInfoVC.h"
|
||||
#import "KBMyKeyBoardVC.h"
|
||||
#import "KBJfPay.h"
|
||||
#import "KBVipPay.h"
|
||||
#import "KBPayMainVC.h"
|
||||
#import "UIImageView+KBWebImage.h"
|
||||
#import "KBUser.h"
|
||||
|
||||
@@ -377,7 +377,7 @@
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
}
|
||||
- (void)onLeftCardTap {
|
||||
KBVipPay *vc = [[KBVipPay alloc] init];
|
||||
KBPayMainVC *vc = [[KBPayMainVC alloc] init];
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
}
|
||||
- (void)onRightCardTap {
|
||||
|
||||
@@ -17,6 +17,17 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 默认 0
|
||||
@property (nonatomic, assign) NSInteger initialSelectedIndex;
|
||||
|
||||
/// 通过键盘深链配置初始商品及是否自动发起购买(透传给 VIP 页)
|
||||
- (void)configureWithProductId:(nullable NSString *)productId
|
||||
autoPurchase:(BOOL)autoPurchase;
|
||||
|
||||
/// 通过键盘扩展预填充商品列表(免二次请求,透传给 VIP 页)
|
||||
/// 注意:selectedIndex 是商品列表下标,不是 VIP/SVIP 的 tab 下标
|
||||
- (void)configureWithProductId:(nullable NSString *)productId
|
||||
autoPurchase:(BOOL)autoPurchase
|
||||
prefillProductsJSON:(nullable NSArray *)productsJSON
|
||||
selectedIndex:(NSInteger)selectedIndex;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -51,10 +51,71 @@ static const CGFloat JXheightForHeaderInSection = 39;
|
||||
@property (nonatomic, strong) UILabel *agreementLabel;
|
||||
@property (nonatomic, strong) UIButton *agreementButton;
|
||||
|
||||
/// Deep link pending config (透传给 VIP 页面)
|
||||
@property (nonatomic, copy, nullable) NSString *pendingProductId;
|
||||
@property (nonatomic, assign) BOOL pendingAutoPurchase;
|
||||
@property (nonatomic, copy, nullable) NSArray *pendingPrefillProductsJSON;
|
||||
@property (nonatomic, assign) NSInteger pendingPrefillSelectedIndex;
|
||||
|
||||
@end
|
||||
|
||||
@implementation KBPayMainVC
|
||||
|
||||
#pragma mark - Deep Link Support
|
||||
|
||||
- (void)configureWithProductId:(nullable NSString *)productId autoPurchase:(BOOL)autoPurchase {
|
||||
self.pendingProductId = productId.length ? [productId copy] : nil;
|
||||
self.pendingAutoPurchase = autoPurchase;
|
||||
self.pendingPrefillProductsJSON = nil;
|
||||
self.pendingPrefillSelectedIndex = NSNotFound;
|
||||
[self kb_applyPendingConfigToVipIfPossible];
|
||||
}
|
||||
|
||||
- (void)configureWithProductId:(nullable NSString *)productId
|
||||
autoPurchase:(BOOL)autoPurchase
|
||||
prefillProductsJSON:(nullable NSArray *)productsJSON
|
||||
selectedIndex:(NSInteger)selectedIndex {
|
||||
self.pendingProductId = productId.length ? [productId copy] : nil;
|
||||
self.pendingAutoPurchase = autoPurchase;
|
||||
self.pendingPrefillProductsJSON = ([productsJSON isKindOfClass:NSArray.class] ? [productsJSON copy] : nil);
|
||||
self.pendingPrefillSelectedIndex = selectedIndex;
|
||||
[self kb_applyPendingConfigToVipIfPossible];
|
||||
}
|
||||
|
||||
- (void)kb_applyPendingConfigToVipIfPossible {
|
||||
if (!self.isViewLoaded) { return; }
|
||||
BOOL hasPrefill = ([self.pendingPrefillProductsJSON isKindOfClass:NSArray.class] && self.pendingPrefillProductsJSON.count > 0);
|
||||
BOOL hasProductId = (self.pendingProductId.length > 0);
|
||||
if (!hasPrefill && !hasProductId && !self.pendingAutoPurchase) {
|
||||
return;
|
||||
}
|
||||
// 仅透传给 VIP 页面,确保深链/键盘入口不依赖子 VC 类型
|
||||
NSInteger vipIndex = 0;
|
||||
if (self.myCategoryView && self.myCategoryView.selectedIndex != vipIndex) {
|
||||
[self.myCategoryView selectItemAtIndex:vipIndex];
|
||||
}
|
||||
KBVipPay *vipVC = (KBVipPay *)[self.pagerView.listContainerView.validListDict objectForKey:@(vipIndex)];
|
||||
if (![vipVC isKindOfClass:KBVipPay.class]) { return; }
|
||||
[self kb_applyPendingConfigToVipList:vipVC];
|
||||
}
|
||||
|
||||
- (void)kb_applyPendingConfigToVipList:(KBVipPay *)vipVC {
|
||||
if (![vipVC isKindOfClass:KBVipPay.class]) { return; }
|
||||
BOOL hasPrefill = ([self.pendingPrefillProductsJSON isKindOfClass:NSArray.class] && self.pendingPrefillProductsJSON.count > 0);
|
||||
BOOL hasProductId = (self.pendingProductId.length > 0);
|
||||
if (!hasPrefill && !hasProductId && !self.pendingAutoPurchase) {
|
||||
return;
|
||||
}
|
||||
if (hasPrefill) {
|
||||
[vipVC configureWithProductId:self.pendingProductId
|
||||
autoPurchase:self.pendingAutoPurchase
|
||||
prefillProductsJSON:self.pendingPrefillProductsJSON
|
||||
selectedIndex:self.pendingPrefillSelectedIndex];
|
||||
} else {
|
||||
[vipVC configureWithProductId:self.pendingProductId autoPurchase:self.pendingAutoPurchase];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
@@ -227,6 +288,7 @@ static const CGFloat JXheightForHeaderInSection = 39;
|
||||
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
||||
if (index == 0) {
|
||||
KBVipPay *list = [[KBVipPay alloc] init];
|
||||
[self kb_applyPendingConfigToVipList:list];
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user