1
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
#define API_THEME_DETAIL @"/themes/detail" // 查询主题详情
|
#define API_THEME_DETAIL @"/themes/detail" // 查询主题详情
|
||||||
#define API_THEME_PURCHASE @"/themes/purchase" // 购买主题
|
#define API_THEME_PURCHASE @"/themes/purchase" // 购买主题
|
||||||
#define API_THEME_DOWNLOAD @"/themes/download" // 主题下载信息
|
#define API_THEME_DOWNLOAD @"/themes/download" // 主题下载信息
|
||||||
|
#define API_THEME_RECOMMENDED @"/themes/recommended" // 推荐主题列表
|
||||||
|
|
||||||
/// pay
|
/// pay
|
||||||
#define API_VALIDATE_RECEIPT @"/api/apple/validate-receipt" // 排行榜标签列表
|
#define API_VALIDATE_RECEIPT @"/api/apple/validate-receipt" // 排行榜标签列表
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
|||||||
[KBHUD show];
|
[KBHUD show];
|
||||||
}
|
}
|
||||||
__weak typeof(self) weakSelf = self;
|
__weak typeof(self) weakSelf = self;
|
||||||
[self.shopVM fetchWalletBalanceWithCompletion:^(NSNumber * _Nullable balance, NSError * _Nullable error) {
|
[self.shopVM fetchWalletBalanceWithCompletion:^(NSString * _Nullable balance, NSError * _Nullable error) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (showHUD) {
|
if (showHUD) {
|
||||||
[KBHUD dismiss];
|
[KBHUD dismiss];
|
||||||
@@ -289,9 +289,9 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
|||||||
[KBHUD showInfo:msg];
|
[KBHUD showInfo:msg];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double amountValue = balance.doubleValue;
|
// double amountValue = balance.doubleValue;
|
||||||
NSString *amountString = [NSString stringWithFormat:@"%.2f", amountValue];
|
// NSString *amountString = [NSString stringWithFormat:@"%.2f", amountValue];
|
||||||
[weakSelf.userHeaderView updatePoints:amountString];
|
[weakSelf.userHeaderView updatePoints:balance];
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#import "KBSkinBottomActionView.h"
|
#import "KBSkinBottomActionView.h"
|
||||||
#import "KBShopVM.h"
|
#import "KBShopVM.h"
|
||||||
#import "KBShopThemeTagModel.h"
|
#import "KBShopThemeTagModel.h"
|
||||||
|
#import "KBShopThemeModel.h"
|
||||||
#import "KBHUD.h"
|
#import "KBHUD.h"
|
||||||
#import "KBSkinService.h"
|
#import "KBSkinService.h"
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
@property (nonatomic, strong) UICollectionView *collectionView; // 主列表
|
@property (nonatomic, strong) UICollectionView *collectionView; // 主列表
|
||||||
@property (nonatomic, strong) KBSkinBottomActionView *bottomBar; // 底部操作条
|
@property (nonatomic, strong) KBSkinBottomActionView *bottomBar; // 底部操作条
|
||||||
@property (nonatomic, copy) NSArray<NSString *> *tags; // 标签数据
|
@property (nonatomic, copy) NSArray<NSString *> *tags; // 标签数据
|
||||||
@property (nonatomic, copy) NSArray<NSDictionary *> *gridData; // 底部网格数据
|
@property (nonatomic, copy) NSArray<KBShopThemeModel *> *recommendedThemes; // 底部网格数据
|
||||||
@property (nonatomic, strong) KBShopVM *shopVM;
|
@property (nonatomic, strong) KBShopVM *shopVM;
|
||||||
@property (nonatomic, strong, nullable) KBShopThemeDetailModel *detailModel;
|
@property (nonatomic, strong, nullable) KBShopThemeDetailModel *detailModel;
|
||||||
//@property (nonatomic, assign) BOOL isProcessingAction;
|
//@property (nonatomic, assign) BOOL isProcessingAction;
|
||||||
@@ -46,11 +47,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
self.view.backgroundColor = [UIColor whiteColor];
|
self.view.backgroundColor = [UIColor whiteColor];
|
||||||
|
|
||||||
self.tags = @[];
|
self.tags = @[];
|
||||||
self.gridData = @[
|
self.recommendedThemes = @[];
|
||||||
@{ @"title": @"Dopamine" }, @{ @"title": @"Dopamine" },
|
|
||||||
@{ @"title": @"Dopamine" }, @{ @"title": @"Dopamine" },
|
|
||||||
@{ @"title": @"Dopamine" }, @{ @"title": @"Dopamine" },
|
|
||||||
];
|
|
||||||
|
|
||||||
// 1. 列表
|
// 1. 列表
|
||||||
[self.view addSubview:self.collectionView];
|
[self.view addSubview:self.collectionView];
|
||||||
@@ -74,6 +71,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
|
|
||||||
[self updateBottomBarAppearance];
|
[self updateBottomBarAppearance];
|
||||||
[self fetchThemeDetailIfNeeded];
|
[self fetchThemeDetailIfNeeded];
|
||||||
|
[self fetchRecommendedThemes];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - UICollectionView DataSource
|
#pragma mark - UICollectionView DataSource
|
||||||
@@ -87,7 +85,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
case KBSkinDetailSectionHeader: return 1; // 顶部大卡片
|
case KBSkinDetailSectionHeader: return 1; // 顶部大卡片
|
||||||
case KBSkinDetailSectionTags: return self.tags.count > 0 ? 1 : 0;
|
case KBSkinDetailSectionTags: return self.tags.count > 0 ? 1 : 0;
|
||||||
case KBSkinDetailSectionTitle: return 1; // 标题
|
case KBSkinDetailSectionTitle: return 1; // 标题
|
||||||
case KBSkinDetailSectionGrid: return self.gridData.count; // 2 列网格
|
case KBSkinDetailSectionGrid: return self.recommendedThemes.count; // 2 列网格
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -111,8 +109,11 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
}
|
}
|
||||||
case KBSkinDetailSectionGrid: {
|
case KBSkinDetailSectionGrid: {
|
||||||
KBSkinCardCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kGridCellId forIndexPath:indexPath];
|
KBSkinCardCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kGridCellId forIndexPath:indexPath];
|
||||||
NSDictionary *d = self.gridData[indexPath.item];
|
KBShopThemeModel *model = self.recommendedThemes[indexPath.item];
|
||||||
[cell configWithTitle:d[@"title"] imageURL:nil price:@"20"];
|
NSString *priceText = [self priceTextForTheme:model];
|
||||||
|
[cell configWithTitle:model.themeName ?: @""
|
||||||
|
imageURL:model.themePreviewImageUrl
|
||||||
|
price:priceText];
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,4 +331,31 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
return _shopVM;
|
return _shopVM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Data
|
||||||
|
|
||||||
|
- (void)fetchRecommendedThemes {
|
||||||
|
__weak typeof(self) weakSelf = self;
|
||||||
|
[self.shopVM fetchRecommendedThemesWithCompletion:^(NSArray<KBShopThemeModel *> * _Nullable themes, NSError * _Nullable error) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"[KBSkinDetailVC] fetch recommended failed: %@", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
weakSelf.recommendedThemes = themes ?: @[];
|
||||||
|
NSIndexSet *sections = [NSIndexSet indexSetWithIndex:KBSkinDetailSectionGrid];
|
||||||
|
[weakSelf.collectionView reloadSections:sections];
|
||||||
|
});
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)priceTextForTheme:(KBShopThemeModel *)model {
|
||||||
|
// if (model.isFree) {
|
||||||
|
// return KBLocalized(@"Free");
|
||||||
|
// }
|
||||||
|
if (model.themePrice > 0.0) {
|
||||||
|
return [NSString stringWithFormat:@"%.2f", model.themePrice];
|
||||||
|
}
|
||||||
|
return @"0";
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ typedef void(^KBShopStylesCompletion)(NSArray<KBShopStyleModel *> *_Nullable sty
|
|||||||
NSError *_Nullable error);
|
NSError *_Nullable error);
|
||||||
typedef void(^KBShopThemesCompletion)(NSArray<KBShopThemeModel *> *_Nullable themes,
|
typedef void(^KBShopThemesCompletion)(NSArray<KBShopThemeModel *> *_Nullable themes,
|
||||||
NSError *_Nullable error);
|
NSError *_Nullable error);
|
||||||
typedef void(^KBShopBalanceCompletion)(NSNumber *_Nullable balance,
|
typedef void(^KBShopBalanceCompletion)(NSString *_Nullable balance,
|
||||||
NSError *_Nullable error);
|
NSError *_Nullable error);
|
||||||
typedef void(^KBShopDetailCompletion)(KBShopThemeDetailModel *_Nullable detail,
|
typedef void(^KBShopDetailCompletion)(KBShopThemeDetailModel *_Nullable detail,
|
||||||
NSError *_Nullable error);
|
NSError *_Nullable error);
|
||||||
@@ -53,6 +53,9 @@ typedef void(^KBShopDownloadInfoCompletion)(NSDictionary *_Nullable info,
|
|||||||
- (void)fetchThemeDownloadInfoWithId:(nullable NSString *)themeId
|
- (void)fetchThemeDownloadInfoWithId:(nullable NSString *)themeId
|
||||||
completion:(KBShopDownloadInfoCompletion)completion;
|
completion:(KBShopDownloadInfoCompletion)completion;
|
||||||
|
|
||||||
|
/// 推荐主题列表(用于皮肤详情页底部网格)
|
||||||
|
- (void)fetchRecommendedThemesWithCompletion:(KBShopThemesCompletion)completion;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@@ -100,17 +100,9 @@
|
|||||||
if (completion) completion(nil, [self kb_invalidResponseError]);
|
if (completion) completion(nil, [self kb_invalidResponseError]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
id balanceValue = dataObj[@"balance"];
|
NSString * balanceValue = dataObj[@"balanceDisplay"];
|
||||||
NSNumber *balanceNumber = nil;
|
|
||||||
if ([balanceValue isKindOfClass:[NSNumber class]]) {
|
if (completion) completion(balanceValue, nil);
|
||||||
balanceNumber = balanceValue;
|
|
||||||
} else if ([balanceValue isKindOfClass:[NSString class]]) {
|
|
||||||
balanceNumber = @([(NSString *)balanceValue doubleValue]);
|
|
||||||
}
|
|
||||||
if (!balanceNumber) {
|
|
||||||
balanceNumber = @(0);
|
|
||||||
}
|
|
||||||
if (completion) completion(balanceNumber, 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 {
|
- (id)kb_themeIdParamFromString:(NSString *)themeId {
|
||||||
if (themeId.length == 0) { return @""; }
|
if (themeId.length == 0) { return @""; }
|
||||||
NSNumberFormatter *formatter = [NSNumberFormatter new];
|
NSNumberFormatter *formatter = [NSNumberFormatter new];
|
||||||
|
|||||||
Reference in New Issue
Block a user