ASGoodsDetailsTableView.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //
  2. // ASGoodsDetailsTableView.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/17.
  6. //
  7. #import "ASGoodsDetailsTableView.h"
  8. //#import "GoodsReviewsListM.h"
  9. #import "ASGoodsBannerCell.h"
  10. #import "ASGoodsDetailsSizeCell.h"
  11. #import "ASGoodsCouponCell.h"
  12. #import "ASGoodsTitlePriceCell.h"
  13. #import "ASGoodsGuaranteeInfoCell.h"
  14. #import "ASGoodsReviewHeadCell.h"
  15. #import "GoodsReviewsCell.h"
  16. #import "ASGoodsReviewFootCell.h"
  17. #import "KWMineMoreProductsCell.h"
  18. #import "KWMineMoreProductModel.h"
  19. @interface ASGoodsDetailsTableView()
  20. @property (nonatomic, assign) BOOL couponSelect;
  21. @end
  22. @implementation ASGoodsDetailsTableView
  23. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  24. NSObject *dataM = self.infodata[indexPath.row];
  25. NSObject *objectM = nil;
  26. NSString *typeStr = @"";
  27. if ([dataM isKindOfClass:[NSDictionary class]]) {
  28. NSDictionary *dataDic = (NSDictionary *)dataM;
  29. objectM = [dataDic objectForKey:@"data"];
  30. typeStr = [dataDic objectForKey:@"type"];
  31. } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) {
  32. objectM = dataM;
  33. }
  34. if ([typeStr isEqualToString:@"banner"]) {
  35. ASGoodsBannerCell *cell = [ASGoodsBannerCell cellWithTableView:tableView CellClass:[ASGoodsBannerCell class]];
  36. [cell configData:(GoodsInformationM *)objectM];
  37. return cell;
  38. } else if ([typeStr isEqualToString:@"titlePrice"]) {
  39. ASGoodsTitlePriceCell *cell = [ASGoodsTitlePriceCell cellWithTableView:tableView CellClass:[ASGoodsTitlePriceCell class]];
  40. [cell configData:(GoodsInformationM *)objectM];
  41. @weakify(self)
  42. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  43. @strongify(self)
  44. [self generaltriggermethodType:type data:Data];
  45. };
  46. return cell;
  47. } else if ([typeStr isEqualToString:@"coupon"]) {
  48. ASGoodsCouponCell *cell = [ASGoodsCouponCell cellWithTableView:tableView CellClass:[ASGoodsCouponCell class]];
  49. [cell configData:(GoodsInformationM *)objectM isSelect:self.couponSelect];
  50. @weakify(self)
  51. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  52. @strongify(self)
  53. self.couponSelect = type;
  54. [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  55. };
  56. return cell;
  57. } else if ([typeStr isEqualToString:@"size"]) {
  58. ASGoodsDetailsSizeCell *cell = [ASGoodsDetailsSizeCell cellWithTableView:tableView CellClass:[ASGoodsDetailsSizeCell class]];
  59. @weakify(self)
  60. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  61. @strongify(self)
  62. [self generaltriggermethodType:type data:Data];
  63. };
  64. [cell configData:(GoodsInformationM *)objectM];
  65. return cell;
  66. } else if ([typeStr isEqualToString:@"guarantee"]) {
  67. ASGoodsGuaranteeInfoCell *cell = [ASGoodsGuaranteeInfoCell cellWithTableView:tableView CellClass:[ASGoodsGuaranteeInfoCell class]];
  68. [cell configData:(GoodsInformationM *)objectM];
  69. @weakify(self)
  70. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  71. @strongify(self)
  72. [self generaltriggermethodType:type data:Data];
  73. };
  74. return cell;
  75. } else if ([typeStr isEqualToString:@"reviewHead"]) {
  76. ASGoodsReviewHeadCell *cell = [ASGoodsReviewHeadCell cellWithTableView:tableView CellClass:[ASGoodsReviewHeadCell class]];
  77. cell.clipsToBounds = YES;
  78. [cell configData:(GoodsInformationM *)objectM];
  79. @weakify(self)
  80. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  81. @strongify(self)
  82. [self generaltriggermethodType:type data:Data];
  83. };
  84. return cell;
  85. } else if ([objectM isKindOfClass:[GoodsReviewsListM class]]) {
  86. // GoodsReviewsListM *objectM = self.infodata[indexPath.row];
  87. GoodsReviewsCell *cell = [GoodsReviewsCell cellWithTableView:tableView CellClass:[GoodsReviewsCell class]];
  88. cell.clipsToBounds = YES;
  89. [cell configData:objectM];
  90. @weakify(self)
  91. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  92. @strongify(self) //图片选择器展示
  93. };
  94. return cell;
  95. } else if ([typeStr isEqualToString:@"reviewFoot"]) {
  96. // GoodsReviewsListM *objectM = self.infodata[indexPath.row];
  97. ASGoodsReviewFootCell *cell = [ASGoodsReviewFootCell cellWithTableView:tableView CellClass:[ASGoodsReviewFootCell class]];
  98. cell.clipsToBounds = YES;
  99. @weakify(self)
  100. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  101. @strongify(self)
  102. [self generaltriggermethodType:type data:Data];
  103. };
  104. return cell;
  105. } else if ([typeStr isEqualToString:@"customer"]) {
  106. KWMineMoreProductModel *model = (KWMineMoreProductModel *)objectM;
  107. // KWMineMoreProductsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KWMineMoreProductsCell" forIndexPath:indexPath];
  108. KWMineMoreProductsCell *cell = [[KWMineMoreProductsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KWMineMoreProductsCell"];
  109. cell.topSpace = 20;
  110. // KWMineMoreProductModel * model = [KWMineMoreProductModel demoData];
  111. [cell setData: model];
  112. @weakify(self);
  113. [cell setProductClick:^(NSInteger i, ASProductBaseModel *m) {
  114. // if (![weak_self checkLogin:true]) {
  115. // return;
  116. // }
  117. // 点击推荐商品
  118. // [weak_self goto_WKM_GoodsDetailsC:m.Id];
  119. }];
  120. return cell;
  121. }
  122. return nil;
  123. }
  124. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  125. NSObject *dataM = self.infodata[indexPath.row];
  126. NSObject *objectM = nil;
  127. NSString *typeStr = @"";
  128. if ([dataM isKindOfClass:[NSDictionary class]]) {
  129. NSDictionary *dataDic = (NSDictionary *)dataM;
  130. objectM = [dataDic objectForKey:@"data"];
  131. typeStr = [dataDic objectForKey:@"type"];
  132. } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) {
  133. objectM = dataM;
  134. }
  135. if (([typeStr isEqualToString:@"reviewHead"] || [objectM isKindOfClass:[GoodsReviewsListM class]] || [typeStr isEqualToString:@"reviewFoot"] || [typeStr isEqualToString:@"customer"]) && !self.isReview) {
  136. return 0;
  137. }
  138. return UITableViewAutomaticDimension;
  139. }
  140. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  141. return 200;
  142. }
  143. @end