ASGoodsDetailsTableView.m 5.1 KB

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