This commit is contained in:
2025-12-15 15:11:16 +08:00
parent b21a2a8193
commit 1f0bdb1bd4

View File

@@ -9,6 +9,7 @@
#import "PayVM.h"
#import "KBPayProductModel.h"
#import "KBBizCode.h"
#import "KBShopVM.h"
static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
@interface KBJfPay () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@@ -40,6 +41,7 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
@property (nonatomic, strong) FGIAPProductsFilter *filter;
@property (nonatomic, strong) PayVM *payVM;
@property (nonatomic, strong) KBShopVM *shopVM;
@end
@@ -49,6 +51,7 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
[super viewDidLoad];
self.filter = [[FGIAPProductsFilter alloc] init];
self.payVM = [PayVM new];
self.shopVM = [KBShopVM new];
self.data = @[];
self.selectedIndex = NSNotFound;
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_bg_icon"]];
@@ -138,6 +141,11 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
[self fetchInAppProductList];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self fetchWalletBalance];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self selectItemAtCurrentIndexAnimated:NO];
@@ -217,6 +225,23 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
}
#pragma mark - Data
- (void)fetchWalletBalance {
__weak typeof(self) weakSelf = self;
[self.shopVM fetchWalletBalanceWithCompletion:^(NSString * _Nullable balance, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) self = weakSelf;
if (!self) { return; }
if (error) {
NSString *msg = error.localizedDescription ?: KBLocalized(@"Network error");
[KBHUD showInfo:msg];
return;
}
NSString *displayValue = balance.length ? balance : @"0";
self.pointsLabel.text = displayValue;
});
}];
}
- (void)fetchInAppProductList {
__weak typeof(self) weakSelf = self;
[self.payVM fetchInAppProductsNeedShow:YES completion:^(NSInteger sta, NSString * _Nullable msg, NSArray<KBPayProductModel *> * _Nullable products) {
@@ -320,7 +345,7 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
- (UILabel *)pointsLabel {
if (!_pointsLabel) {
_pointsLabel = [UILabel new];
_pointsLabel.text = @"4230"; //
_pointsLabel.text = @"--";
_pointsLabel.font = [KBFont bold:30];
_pointsLabel.textColor = [UIColor colorWithHex:KBColorValue];
}