ASGoodsDetailsTableView.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // ASGoodsDetailsTableView.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/17.
  6. //
  7. #import "ASGoodsDetailsTableView.h"
  8. #import "ASGoodsBannerCell.h"
  9. #import "ASGoodsDetailsSizeCell.h"
  10. #import "ASGoodsCouponCell.h"
  11. #import "ASGoodsTitlePriceCell.h"
  12. #import "ASGoodsGuaranteeInfoCell.h"
  13. #import "ASGoodsReviewHeadCell.h"
  14. @interface ASGoodsDetailsTableView()
  15. @property (nonatomic, assign) BOOL couponSelect;
  16. @end
  17. @implementation ASGoodsDetailsTableView
  18. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  19. NSDictionary *dicData = self.infodata[indexPath.row];
  20. NSObject *objectM = [dicData objectForKey:@"data"];
  21. NSString *typeStr = [dicData objectForKey:@"type"];
  22. if ([typeStr isEqualToString:@"banner"]) {
  23. ASGoodsBannerCell *cell = [ASGoodsBannerCell cellWithTableView:tableView CellClass:[ASGoodsBannerCell class]];
  24. [cell configData:(GoodsInformationM *)objectM];
  25. return cell;
  26. } else if ([typeStr isEqualToString:@"titlePrice"]) {
  27. ASGoodsTitlePriceCell *cell = [ASGoodsTitlePriceCell cellWithTableView:tableView CellClass:[ASGoodsTitlePriceCell class]];
  28. [cell configData:(GoodsInformationM *)objectM];
  29. @weakify(self)
  30. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  31. @strongify(self)
  32. [self generaltriggermethodType:type data:Data];
  33. };
  34. return cell;
  35. } else if ([typeStr isEqualToString:@"coupon"]) {
  36. ASGoodsCouponCell *cell = [ASGoodsCouponCell cellWithTableView:tableView CellClass:[ASGoodsCouponCell class]];
  37. [cell configData:(GoodsInformationM *)objectM isSelect:self.couponSelect];
  38. @weakify(self)
  39. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  40. @strongify(self)
  41. self.couponSelect = type;
  42. [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  43. };
  44. return cell;
  45. } else if ([typeStr isEqualToString:@"size"]) {
  46. ASGoodsDetailsSizeCell *cell = [ASGoodsDetailsSizeCell cellWithTableView:tableView CellClass:[ASGoodsDetailsSizeCell class]];
  47. [cell configData:(GoodsInformationM *)objectM];
  48. @weakify(self)
  49. cell.currencyparameterClose = ^(NSInteger type, id Data) {
  50. @strongify(self)
  51. [self generaltriggermethodType:type data:Data];
  52. };
  53. return cell;
  54. } else if ([typeStr isEqualToString:@"guarantee"]) {
  55. ASGoodsGuaranteeInfoCell *cell = [ASGoodsGuaranteeInfoCell cellWithTableView:tableView CellClass:[ASGoodsGuaranteeInfoCell 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:@"reviewHead"]) {
  64. ASGoodsReviewHeadCell *cell = [ASGoodsReviewHeadCell cellWithTableView:tableView CellClass:[ASGoodsReviewHeadCell 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. }
  73. return nil;
  74. }
  75. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  76. // NSObject *objectM = self.infodata[indexPath.row];
  77. // if([objectM isKindOfClass:[CartTotalsItemsM class]] && self.isFlod){
  78. // return 0;
  79. // }
  80. // return 1;
  81. return UITableViewAutomaticDimension;
  82. }
  83. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  84. return 200;
  85. }
  86. @end