处理vip逻辑
This commit is contained in:
@@ -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