|
@@ -21,7 +21,9 @@
|
|
|
@property (nonatomic, strong) NSArray <ASHomeBannerModel *>*topLinkArr;
|
|
|
|
|
|
@property (nonatomic, assign) BOOL desMoreOpen;
|
|
|
+@property (nonatomic, assign) BOOL canShowMoreBt;
|
|
|
|
|
|
+@property (nonatomic, assign) NSInteger page;
|
|
|
|
|
|
|
|
|
|
|
@@ -43,14 +45,14 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
-
|
|
|
+ self.currentSortType = 2;
|
|
|
self.desMoreOpen = false;
|
|
|
[self loadSubVs];
|
|
|
[self loasActiveDataAndV];
|
|
|
self.vm = [ASProductListViewModel new];
|
|
|
[self.collectV reloadData];
|
|
|
|
|
|
-
|
|
|
+ [self.collectV.mj_header beginRefreshing];
|
|
|
|
|
|
}
|
|
|
|
|
@@ -85,6 +87,17 @@
|
|
|
}];
|
|
|
self.menuFilterV.hidden = true;
|
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ self.collectV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
|
+ weakSelf.page = 1;
|
|
|
+ [weakSelf.collectV.mj_footer resetNoMoreData];
|
|
|
+ [weakSelf getNetData];
|
|
|
+ }];
|
|
|
+ self.collectV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
|
|
|
+ weakSelf.page += 1;
|
|
|
+ [weakSelf getNetData];
|
|
|
+ }];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)loasActiveDataAndV {
|
|
@@ -98,6 +111,9 @@
|
|
|
[self.collectV reloadData];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// MARK: - delegate datasource
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
@@ -106,38 +122,45 @@
|
|
|
|
|
|
// MARK: - UICollectionViewDataSource
|
|
|
- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
|
|
- if (indexPath.section == 2 && indexPath.row == 0) {
|
|
|
- ASProductListImageCell *c = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASProductListImageCell" forIndexPath:indexPath];
|
|
|
- [c setImgStr:@"https://img1.baidu.com/it/u=3005611618,1188581709&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=313"];
|
|
|
- return c;
|
|
|
- }
|
|
|
- if (indexPath.section == 3 && indexPath.item == 0)
|
|
|
- {
|
|
|
- ASMoreBtCell *btCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASMoreBtCell" forIndexPath:indexPath];
|
|
|
- return btCell;
|
|
|
- }
|
|
|
-
|
|
|
- if (indexPath.section == 3 && indexPath.item == 1)
|
|
|
- {
|
|
|
- ASProductListTypeDesCell *desCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASProductListTypeDesCell" forIndexPath:indexPath];
|
|
|
- [desCell setData:@"LONG WIGS" des:@"Asteria Hair offers long length wigs with different hair colors and styles, find long lace front wig, long black hair wigs, long blonde wigs you’ve been dreaming of, long straight wig and long curly hair lace front wigs are featured, go shopping and find t" moreStatus:self.desMoreOpen];
|
|
|
- desCell.moreStatusChange = ^{
|
|
|
- self.desMoreOpen = !self.desMoreOpen;
|
|
|
- [self.collectV reloadData];
|
|
|
- };
|
|
|
- return desCell;
|
|
|
+ switch (indexPath.section) {
|
|
|
+ case 3:{
|
|
|
+ if (self.canShowMoreBt) {
|
|
|
+ if (indexPath.row == 0) {
|
|
|
+ ASMoreBtCell *btCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASMoreBtCell" forIndexPath:indexPath];
|
|
|
+ return btCell;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ASProductListTypeDesCell *desCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASProductListTypeDesCell" forIndexPath:indexPath];
|
|
|
+ [desCell setData:self.vm.cateModel.name des:self.vm.cateModel.meta_description moreStatus:self.desMoreOpen];
|
|
|
+ desCell.moreStatusChange = ^{
|
|
|
+ self.desMoreOpen = !self.desMoreOpen;
|
|
|
+ [self.collectV reloadData];
|
|
|
+ };
|
|
|
+ return desCell;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ default: {
|
|
|
+ if (indexPath.row == 0 && self.vm.cateModel.image.length > 0) {
|
|
|
+ ASProductListImageCell *c = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASProductListImageCell" forIndexPath:indexPath];
|
|
|
+ [c setImgStr:[NSString stringWithFormat:@"https://%@%@%@",HostPath, CategoryImgPath, self.vm.cateModel.image]];
|
|
|
+ return c;
|
|
|
+
|
|
|
+ }
|
|
|
+ HomeFlashDealSubCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeFlashDealSubCollectCell" forIndexPath:indexPath];
|
|
|
+ NSInteger tempOff = self.vm.cateModel.image.length > 0 ? 1 : 0;
|
|
|
+ if (self.vm.productList.count <= indexPath.row-tempOff)
|
|
|
+ {
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+
|
|
|
+ ASProductBaseModel *m = self.vm.productList[indexPath.row-tempOff];
|
|
|
+ cell.model = m;
|
|
|
+ cell.contView.addCartBt.hidden = false;
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- HomeFlashDealSubCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeFlashDealSubCollectCell" forIndexPath:indexPath];
|
|
|
- if (self.vm.productList.count <= indexPath.row-1)
|
|
|
- {
|
|
|
- return cell;
|
|
|
- }
|
|
|
-
|
|
|
- ASProductBaseModel *m = self.vm.productList[indexPath.row-1];
|
|
|
- cell.model = m;
|
|
|
- cell.contView.addCartBt.hidden = true;
|
|
|
- return cell;
|
|
|
}
|
|
|
|
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
|
|
@@ -149,9 +172,16 @@
|
|
|
return 0;
|
|
|
}
|
|
|
if (section == 3) {
|
|
|
- return 2;
|
|
|
+ NSInteger count = 0;
|
|
|
+ if (self.canShowMoreBt) {
|
|
|
+ count += 1;
|
|
|
+ }
|
|
|
+ if (self.vm.cateModel != nil && self.vm.cateModel.meta_description.length > 0) {
|
|
|
+ count += 1;
|
|
|
+ }
|
|
|
+ return count;
|
|
|
}
|
|
|
- return self.vm.productList.count + 1;
|
|
|
+ return self.vm.productList.count + (self.vm.cateModel.image.length > 0 ? 1 : 0);
|
|
|
}
|
|
|
|
|
|
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
|
|
@@ -200,29 +230,44 @@
|
|
|
}
|
|
|
|
|
|
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
- if (indexPath.row == 0) {
|
|
|
- CGFloat w = KScreenWidth-20;
|
|
|
- CGFloat collH = w/355.0*118;
|
|
|
- return CGSizeMake(w, collH);;
|
|
|
- }
|
|
|
- if (indexPath.section == 3 && indexPath.item == 1) {
|
|
|
- if (!self.desMoreOpen) {
|
|
|
- return CGSizeMake(KScreenWidth-20, 35+60+24);
|
|
|
+ switch (indexPath.section) {
|
|
|
+ case 3:{
|
|
|
+ if (self.canShowMoreBt) {
|
|
|
+ if (indexPath.row == 0) {
|
|
|
+ return CGSizeMake(KScreenWidth-20, 20+36+50);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!self.desMoreOpen) {
|
|
|
+ return CGSizeMake(KScreenWidth-20, 35+60+24);
|
|
|
+ }
|
|
|
+ //设置行间距
|
|
|
+ NSMutableParagraphStyle *paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
|
|
|
+ [paragraphStyle1 setLineSpacing:12];
|
|
|
+ CGFloat h = [self.vm.cateModel.meta_description boundingRectWithSize:CGSizeMake(KScreenWidth-10-35, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSParagraphStyleAttributeName : paragraphStyle1} context:nil].size.height;
|
|
|
+ return CGSizeMake(KScreenWidth-20, 35+60+(h > 24 ? h : 24));
|
|
|
+ }
|
|
|
+ case 2: {
|
|
|
+ if (indexPath.row == 0 && self.vm.cateModel.image.length > 0) {
|
|
|
+ CGFloat w = KScreenWidth-20;
|
|
|
+ CGFloat collH = w/355.0*118;
|
|
|
+ return CGSizeMake(w, collH);
|
|
|
+ }
|
|
|
+ CGFloat marg = 10;
|
|
|
+ CGFloat w = (KScreenWidth-3*marg)/2;
|
|
|
+ CGFloat collH = (KScreenWidth-30)/2 + productHWithOutImg;
|
|
|
+ return CGSizeMake(w, collH);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ default:{
|
|
|
+ CGFloat marg = 10;
|
|
|
+ CGFloat w = (KScreenWidth-3*marg)/2;
|
|
|
+ CGFloat collH = (KScreenWidth-30)/2 + productHWithOutImg;
|
|
|
+ return CGSizeMake(w, collH);
|
|
|
}
|
|
|
- //设置行间距
|
|
|
- NSMutableParagraphStyle *paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
|
|
|
- [paragraphStyle1 setLineSpacing:12];
|
|
|
- CGFloat h = [@"Asteria Hair offers long length wigs with different hair colors and styles, find long lace front wig, long black hair wigs, long blonde wigs you’ve been dreaming of, long straight wig and long curly hair lace front wigs are featured, go shopping and find t" boundingRectWithSize:CGSizeMake(KScreenWidth-10-35, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSParagraphStyleAttributeName : paragraphStyle1} context:nil].size.height;
|
|
|
- return CGSizeMake(KScreenWidth-20, 35+60+(h > 24 ? h : 24));
|
|
|
- }
|
|
|
-
|
|
|
- if (indexPath.section == 3 && indexPath.item == 0) {
|
|
|
- return CGSizeMake(KScreenWidth-20, 20+36+50);
|
|
|
}
|
|
|
- CGFloat marg = 10;
|
|
|
- CGFloat w = (KScreenWidth-3*marg)/2;
|
|
|
- CGFloat collH = (KScreenWidth-30)/2 + productHWithOutImg;
|
|
|
- return CGSizeMake(w, collH);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
|
|
@@ -296,7 +341,7 @@
|
|
|
[v setSelectIndex:^(NSInteger index) {
|
|
|
weakself.currentSortType = index;
|
|
|
[weakself.collectV reloadData];
|
|
|
-// [weakself.collectV.mj_header beginRefreshing];
|
|
|
+ [weakself.collectV.mj_header beginRefreshing];
|
|
|
}];
|
|
|
_sortTypeV = v;
|
|
|
}
|
|
@@ -312,8 +357,25 @@
|
|
|
[self.menuFilterV showAnimate:self.vm.selectDic];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+-(void)getNetData {
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:true];
|
|
|
+
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ [self.vm getProductListData:self.type page:self.page orderBy:self.currentSortType dir:@"DESC" com:^(BOOL hasNext, NSString * _Nonnull msg) {
|
|
|
+ [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
|
|
|
+ [weakSelf.collectV.mj_header endRefreshing];
|
|
|
+ [weakSelf.collectV.mj_footer endRefreshing];
|
|
|
+ weakSelf.canShowMoreBt = true;
|
|
|
+ if (!hasNext) {
|
|
|
+ weakSelf.canShowMoreBt = false;
|
|
|
+ [weakSelf.collectV.mj_footer endRefreshingWithNoMoreData];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self.collectV reloadData];
|
|
|
+ if (!msg.isEmpty) {
|
|
|
+ [weakSelf.view makeToast:msg];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+}
|
|
|
|
|
|
@end
|