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