1
This commit is contained in:
@@ -19,7 +19,7 @@ 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)(KBShopThemeDetailModel *_Nullable detail,
|
||||
NSError *_Nullable error);
|
||||
@@ -53,6 +53,9 @@ typedef void(^KBShopDownloadInfoCompletion)(NSDictionary *_Nullable info,
|
||||
- (void)fetchThemeDownloadInfoWithId:(nullable NSString *)themeId
|
||||
completion:(KBShopDownloadInfoCompletion)completion;
|
||||
|
||||
/// 推荐主题列表(用于皮肤详情页底部网格)
|
||||
- (void)fetchRecommendedThemesWithCompletion:(KBShopThemesCompletion)completion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -100,17 +100,9 @@
|
||||
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);
|
||||
NSString * balanceValue = dataObj[@"balanceDisplay"];
|
||||
|
||||
if (completion) completion(balanceValue, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -187,6 +179,28 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)fetchRecommendedThemesWithCompletion:(KBShopThemesCompletion)completion {
|
||||
[[KBNetworkManager shared] GET:API_THEME_RECOMMENDED
|
||||
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:[NSArray class]]) {
|
||||
if (completion) completion(nil, [self kb_invalidResponseError]);
|
||||
return;
|
||||
}
|
||||
NSArray<KBShopThemeModel *> *list = [KBShopThemeModel mj_objectArrayWithKeyValuesArray:(NSArray *)dataObj];
|
||||
if (completion) completion(list, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
- (id)kb_themeIdParamFromString:(NSString *)themeId {
|
||||
if (themeId.length == 0) { return @""; }
|
||||
NSNumberFormatter *formatter = [NSNumberFormatter new];
|
||||
|
||||
Reference in New Issue
Block a user