ASGoodsDetailsTableView.m 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. #import <GKPhotoBrowser/GKPhotoBrowser.h>
  20. @interface ASGoodsDetailsTableView()
  21. @property (nonatomic, assign) BOOL couponSelect;
  22. @end
  23. @implementation ASGoodsDetailsTableView
  24. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  25. NSObject *dataM = self.infodata[indexPath.row];
  26. NSObject *objectM = nil;
  27. NSString *typeStr = @"";
  28. if ([dataM isKindOfClass:[NSDictionary class]]) {
  29. NSDictionary *dataDic = (NSDictionary *)dataM;
  30. objectM = [dataDic objectForKey:@"data"];
  31. typeStr = [dataDic objectForKey:@"type"];
  32. } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) {
  33. objectM = dataM;
  34. }
  35. if ([typeStr isEqualToString:@"banner"]) {
  36. ASGoodsBannerCell *cell = [ASGoodsBannerCell cellWithTableView:tableView CellClass:[ASGoodsBannerCell class]];
  37. [cell configData:(GoodsInformationM *)objectM];
  38. return cell;
  39. } else if ([typeStr isEqualToString:@"titlePrice"]) {
  40. ASGoodsTitlePriceCell *cell = [ASGoodsTitlePriceCell cellWithTableView:tableView CellClass:[ASGoodsTitlePriceCell class]];
  41. [cell configData:(GoodsInformationM *)objectM];
  42. @weakify(self)
  43. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  44. @strongify(self)
  45. [self generaltriggermethodType:type data:Data];
  46. };
  47. return cell;
  48. } else if ([typeStr isEqualToString:@"coupon"]) {
  49. ASGoodsCouponCell *cell = [ASGoodsCouponCell cellWithTableView:tableView CellClass:[ASGoodsCouponCell class]];
  50. [cell configData:(GoodsInformationM *)objectM isSelect:self.couponSelect];
  51. @weakify(self)
  52. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  53. @strongify(self)
  54. self.couponSelect = type;
  55. [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  56. };
  57. return cell;
  58. } else if ([typeStr isEqualToString:@"size"]) {
  59. ASGoodsDetailsSizeCell *cell = [ASGoodsDetailsSizeCell cellWithTableView:tableView CellClass:[ASGoodsDetailsSizeCell class]];
  60. @weakify(self)
  61. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  62. @strongify(self)
  63. [self generaltriggermethodType:type data:Data];
  64. };
  65. [cell configData:(GoodsInformationM *)objectM];
  66. return cell;
  67. } else if ([typeStr isEqualToString:@"guarantee"]) {
  68. ASGoodsGuaranteeInfoCell *cell = [ASGoodsGuaranteeInfoCell cellWithTableView:tableView CellClass:[ASGoodsGuaranteeInfoCell class]];
  69. [cell configData:(GoodsInformationM *)objectM];
  70. @weakify(self)
  71. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  72. @strongify(self)
  73. [self generaltriggermethodType:type data:Data];
  74. };
  75. return cell;
  76. } else if ([typeStr isEqualToString:@"reviewHead"]) {
  77. ASGoodsReviewHeadCell *cell = [ASGoodsReviewHeadCell cellWithTableView:tableView CellClass:[ASGoodsReviewHeadCell class]];
  78. cell.clipsToBounds = YES;
  79. [cell configData:(GoodsInformationM *)objectM];
  80. @weakify(self)
  81. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  82. @strongify(self)
  83. [self generaltriggermethodType:type data:Data];
  84. };
  85. return cell;
  86. } else if ([objectM isKindOfClass:[GoodsReviewsListM class]]) {
  87. // GoodsReviewsListM *objectM = self.infodata[indexPath.row];
  88. GoodsReviewsCell *cell = [GoodsReviewsCell cellWithTableView:tableView CellClass:[GoodsReviewsCell class]];
  89. cell.clipsToBounds = YES;
  90. [cell configData:objectM];
  91. @weakify(self)
  92. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  93. @strongify(self) //图片选择器展示
  94. NSArray *imageArr = (NSArray *)Data;
  95. NSMutableArray *photos = [[NSMutableArray alloc]init];
  96. for (NSString *imgUrl in imageArr) {
  97. GKPhoto *photo = [GKPhoto new];
  98. photo.placeholderImage = UIImageDefaultImg_SD;
  99. photo.url = [NSURL URLWithString:imgUrl];
  100. [photos addObject:photo];
  101. }
  102. GKPhotoBrowser *photoBrowser = [GKPhotoBrowser photoBrowserWithPhotos:photos currentIndex:type];
  103. photoBrowser.showStyle = GKPhotoBrowserShowStyleNone;
  104. [photoBrowser showFromVC:[Current_normalTool topViewController]];
  105. };
  106. return cell;
  107. } else if ([typeStr isEqualToString:@"reviewFoot"]) {
  108. // GoodsReviewsListM *objectM = self.infodata[indexPath.row];
  109. ASGoodsReviewFootCell *cell = [ASGoodsReviewFootCell cellWithTableView:tableView CellClass:[ASGoodsReviewFootCell class]];
  110. cell.clipsToBounds = YES;
  111. @weakify(self)
  112. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  113. @strongify(self)
  114. [self generaltriggermethodType:type data:Data];
  115. };
  116. return cell;
  117. } else if ([typeStr isEqualToString:@"customer"]) {
  118. NSArray *typeArr = (NSArray *)objectM;
  119. // KWMineMoreProductsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KWMineMoreProductsCell" forIndexPath:indexPath];
  120. KWMineMoreProductsCell *cell = [[KWMineMoreProductsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KWMineMoreProductsCell"];
  121. cell.topSpace = 20;
  122. // KWMineMoreProductModel * model = [KWMineMoreProductModel demoData];
  123. // [cell setData: model];
  124. [cell setTypeArray:typeArr];
  125. K_WEAK_SELF;
  126. cell.productBlock = ^(ASProductBaseModel * _Nonnull model) {
  127. K_STRONG_SELF;
  128. [self generaltriggermethodType:101 data:model];
  129. };
  130. cell.addCartBlock = ^(ASProductBaseModel * _Nonnull model) {
  131. K_STRONG_SELF;
  132. [self generaltriggermethodType:102 data:model];
  133. };
  134. return cell;
  135. }
  136. return nil;
  137. }
  138. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  139. NSObject *dataM = self.infodata[indexPath.row];
  140. NSObject *objectM = nil;
  141. NSString *typeStr = @"";
  142. if ([dataM isKindOfClass:[NSDictionary class]]) {
  143. NSDictionary *dataDic = (NSDictionary *)dataM;
  144. objectM = [dataDic objectForKey:@"data"];
  145. typeStr = [dataDic objectForKey:@"type"];
  146. } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) {
  147. objectM = dataM;
  148. }
  149. if (([typeStr isEqualToString:@"reviewHead"] || [objectM isKindOfClass:[GoodsReviewsListM class]] || [typeStr isEqualToString:@"reviewFoot"] || [typeStr isEqualToString:@"customer"]) && !self.isReview) {
  150. return 0;
  151. }
  152. return UITableViewAutomaticDimension;
  153. }
  154. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  155. return 200;
  156. }
  157. @end