处理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

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