1
This commit is contained in:
@@ -18,8 +18,10 @@ 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,
|
||||
typedef void(^KBShopBalanceCompletion)(NSString *_Nullable balance,
|
||||
NSError *_Nullable error);
|
||||
typedef void(^KBShopDetailCompletion)(NSDictionary *_Nullable json,
|
||||
NSError *_Nullable error);
|
||||
|
||||
@interface KBShopVM : NSObject
|
||||
@property (nonatomic, copy, readonly, nullable) NSArray<KBShopStyleModel *> *styles;
|
||||
@@ -34,6 +36,10 @@ typedef void(^KBShopBalanceCompletion)(NSNumber *_Nullable balance,
|
||||
/// 查询钱包余额
|
||||
- (void)fetchWalletBalanceWithCompletion:(KBShopBalanceCompletion)completion;
|
||||
|
||||
/// 查询主题详情
|
||||
- (void)fetchThemeDetailWithId:(nullable NSString *)themeId
|
||||
completion:(KBShopDetailCompletion)completion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -99,17 +99,37 @@
|
||||
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]);
|
||||
NSString *balanceValue = dataObj[@"balanceDisplay"];
|
||||
// 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(balanceValue, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)fetchThemeDetailWithId:(nullable NSString *)themeId
|
||||
completion:(KBShopDetailCompletion)completion {
|
||||
if (themeId.length == 0) {
|
||||
if (completion) completion(nil, [self kb_invalidParameterError]);
|
||||
return;
|
||||
}
|
||||
NSDictionary *params = @{@"themeId": themeId};
|
||||
[[KBNetworkManager shared] GET:API_THEME_DETAIL
|
||||
parameters:params
|
||||
headers:nil
|
||||
autoShowBusinessError:NO
|
||||
completion:^(NSDictionary * _Nullable json,
|
||||
NSURLResponse * _Nullable response,
|
||||
NSError * _Nullable error) {
|
||||
if (completion) {
|
||||
completion(json, error);
|
||||
}
|
||||
if (!balanceNumber) {
|
||||
balanceNumber = @(0);
|
||||
}
|
||||
if (completion) completion(balanceNumber, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user