处理vip逻辑

This commit is contained in:
2026-02-04 21:49:28 +08:00
parent b73f225d15
commit 35b1fc0f1e
8 changed files with 99 additions and 19 deletions

View File

@@ -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"];

View File

@@ -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"

View File

@@ -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 {

View File

@@ -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

View File

@@ -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;
}