This commit is contained in:
2025-12-11 14:03:13 +08:00
parent 2b4123741a
commit 94269209e0
8 changed files with 68 additions and 7 deletions

View File

@@ -49,6 +49,7 @@
#define API_THEME_LIST_ALL_STYLES @"/themes/listAllStyles" // 查询所有主题风格
#define API_THEME_LIST_BY_STYLE @"/themes/listByStyle" // 按风格查询主题列表
#define API_THEME_PURCHASED @"/themes/purchased" // 查询已购买主题
#define API_WALLET_BALANCE @"/wallet/balance" // 查询钱包余额
/// pay
#define API_VALIDATE_RECEIPT @"/api/apple/validate-receipt" // 排行榜标签列表

View File

@@ -115,8 +115,6 @@
0498BD8C2EE69E15006CC1D5 /* KBTagItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BD8A2EE69E15006CC1D5 /* KBTagItemModel.m */; };
0498BD8F2EE6A3BD006CC1D5 /* KBMyMainModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BD8E2EE6A3BD006CC1D5 /* KBMyMainModel.m */; };
0498BD902EE6A3BD006CC1D5 /* KBMyMainModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BD8E2EE6A3BD006CC1D5 /* KBMyMainModel.m */; };
550CB2630FA4A7B4B9782EFA /* KBMyTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 180D662EC4DB3A7FFF83FF18 /* KBMyTheme.m */; };
471CAD3574798685B72ADD55 /* KBMyTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 180D662EC4DB3A7FFF83FF18 /* KBMyTheme.m */; };
0498BDDA2EE7ECEA006CC1D5 /* WJXEventSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDD82EE7ECEA006CC1D5 /* WJXEventSource.m */; };
0498BDDE2EE81508006CC1D5 /* KBShopVM.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDDD2EE81508006CC1D5 /* KBShopVM.m */; };
0498BDE12EEA87C9006CC1D5 /* KBShopStyleModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDE02EEA87C8006CC1D5 /* KBShopStyleModel.m */; };
@@ -182,6 +180,8 @@
04FC97092EB31B14007BD342 /* KBHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC97082EB31B14007BD342 /* KBHUD.m */; };
04FC970E2EB334F8007BD342 /* UIImageView+KBWebImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC970B2EB334F8007BD342 /* UIImageView+KBWebImage.m */; };
04FC970F2EB334F8007BD342 /* KBWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC970D2EB334F8007BD342 /* KBWebImageManager.m */; };
471CAD3574798685B72ADD55 /* KBMyTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 180D662EC4DB3A7FFF83FF18 /* KBMyTheme.m */; };
550CB2630FA4A7B4B9782EFA /* KBMyTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 180D662EC4DB3A7FFF83FF18 /* KBMyTheme.m */; };
7A36414DFDA5BEC9B7D2E318 /* Pods_CustomKeyboard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1092FB2B452F95B15D4263 /* Pods_CustomKeyboard.framework */; };
A1B2C3D42EB0A0A100000001 /* KBFunctionTagCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D32EB0A0A100000001 /* KBFunctionTagCell.m */; };
A1B2C3E22EB0C0A100000001 /* KBNetworkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3E12EB0C0A100000001 /* KBNetworkManager.m */; };
@@ -411,8 +411,6 @@
0498BD8A2EE69E15006CC1D5 /* KBTagItemModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBTagItemModel.m; sourceTree = "<group>"; };
0498BD8D2EE6A3BD006CC1D5 /* KBMyMainModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBMyMainModel.h; sourceTree = "<group>"; };
0498BD8E2EE6A3BD006CC1D5 /* KBMyMainModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBMyMainModel.m; sourceTree = "<group>"; };
7ECBD0E320F971D0FBEDD7BC /* KBMyTheme.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBMyTheme.h; sourceTree = "<group>"; };
180D662EC4DB3A7FFF83FF18 /* KBMyTheme.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBMyTheme.m; sourceTree = "<group>"; };
0498BDD72EE7ECEA006CC1D5 /* WJXEventSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WJXEventSource.h; sourceTree = "<group>"; };
0498BDD82EE7ECEA006CC1D5 /* WJXEventSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WJXEventSource.m; sourceTree = "<group>"; };
0498BDDC2EE81508006CC1D5 /* KBShopVM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBShopVM.h; sourceTree = "<group>"; };
@@ -539,11 +537,13 @@
04FC970C2EB334F8007BD342 /* KBWebImageManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBWebImageManager.h; sourceTree = "<group>"; };
04FC970D2EB334F8007BD342 /* KBWebImageManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBWebImageManager.m; sourceTree = "<group>"; };
04FC98012EB36AAB007BD342 /* KBConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBConfig.h; sourceTree = "<group>"; };
180D662EC4DB3A7FFF83FF18 /* KBMyTheme.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBMyTheme.m; sourceTree = "<group>"; };
2C1092FB2B452F95B15D4263 /* Pods_CustomKeyboard.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CustomKeyboard.framework; sourceTree = BUILT_PRODUCTS_DIR; };
51FE7C4C42C2255B3C1C4128 /* Pods-keyBoard.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-keyBoard.release.xcconfig"; path = "Target Support Files/Pods-keyBoard/Pods-keyBoard.release.xcconfig"; sourceTree = "<group>"; };
7276DDA62EC1B28300804C36 /* KBWebViewViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBWebViewViewController.h; sourceTree = "<group>"; };
7276DDA72EC1B28300804C36 /* KBWebViewViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBWebViewViewController.m; sourceTree = "<group>"; };
727EC7532EAF848B00B36487 /* keyBoard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = keyBoard.app; sourceTree = BUILT_PRODUCTS_DIR; };
7ECBD0E320F971D0FBEDD7BC /* KBMyTheme.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBMyTheme.h; sourceTree = "<group>"; };
967065BB5230E43F293B3AF9 /* Pods_keyBoard.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_keyBoard.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A1B2C3D22EB0A0A100000001 /* KBFunctionTagCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBFunctionTagCell.h; sourceTree = "<group>"; };
A1B2C3D32EB0A0A100000001 /* KBFunctionTagCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFunctionTagCell.m; sourceTree = "<group>"; };
@@ -810,6 +810,8 @@
047C654F2EBCBA9E0035E841 /* KBShopVC.m */,
048908F32EC0496400FABA60 /* KBShopItemVC.h */,
048908F42EC0496400FABA60 /* KBShopItemVC.m */,
048908E12EBF821700FABA60 /* KBSkinDetailVC.h */,
048908E22EBF821700FABA60 /* KBSkinDetailVC.m */,
);
path = VC;
sourceTree = "<group>";
@@ -1225,8 +1227,6 @@
049FB2192EC20A9E00FAB05D /* KBMyKeyBoardVC.m */,
048908DE2EBF73DC00FABA60 /* MySkinVC.h */,
048908DF2EBF73DC00FABA60 /* MySkinVC.m */,
048908E12EBF821700FABA60 /* KBSkinDetailVC.h */,
048908E22EBF821700FABA60 /* KBSkinDetailVC.m */,
049FB2212EC311F900FAB05D /* KBPersonInfoVC.h */,
049FB2222EC311F900FAB05D /* KBPersonInfoVC.m */,
04791F902ED48010004E8522 /* KBNoticeVC.h */,

View File

@@ -272,7 +272,7 @@
- (UILabel *)amountLabel {
if (!_amountLabel) {
_amountLabel = [UILabel new];
_amountLabel.text = @"88.00";
_amountLabel.text = @"00.00";
_amountLabel.textColor = [UIColor colorWithHex:KBColorValue];
_amountLabel.font = [KBFont bold:40];
_amountLabel.adjustsFontSizeToFitWidth = YES;

View File

@@ -70,6 +70,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
}];
[self fetchShopStylesWithHUD:YES];
[self fetchWalletBalanceWithHUD:NO];
}
// Base VC
@@ -137,6 +138,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
__weak typeof(self)weakSelf = self;
self.pagerView.mainTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
[weakSelf fetchShopStylesWithHUD:NO];
[weakSelf fetchWalletBalanceWithHUD:NO];
}];
self.pagerView.pinSectionHeaderVerticalOffset = KB_NAV_TOTAL_HEIGHT;
@@ -272,6 +274,28 @@ static const CGFloat JXheightForHeaderInSection = 50;
return _shopVM;
}
- (void)fetchWalletBalanceWithHUD:(BOOL)showHUD {
if (showHUD) {
[KBHUD show];
}
__weak typeof(self) weakSelf = self;
[self.shopVM fetchWalletBalanceWithCompletion:^(NSNumber * _Nullable balance, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (showHUD) {
[KBHUD dismiss];
}
if (error) {
NSString *msg = error.localizedDescription ?: KBLocalized(@"Network error");
[KBHUD showInfo:msg];
return;
}
double amountValue = balance.doubleValue;
NSString *amountString = [NSString stringWithFormat:@"%.2f", amountValue];
[weakSelf.userHeaderView updatePoints:amountString];
});
}];
}
- (void)fetchShopStylesWithHUD:(BOOL)showHUD {
if (showHUD) {
[KBHUD show];

View File

@@ -18,6 +18,8 @@ typedef void(^KBShopStylesCompletion)(NSArray<KBShopStyleModel *> *_Nullable sty
NSError *_Nullable error);
typedef void(^KBShopThemesCompletion)(NSArray<KBShopThemeModel *> *_Nullable themes,
NSError *_Nullable error);
typedef void(^KBShopBalanceCompletion)(NSNumber *_Nullable balance,
NSError *_Nullable error);
@interface KBShopVM : NSObject
@property (nonatomic, copy, readonly, nullable) NSArray<KBShopStyleModel *> *styles;
@@ -29,6 +31,9 @@ typedef void(^KBShopThemesCompletion)(NSArray<KBShopThemeModel *> *_Nullable the
- (void)fetchThemesForStyleId:(nullable NSString *)styleId
completion:(KBShopThemesCompletion)completion;
/// 查询钱包余额
- (void)fetchWalletBalanceWithCompletion:(KBShopBalanceCompletion)completion;
@end
NS_ASSUME_NONNULL_END

View File

@@ -82,4 +82,35 @@
}];
}
- (void)fetchWalletBalanceWithCompletion:(KBShopBalanceCompletion)completion {
[[KBNetworkManager shared] GET:API_WALLET_BALANCE
parameters:nil
headers:nil
autoShowBusinessError:NO
completion:^(NSDictionary * _Nullable json,
NSURLResponse * _Nullable response,
NSError * _Nullable error) {
if (error) {
if (completion) completion(nil, error);
return;
}
id dataObj = json[KBData] ?: json[@"data"];
if (![dataObj isKindOfClass:[NSDictionary class]]) {
if (completion) completion(nil, [self kb_invalidResponseError]);
return;
}
id balanceValue = dataObj[@"balance"];
NSNumber *balanceNumber = nil;
if ([balanceValue isKindOfClass:[NSNumber class]]) {
balanceNumber = balanceValue;
} else if ([balanceValue isKindOfClass:[NSString class]]) {
balanceNumber = @([(NSString *)balanceValue doubleValue]);
}
if (!balanceNumber) {
balanceNumber = @(0);
}
if (completion) completion(balanceNumber, nil);
}];
}
@end