// // ASGoodsDetailsTableView.m // Asteria // // Created by xingyu on 2024/5/17. // #import "ASGoodsDetailsTableView.h" //#import "GoodsReviewsListM.h" #import "ASGoodsBannerCell.h" #import "ASGoodsDetailsSizeCell.h" #import "ASGoodsCouponCell.h" #import "ASGoodsTitlePriceCell.h" #import "ASGoodsGuaranteeInfoCell.h" #import "ASGoodsReviewHeadCell.h" #import "GoodsReviewsCell.h" #import "ASGoodsReviewFootCell.h" @interface ASGoodsDetailsTableView() @property (nonatomic, assign) BOOL couponSelect; @end @implementation ASGoodsDetailsTableView - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSObject *dataM = self.infodata[indexPath.row]; NSObject *objectM = nil; NSString *typeStr = @""; if ([dataM isKindOfClass:[NSDictionary class]]) { NSDictionary *dataDic = (NSDictionary *)dataM; objectM = [dataDic objectForKey:@"data"]; typeStr = [dataDic objectForKey:@"type"]; } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) { objectM = dataM; } if ([typeStr isEqualToString:@"banner"]) { ASGoodsBannerCell *cell = [ASGoodsBannerCell cellWithTableView:tableView CellClass:[ASGoodsBannerCell class]]; [cell configData:(GoodsInformationM *)objectM]; return cell; } else if ([typeStr isEqualToString:@"titlePrice"]) { ASGoodsTitlePriceCell *cell = [ASGoodsTitlePriceCell cellWithTableView:tableView CellClass:[ASGoodsTitlePriceCell class]]; [cell configData:(GoodsInformationM *)objectM]; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) [self generaltriggermethodType:type data:Data]; }; return cell; } else if ([typeStr isEqualToString:@"coupon"]) { ASGoodsCouponCell *cell = [ASGoodsCouponCell cellWithTableView:tableView CellClass:[ASGoodsCouponCell class]]; [cell configData:(GoodsInformationM *)objectM isSelect:self.couponSelect]; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) self.couponSelect = type; [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; }; return cell; } else if ([typeStr isEqualToString:@"size"]) { ASGoodsDetailsSizeCell *cell = [ASGoodsDetailsSizeCell cellWithTableView:tableView CellClass:[ASGoodsDetailsSizeCell class]]; [cell configData:(GoodsInformationM *)objectM]; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) [self generaltriggermethodType:type data:Data]; }; return cell; } else if ([typeStr isEqualToString:@"guarantee"]) { ASGoodsGuaranteeInfoCell *cell = [ASGoodsGuaranteeInfoCell cellWithTableView:tableView CellClass:[ASGoodsGuaranteeInfoCell class]]; [cell configData:(GoodsInformationM *)objectM]; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) [self generaltriggermethodType:type data:Data]; }; return cell; } else if ([typeStr isEqualToString:@"reviewHead"]) { ASGoodsReviewHeadCell *cell = [ASGoodsReviewHeadCell cellWithTableView:tableView CellClass:[ASGoodsReviewHeadCell class]]; cell.clipsToBounds = YES; [cell configData:(GoodsInformationM *)objectM]; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) [self generaltriggermethodType:type data:Data]; }; return cell; } else if ([objectM isKindOfClass:[GoodsReviewsListM class]]) { // GoodsReviewsListM *objectM = self.infodata[indexPath.row]; GoodsReviewsCell *cell = [GoodsReviewsCell cellWithTableView:tableView CellClass:[GoodsReviewsCell class]]; cell.clipsToBounds = YES; [cell configData:objectM]; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) //图片选择器展示 }; return cell; } else if ([typeStr isEqualToString:@"reviewFoot"]) { // GoodsReviewsListM *objectM = self.infodata[indexPath.row]; ASGoodsReviewFootCell *cell = [ASGoodsReviewFootCell cellWithTableView:tableView CellClass:[ASGoodsReviewFootCell class]]; cell.clipsToBounds = YES; @weakify(self) cell.currencyparameterClose = ^(NSInteger type, id Data) { @strongify(self) [self generaltriggermethodType:type data:Data]; }; return cell; } return nil; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSObject *dataM = self.infodata[indexPath.row]; NSObject *objectM = nil; NSString *typeStr = @""; if ([dataM isKindOfClass:[NSDictionary class]]) { NSDictionary *dataDic = (NSDictionary *)dataM; objectM = [dataDic objectForKey:@"data"]; typeStr = [dataDic objectForKey:@"type"]; } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) { objectM = dataM; } if (([typeStr isEqualToString:@"reviewHead"] || [objectM isKindOfClass:[GoodsReviewsListM class]] || [typeStr isEqualToString:@"reviewFoot"]) && !self.isReview) { return 0; } return UITableViewAutomaticDimension; } - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 200; } @end