ASGoodsDetailsTableView.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. @interface ASGoodsDetailsTableView()
  18. @property (nonatomic, assign) BOOL couponSelect;
  19. @end
  20. @implementation ASGoodsDetailsTableView
  21. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  22. NSObject *dataM = self.infodata[indexPath.row];
  23. NSObject *objectM = nil;
  24. NSString *typeStr = @"";
  25. if ([dataM isKindOfClass:[NSDictionary class]]) {
  26. NSDictionary *dataDic = (NSDictionary *)dataM;
  27. objectM = [dataDic objectForKey:@"data"];
  28. typeStr = [dataDic objectForKey:@"type"];
  29. } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) {
  30. objectM = dataM;
  31. }
  32. if ([typeStr isEqualToString:@"banner"]) {
  33. ASGoodsBannerCell *cell = [ASGoodsBannerCell cellWithTableView:tableView CellClass:[ASGoodsBannerCell class]];
  34. [cell configData:(GoodsInformationM *)objectM];
  35. return cell;
  36. } else if ([typeStr isEqualToString:@"titlePrice"]) {
  37. ASGoodsTitlePriceCell *cell = [ASGoodsTitlePriceCell cellWithTableView:tableView CellClass:[ASGoodsTitlePriceCell class]];
  38. [cell configData:(GoodsInformationM *)objectM];
  39. @weakify(self)
  40. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  41. @strongify(self)
  42. [self generaltriggermethodType:type data:Data];
  43. };
  44. return cell;
  45. } else if ([typeStr isEqualToString:@"coupon"]) {
  46. ASGoodsCouponCell *cell = [ASGoodsCouponCell cellWithTableView:tableView CellClass:[ASGoodsCouponCell class]];
  47. [cell configData:(GoodsInformationM *)objectM isSelect:self.couponSelect];
  48. @weakify(self)
  49. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  50. @strongify(self)
  51. self.couponSelect = type;
  52. [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  53. };
  54. return cell;
  55. } else if ([typeStr isEqualToString:@"size"]) {
  56. ASGoodsDetailsSizeCell *cell = [ASGoodsDetailsSizeCell cellWithTableView:tableView CellClass:[ASGoodsDetailsSizeCell class]];
  57. [cell configData:(GoodsInformationM *)objectM];
  58. @weakify(self)
  59. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  60. @strongify(self)
  61. [self generaltriggermethodType:type data:Data];
  62. };
  63. return cell;
  64. } else if ([typeStr isEqualToString:@"guarantee"]) {
  65. ASGoodsGuaranteeInfoCell *cell = [ASGoodsGuaranteeInfoCell cellWithTableView:tableView CellClass:[ASGoodsGuaranteeInfoCell class]];
  66. [cell configData:(GoodsInformationM *)objectM];
  67. @weakify(self)
  68. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  69. @strongify(self)
  70. [self generaltriggermethodType:type data:Data];
  71. };
  72. return cell;
  73. } else if ([typeStr isEqualToString:@"reviewHead"]) {
  74. ASGoodsReviewHeadCell *cell = [ASGoodsReviewHeadCell cellWithTableView:tableView CellClass:[ASGoodsReviewHeadCell class]];
  75. cell.clipsToBounds = YES;
  76. [cell configData:(GoodsInformationM *)objectM];
  77. @weakify(self)
  78. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  79. @strongify(self)
  80. [self generaltriggermethodType:type data:Data];
  81. };
  82. return cell;
  83. } else if ([objectM isKindOfClass:[GoodsReviewsListM class]]) {
  84. // GoodsReviewsListM *objectM = self.infodata[indexPath.row];
  85. GoodsReviewsCell *cell = [GoodsReviewsCell cellWithTableView:tableView CellClass:[GoodsReviewsCell class]];
  86. cell.clipsToBounds = YES;
  87. [cell configData:objectM];
  88. @weakify(self)
  89. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  90. @strongify(self) //图片选择器展示
  91. };
  92. return cell;
  93. } else if ([typeStr isEqualToString:@"reviewFoot"]) {
  94. // GoodsReviewsListM *objectM = self.infodata[indexPath.row];
  95. ASGoodsReviewFootCell *cell = [ASGoodsReviewFootCell cellWithTableView:tableView CellClass:[ASGoodsReviewFootCell class]];
  96. cell.clipsToBounds = YES;
  97. @weakify(self)
  98. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  99. @strongify(self)
  100. [self generaltriggermethodType:type data:Data];
  101. };
  102. return cell;
  103. }
  104. return nil;
  105. }
  106. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  107. NSObject *dataM = self.infodata[indexPath.row];
  108. NSObject *objectM = nil;
  109. NSString *typeStr = @"";
  110. if ([dataM isKindOfClass:[NSDictionary class]]) {
  111. NSDictionary *dataDic = (NSDictionary *)dataM;
  112. objectM = [dataDic objectForKey:@"data"];
  113. typeStr = [dataDic objectForKey:@"type"];
  114. } else if ([dataM isKindOfClass:[GoodsReviewsListM class]]) {
  115. objectM = dataM;
  116. }
  117. if (([typeStr isEqualToString:@"reviewHead"] || [objectM isKindOfClass:[GoodsReviewsListM class]] || [typeStr isEqualToString:@"reviewFoot"]) && !self.isReview) {
  118. return 0;
  119. }
  120. return UITableViewAutomaticDimension;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  123. return 200;
  124. }
  125. @end