AS_GoodsReviewsListC.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // AS_GoodsReviewsListC.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2024/1/4.
  6. //
  7. #import "AS_GoodsReviewsListC.h"
  8. #import "ASGoodsDetailsVM.h"
  9. #import "RadioButton.h"
  10. #import "GoodsReviewsListTableV.h"
  11. @interface AS_GoodsReviewsListC ()<RY_baseVMprotocol>
  12. @property (nonatomic, strong) ASGoodsDetailsVM *VM;
  13. @property (nonatomic, strong) UIView *topBgV;
  14. @property (nonatomic, strong) UIImageView *topImgV;
  15. @property (nonatomic, strong) UILabel *goodsTitleLab;
  16. @property (nonatomic, strong) QMUILabel *priceLab;
  17. @property (nonatomic, strong) QMUILabel *soldLab;
  18. @property (nonatomic, strong) NSMutableArray *radioBtnAry;
  19. @property (nonatomic, strong) UIView *tableHeadV;
  20. @property (nonatomic, strong) QMUILabel *reviewsLab;
  21. @property (nonatomic, strong) GoodsReviewsListTableV *TableV;
  22. @end
  23. @implementation AS_GoodsReviewsListC
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. self.title = [NSString stringWithFormat:@"Reviews (%@)",self.goodsM.review_nums];
  27. [self reqNet_Goods_productGetProductsReview];
  28. }
  29. - (void)initSubviews {
  30. [super initSubviews];
  31. [self.view addSubview:self.topBgV];
  32. NSArray *segAry = @[@"All",@"Newest",@"Pictures"];
  33. for (int i=0; i<segAry.count; i++) {
  34. RadioButton *radBtn= [[RadioButton alloc]init];
  35. radBtn.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  36. radBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  37. radBtn.layer.cornerRadius = 4;
  38. radBtn.clipsToBounds = YES;
  39. radBtn.tag = i;
  40. [radBtn setTitle:segAry[i] forState:UIControlStateNormal];
  41. [radBtn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateNormal];
  42. [radBtn addTarget:self action:@selector(handle_onRadioButtonValueChanged:) forControlEvents:UIControlEventValueChanged];
  43. [self.view addSubview:radBtn];
  44. CGFloat btnWidth = (KScreenWidth-40)/3;
  45. radBtn.frame = CGRectMake(10 + i*(btnWidth+10), CGRectGetMaxY(self.topBgV.frame)+10,btnWidth, 40);
  46. [self.radioBtnAry addObject:radBtn];
  47. }
  48. RadioButton *firstBtn = self.radioBtnAry[0];
  49. [firstBtn setGroupButtons:self.radioBtnAry];
  50. firstBtn.selected = YES;
  51. [self setupTableV:[GoodsReviewsListTableV class] Frame:CGRectMake(0, CGRectGetMaxY(firstBtn.frame)+10, KScreenWidth, KScreenHeight- CGRectGetMaxY(firstBtn.frame)-10)];
  52. self.TableV.backgroundColor = [UIColor clearColor];
  53. self.TableV.tableHeaderView = self.tableHeadV;
  54. self.TableV.Page = 1;
  55. self.TableV.is_refreshHeader = YES;
  56. self.TableV.is_refreshfoot = YES;
  57. }
  58. - (void)viewDidLayoutSubviews {
  59. [super viewDidLayoutSubviews];
  60. }
  61. - (void)ucm_changedefault{
  62. [self.topImgV sd_setImageWithURL:[NSURL URLWithString:self.goodsM.gooodsImgUrl] placeholderImage:UIImageDefaultImg_SD];
  63. self.goodsTitleLab.text = self.goodsM.name;
  64. self.priceLab.attributedText = self.goodsM.priceAtr;
  65. self.soldLab.text = [NSString stringWithFormat:@"SOLD: %@",self.goodsM.sold];
  66. }
  67. - (void)ucm_bindvmmodel{
  68. self.VM = [[ASGoodsDetailsVM alloc]initDelegate:self];
  69. }
  70. #pragma mark - **************** reqNet ****************
  71. -(void)reqNet_Goods_productGetProductsReview{
  72. NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
  73. [params setObject:self.goodsM.Id forKey:@"pid"];
  74. [params setObject:@1 forKey:@"img"];
  75. [params setObject:@"All" forKey:@"sortreview"];
  76. [params setObject:@1 forKey:@"p"];
  77. [params setObject:@10 forKey:@"limit"];
  78. [self.VM ry_requestGetApi:Goods_productGetProductsReview param:params];
  79. }
  80. -(void)ry_respnsData:(id)data
  81. parseAry:(NSMutableArray *)arry
  82. sucess:(BOOL)sucessOrFail
  83. mark:(NSString *)mark{
  84. [MBProgressHUD hideHUDForView:self.view animated:YES];
  85. if(sucessOrFail){ ///如何加载相关的评论页面
  86. if([mark isEqualToString:Goods_productGetProductsReview]){
  87. [self.TableV configDataNew:arry has_more:arry.count==10 ? YES : NO];
  88. }
  89. }
  90. }
  91. #pragma mark - **************** handle ****************
  92. -(void)handle_onRadioButtonValueChanged:(RadioButton *)btn{
  93. if (btn.selected) {
  94. }else{
  95. }
  96. }
  97. #pragma mark - **************** lazy ****************
  98. - (UIView *)topBgV {
  99. if (!_topBgV) {
  100. IPhoneXHeigh
  101. UIView *v= [[UIView alloc] initWithFrame:CGRectMake(0, securitytop_Y, KScreenWidth, 60)];
  102. v.backgroundColor = [UIColor colorWithHexString:@"#E0FFF5"];
  103. [v addSubview:self.topImgV];
  104. [v addSubview:self.goodsTitleLab];
  105. [v addSubview:self.priceLab];
  106. [v addSubview:self.soldLab];
  107. [self.topImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.mas_equalTo(20);
  109. make.top.mas_equalTo(10);
  110. make.height.mas_equalTo(40);
  111. make.width.mas_equalTo(40);
  112. }];
  113. [self.soldLab mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.right.mas_equalTo(-10);
  115. make.centerY.mas_equalTo(0);
  116. make.height.mas_equalTo(40);
  117. }];
  118. [self.goodsTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.left.equalTo(self.topImgV.mas_right).offset(10);
  120. make.right.equalTo(self.soldLab.mas_left).offset(-10);
  121. make.top.mas_equalTo(10);
  122. make.height.mas_equalTo(20);
  123. }];
  124. [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.left.equalTo(self.topImgV.mas_right).offset(10);
  126. make.right.equalTo(self.soldLab.mas_left).offset(-10);
  127. make.top.equalTo(self.goodsTitleLab.mas_bottom);
  128. make.height.mas_equalTo(20);
  129. }];
  130. _topBgV = v;
  131. }
  132. return _topBgV;
  133. }
  134. - (UIImageView *)topImgV {
  135. if (!_topImgV) {
  136. _topImgV = [[UIImageView alloc] initWithImage:nil];
  137. _topImgV.contentMode = UIViewContentModeScaleAspectFill;
  138. _topImgV.clipsToBounds = YES;
  139. }
  140. return _topImgV;
  141. }
  142. - (UILabel *)goodsTitleLab {
  143. if (!_goodsTitleLab) {
  144. _goodsTitleLab = [[UILabel alloc] initWithFrame:CGRectZero];
  145. _goodsTitleLab.textColor = [UIColor colorWithHexString:@"#B2B2B2"];
  146. _goodsTitleLab.font = [UIFont fontWithName:Rob_Regular size:12];
  147. }
  148. return _goodsTitleLab;
  149. }
  150. - (QMUILabel *)priceLab {
  151. if (!_priceLab) {
  152. _priceLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  153. }
  154. return _priceLab;
  155. }
  156. - (QMUILabel *)soldLab {
  157. if (!_soldLab) {
  158. _soldLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  159. _soldLab.textAlignment = NSTextAlignmentRight;
  160. _soldLab.textColor = [UIColor colorWithHexString:@"#000000"];
  161. _soldLab.font = [UIFont fontWithName:Rob_Regular size:12];
  162. }
  163. return _soldLab;
  164. }
  165. - (NSMutableArray *)radioBtnAry {
  166. if (!_radioBtnAry) {
  167. _radioBtnAry = [[NSMutableArray alloc] init];
  168. }
  169. return _radioBtnAry;
  170. }
  171. - (UIView *)tableHeadV {
  172. if (!_tableHeadV) {
  173. _tableHeadV = [[UIView alloc] initWithFrame:CGRectFlatMake(10, 0, KScreenHeight-20, 86)];
  174. _tableHeadV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  175. }
  176. return _tableHeadV;
  177. }
  178. - (QMUILabel *)reviewsLab {
  179. if (!_reviewsLab) {
  180. _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  181. _reviewsLab.textAlignment = NSTextAlignmentLeft;
  182. _reviewsLab.textColor = [UIColor blackColor];
  183. _reviewsLab.font = [UIFont systemFontOfSize:18];
  184. _reviewsLab.text = @"test";
  185. }
  186. return _reviewsLab;
  187. }
  188. @end