|
@@ -9,6 +9,10 @@
|
|
|
#import "XSTTUIGeneralHeader.h"
|
|
|
#import <CALayer+JXHShadow.h>
|
|
|
#import "XSTTBlindBoxDetailsViewController.h"
|
|
|
+#import "XSTTBlindBoxToOrderModel.h"
|
|
|
+#import <UIImageView+WebCache.h>
|
|
|
+#import "UIViewController+XSTTNetworkManager.h"
|
|
|
+#import "XSTTBusinessManager.h"
|
|
|
|
|
|
#define xstt_blindBoxToOrderCellImageHeight ((jxh_screenWidth() - XSTTMargin * 2) * 0.3)
|
|
|
|
|
@@ -95,35 +99,18 @@
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
-- (void)reloadData:(NSIndexPath *)data {
|
|
|
- switch (data.row) {
|
|
|
- case 0:
|
|
|
- _imageView.image = jxh_getImage(列表_入门);
|
|
|
- _title.text = @"入门精酿·盲盒订阅";
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- _imageView.image = jxh_getImage(列表_高端);
|
|
|
- _title.text = @"高端玩家·精酿订阅";
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- _imageView.image = jxh_getImage(列表_酿造);
|
|
|
- _title.text = @"亲自酿造·高级定制";
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- _imageView.image = jxh_getImage(列表_季节);
|
|
|
- _title.text = @"季节尝鲜款·限量订阅";
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- _number.text = @"2023040159期";
|
|
|
- _time.text = @"2023/03/20";
|
|
|
+- (void)reloadData:(XSTTBlindBoxToOrderModel *)data {
|
|
|
+ _title.text = data.xstt_boxName;
|
|
|
+ [_imageView sd_setImageWithURL:[NSURL URLWithString:data.xstt_boxBg]];
|
|
|
+ _number.text = [NSString stringWithFormat:@"%@期",data.xstt_currBoxNo];
|
|
|
+ _time.text = data.xstt_cutOffTime;
|
|
|
}
|
|
|
|
|
|
@end
|
|
|
|
|
|
-@interface XSTTBlindBoxToOrderTableViewController ()
|
|
|
+@interface XSTTBlindBoxToOrderTableViewController () {
|
|
|
+ NSArray<XSTTBlindBoxToOrderModel *> *_dataArray;
|
|
|
+}
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -132,16 +119,48 @@
|
|
|
- (instancetype)init {
|
|
|
self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:XSTTTableViewBackgroundColorWhite];
|
|
|
if (!self) return nil;
|
|
|
+ _dataArray = NSArray.new;
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
[self setUpUI];
|
|
|
+ [self getList];
|
|
|
}
|
|
|
|
|
|
#pragma mark - Action
|
|
|
#pragma mark - Network Action
|
|
|
+- (void)getList {
|
|
|
+ [self networkUseMethod:XSTTNetworkMethodGET loadingTips:XSTTGetDataLoadingCommonTips isLogin:xstt_isLogin() signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(XSTTURLGetBlindBoxList) urlParameters:nil parameters:nil success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ [self getListSuccesss:data];
|
|
|
+ return @"";
|
|
|
+ } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ [self getListFailure:error];
|
|
|
+ return XSTTGetDataFailureCommonTips;
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)getListSuccesss:(id)data {
|
|
|
+ _dataArray = [XSTTBlindBoxToOrderModel getModelListWithArray:data[@"data"]];
|
|
|
+ [self.tableView reloadData];
|
|
|
+ if (_dataArray.count == 0) {
|
|
|
+ [self.tableView setDefaultFootViewWithError:nil image:jxh_getImage(blind_box_default) tips:@"还未开放精酿订购信息" height:jxh_viewHeight(self.view) - jxh_safeInsets(self.view).top - jxh_safeInsets(self.view).bottom action:nil];
|
|
|
+ } else {
|
|
|
+ [self.tableView removeDefaultFootView];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)getListFailure:(NSError *)error {
|
|
|
+ if (_dataArray.count == 0) {
|
|
|
+ @weakify(self)
|
|
|
+ [self.tableView setDefaultFootViewWithError:error image:nil tips:nil height:jxh_viewHeight(self.view) - jxh_safeInsets(self.view).top - jxh_safeInsets(self.view).bottom action:^{
|
|
|
+ @strongify(self)
|
|
|
+ [self getList];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Delegate & DataSource
|
|
|
|
|
|
static NSString * const reuseIdentifier = @"XSTTBlindBoxToOrderTableViewCell";
|
|
@@ -151,12 +170,12 @@ static NSString * const reuseIdentifier = @"XSTTBlindBoxToOrderTableViewCell";
|
|
|
if (!cell) {
|
|
|
cell = [[XSTTBlindBoxToOrderTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
|
|
|
}
|
|
|
- [cell reloadData:indexPath];
|
|
|
+ [cell reloadData:_dataArray[indexPath.row]];
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
- return 10;
|
|
|
+ return _dataArray.count;
|
|
|
}
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
@@ -184,6 +203,7 @@ static NSString * const reuseIdentifier = @"XSTTBlindBoxToOrderTableViewCell";
|
|
|
}
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
|
|
+ if (_dataArray.count == 0) return jxh_onePixe();
|
|
|
return 16;
|
|
|
}
|
|
|
|