|
@@ -25,7 +25,6 @@
|
|
@property (nonatomic, strong) ASHomeViewModel *vm;
|
|
@property (nonatomic, strong) ASHomeViewModel *vm;
|
|
|
|
|
|
@property (nonatomic, strong) UITableView *tableV;
|
|
@property (nonatomic, strong) UITableView *tableV;
|
|
-@property (nonatomic, strong) NSArray <ASHomeMainListModel*>*listArr;
|
|
|
|
|
|
|
|
@property (nonatomic, strong, nullable) ASHomeActiveView *activeV;
|
|
@property (nonatomic, strong, nullable) ASHomeActiveView *activeV;
|
|
|
|
|
|
@@ -43,17 +42,12 @@
|
|
// TODO: 跳转搜索模块
|
|
// TODO: 跳转搜索模块
|
|
}];
|
|
}];
|
|
[self addSubV];
|
|
[self addSubV];
|
|
- [self demoData];
|
|
|
|
[self.tableV.mj_header beginRefreshing];
|
|
[self.tableV.mj_header beginRefreshing];
|
|
|
|
|
|
[self updateTopLinkData];
|
|
[self updateTopLinkData];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-- (void)demoData {
|
|
|
|
- _listArr = [ASHomeMainListModel homeDemoDatas];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
- (void)getTopLinkData {
|
|
- (void)getTopLinkData {
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
[self.topVm getTopLinkList:^{
|
|
[self.topVm getTopLinkList:^{
|
|
@@ -61,6 +55,14 @@
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)getHomeListData {
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
+ [self.vm getHomeListData:^{
|
|
|
|
+ [weakSelf.tableV.mj_header endRefreshing];
|
|
|
|
+ [weakSelf.tableV reloadData];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
- (void)getHomeTopData {
|
|
- (void)getHomeTopData {
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
[self.vm getHomeTopData:^{
|
|
[self.vm getHomeTopData:^{
|
|
@@ -71,8 +73,10 @@
|
|
- (void)updateTopLinkData {
|
|
- (void)updateTopLinkData {
|
|
if (self.topVm.topLinks.count > 0) {
|
|
if (self.topVm.topLinks.count > 0) {
|
|
self.activeV = [[ASHomeActiveView alloc] initWithFrame:CGRectZero];
|
|
self.activeV = [[ASHomeActiveView alloc] initWithFrame:CGRectZero];
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
[self.activeV setTapTopBlock:^(KWSearchHotKeyModel * _Nullable m) {
|
|
[self.activeV setTapTopBlock:^(KWSearchHotKeyModel * _Nullable m) {
|
|
NSLog(@"---toplink:-%@--", m.code);
|
|
NSLog(@"---toplink:-%@--", m.code);
|
|
|
|
+ [weakSelf jumpWithModel:[m toJumpM]];
|
|
}];
|
|
}];
|
|
self.tableV.tableHeaderView = self.activeV;
|
|
self.tableV.tableHeaderView = self.activeV;
|
|
[self.activeV setTopData:self.topVm.topLinks];
|
|
[self.activeV setTopData:self.topVm.topLinks];
|
|
@@ -95,12 +99,8 @@
|
|
self.tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
self.tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
[weakSelf getTopLinkData];
|
|
[weakSelf getTopLinkData];
|
|
[weakSelf getHomeTopData];
|
|
[weakSelf getHomeTopData];
|
|
|
|
+ [weakSelf getHomeListData];
|
|
|
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1), dispatch_get_main_queue(), ^{
|
|
|
|
-
|
|
|
|
- [self.tableV.mj_header endRefreshing];
|
|
|
|
- [self.tableV reloadData];
|
|
|
|
- });
|
|
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -117,7 +117,7 @@
|
|
// MARK: - UITableViewDataSource
|
|
// MARK: - UITableViewDataSource
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
{
|
|
{
|
|
- return self.listArr.count + 2;
|
|
|
|
|
|
+ return self.vm.listData.count + 3;
|
|
}
|
|
}
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
@@ -130,9 +130,43 @@
|
|
case 1:// category
|
|
case 1:// category
|
|
return self.vm.categorys.count > 0 ? 1 : 0;
|
|
return self.vm.categorys.count > 0 ? 1 : 0;
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+ case 2:// tips
|
|
|
|
+ return 1;
|
|
default:
|
|
default:
|
|
|
|
+ {
|
|
|
|
+ if (self.vm.listData.count < section-3) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ ASHomeMainListModel *m = self.vm.listData[section-3];
|
|
|
|
+ NSInteger showtype = m.showType;
|
|
|
|
+ switch (showtype) {
|
|
|
|
+ case 1:// best seller
|
|
|
|
+ return m.productList.count > 0 ? 1 : 0;
|
|
|
|
+ case 2:// new in
|
|
|
|
+ return m.productList.count > 0 ? 1 : 0;
|
|
|
|
+ case 3://
|
|
|
|
+ return m.imgUrl.length > 0 ? 1 : 0;
|
|
|
|
+ case 4:// New Arrivals
|
|
|
|
+ return m.productList.count > 0 ? 1 : 0;
|
|
|
|
+ case 5:// 单图活动
|
|
|
|
+ return m.imgUrl.length > 0 ? 1 : 0;
|
|
|
|
+ case 6:// shop by looking
|
|
|
|
+ return m.titleArr.count > 0 ? 1 : 0;
|
|
|
|
+ case 7:// memship
|
|
|
|
+ return m.imgUrl.length > 0 ? 1 : 0;
|
|
|
|
+// case 8:// video Active
|
|
|
|
+// return m.videoUrl.length > 0 ? 1 : 0;
|
|
|
|
+// case 9:// You may also like
|
|
|
|
+// return m.productList.count > 0 ? 1 : 0;
|
|
|
|
+// case 10:// today deals
|
|
|
|
+// return m.productList.count > 0 ? 1 : 0;
|
|
|
|
+// case 11: // 带背景色和图片的 cycle cell
|
|
|
|
+// return m.productList.count > 0 ? 1 : 0;
|
|
|
|
+ default:
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
return 1;
|
|
return 1;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@@ -161,53 +195,74 @@
|
|
};
|
|
};
|
|
return cell;
|
|
return cell;
|
|
}
|
|
}
|
|
- if (self.listArr.count <= indexPath.row) {
|
|
|
|
|
|
+ if (indexPath.section == 2) {
|
|
|
|
+ ASHomeTipCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeTipCell" forIndexPath:indexPath];
|
|
|
|
+ return cell;
|
|
|
|
+ }
|
|
|
|
+ if (self.vm.listData.count <= indexPath.section-3) {
|
|
return [UITableViewCell new];
|
|
return [UITableViewCell new];
|
|
}
|
|
}
|
|
- ASHomeMainListModel *m = self.listArr[indexPath.section-1];
|
|
|
|
|
|
+ ASHomeMainListModel *m = self.vm.listData[indexPath.section-3];
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
switch (m.showType) {
|
|
switch (m.showType) {
|
|
- case 1: { // 分类
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- case 2: { // tips
|
|
|
|
- ASHomeTipCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeTipCell" forIndexPath:indexPath];
|
|
|
|
- return cell;
|
|
|
|
- }
|
|
|
|
- case 3: {// bestSell
|
|
|
|
|
|
+ case 1: {// bestSell
|
|
ASHomeBestSellCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeBestSellCell" forIndexPath:indexPath];
|
|
ASHomeBestSellCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeBestSellCell" forIndexPath:indexPath];
|
|
cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
|
|
cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
|
|
|
|
+ [weakSelf goto_WKM_GoodsDetailsC:m.Id];
|
|
};
|
|
};
|
|
cell.model = m;
|
|
cell.model = m;
|
|
return cell;
|
|
return cell;
|
|
}
|
|
}
|
|
- case 4: {
|
|
|
|
|
|
+ case 2: {
|
|
ASHomeNewInCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeNewInCellTableViewCell" forIndexPath:indexPath];
|
|
ASHomeNewInCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeNewInCellTableViewCell" forIndexPath:indexPath];
|
|
|
|
+ cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
|
|
|
|
+ [weakSelf goto_WKM_GoodsDetailsC: model.Id];
|
|
|
|
+ };
|
|
|
|
+ cell.addCartBlock = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
|
|
|
|
+ [weakSelf action_GoodsSizeC: model.Id];
|
|
|
|
+ };
|
|
[cell setData:m];
|
|
[cell setData:m];
|
|
return cell;
|
|
return cell;
|
|
}
|
|
}
|
|
|
|
+ case 3: {
|
|
|
|
+ ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
|
|
|
|
+ cell.tapImgBlock = ^{
|
|
|
|
+ [weakSelf jumpWithModel:[m toJumpM]];
|
|
|
|
+ };
|
|
|
|
+ [cell setImgStr:m.imgUrl];
|
|
|
|
+ return cell;
|
|
|
|
+ }
|
|
case 5: {
|
|
case 5: {
|
|
ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
|
|
ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
|
|
cell.tapImgBlock = ^{
|
|
cell.tapImgBlock = ^{
|
|
- // TODO: -
|
|
|
|
|
|
+ [weakSelf jumpWithModel:[m toJumpM]];
|
|
};
|
|
};
|
|
[cell setImgStr:m.imgUrl];
|
|
[cell setImgStr:m.imgUrl];
|
|
return cell;
|
|
return cell;
|
|
}
|
|
}
|
|
- case 6: {
|
|
|
|
|
|
+ case 7: {
|
|
|
|
+ ASHomeImgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeImgCell" forIndexPath:indexPath];
|
|
|
|
+ cell.tapImgBlock = ^{
|
|
|
|
+ [weakSelf jumpWithModel:[m toJumpM]];
|
|
|
|
+ };
|
|
|
|
+ [cell setImgStr:m.imgUrl];
|
|
|
|
+ return cell;
|
|
|
|
+ }
|
|
|
|
+ case 4: {
|
|
ASHomeFlashDealCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeFlashDealCell" forIndexPath:indexPath];
|
|
ASHomeFlashDealCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeFlashDealCell" forIndexPath:indexPath];
|
|
- cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
|
|
|
|
-
|
|
|
|
|
|
+ cell.productClick = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
|
|
|
|
+ [weakSelf goto_WKM_GoodsDetailsC:model.Id];
|
|
};
|
|
};
|
|
- cell.proAddCartClick = ^(NSInteger i, ASProductBaseModel * _Nonnull m) {
|
|
|
|
-
|
|
|
|
|
|
+ cell.proAddCartClick = ^(NSInteger i, ASProductBaseModel * _Nonnull model) {
|
|
|
|
+ [weakSelf action_GoodsSizeC:model.Id];
|
|
};
|
|
};
|
|
cell.model = m;
|
|
cell.model = m;
|
|
return cell;
|
|
return cell;
|
|
}
|
|
}
|
|
- case 7: {
|
|
|
|
|
|
+ case 6: {
|
|
ASHomeLookingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeLookingCell" forIndexPath:indexPath];
|
|
ASHomeLookingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASHomeLookingCell" forIndexPath:indexPath];
|
|
- cell.itemClick = ^(NSInteger i, ASHomeCategoryModel * _Nonnull m) {
|
|
|
|
-
|
|
|
|
|
|
+ cell.itemClick = ^(NSInteger i, ASHomeCategoryModel * _Nonnull model) {
|
|
|
|
+ [weakSelf jumpWithModel:[model toJumpM]];
|
|
};
|
|
};
|
|
cell.model = m;
|
|
cell.model = m;
|
|
return cell;
|
|
return cell;
|