ASGoodsDetailsTableView.m 7.6 KB

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