ASGoodsDetailsViewController.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // ASGoodsDetailsViewController.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/17.
  6. //
  7. #import "ASGoodsDetailsViewController.h"
  8. #import "AS_GoodsReviewsListC.h"
  9. #import "Cart_CheckoutC.h"
  10. #import "ASGoodsDetailsVM.h"
  11. #import "ASGoodsDetailsTableView.h"
  12. #import "ASGoodsIntrouduceWebView.h"
  13. #import "GoodsDetailsBottomV.h"
  14. #import "GoodsInformationM.h"
  15. #import "WKM_goodsBanner.h"
  16. @interface ASGoodsDetailsViewController ()<RY_baseVMprotocol>
  17. @property (nonatomic, strong) ASGoodsDetailsVM *VM;
  18. @property (nonatomic, strong) ASGoodsDetailsTableView *TableV;
  19. @property (nonatomic, strong) GoodsInformationM *model;
  20. @property (nonatomic, strong) WKM_goodsBanner *goodsBanner;
  21. @property (nonatomic, strong) UIView *footView;
  22. @property (nonatomic, strong) GoodsDetailsBottomV *bottomV;
  23. //尺寸数据
  24. @property (nonatomic, strong) NSDictionary *sizeParam;
  25. //底部按钮点击类型
  26. @property (nonatomic, assign) NSInteger bottomClickType;
  27. @end
  28. @implementation ASGoodsDetailsViewController
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. [self reqNet_GoodsDetails_productGetProduct];
  32. }
  33. - (void)initSubviews {
  34. [super initSubviews];
  35. [self.view addSubview:self.bottomV];
  36. @weakify(self)
  37. self.bottomV.ViewtapClose = ^(NSInteger num, id _Nonnull data) {
  38. @strongify(self)
  39. self.bottomClickType = num;
  40. [self reqNet_Size_rewriteCartAddProducts];
  41. };
  42. IPhoneXHeigh
  43. [self setupTableV:[ASGoodsDetailsTableView class] Frame:CGRectMake(0, securitytop_Y , KScreenWidth, KScreenHeight - securitytop_Y - securityBottom_H - 65)];
  44. self.TableV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  45. K_WEAK_SELF;
  46. self.TableV.tapClose = ^(NSInteger num, id data) {
  47. K_STRONG_SELF;
  48. if (num == 1) {//查看评论
  49. [self action_GoodsReviewsListC];
  50. } else if (num == 2) {//商品web详情
  51. self.TableV.tableFooterView = self.footView;
  52. } else if (num == 3) {//商品评论
  53. self.TableV.tableFooterView = nil;
  54. } else if (num == 100) {
  55. self.sizeParam = (NSDictionary *)data;
  56. }
  57. };
  58. }
  59. -(void)reqNet_Size_rewriteCartAddProducts {
  60. NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:self.sizeParam];
  61. params[@"product"] = self.model.Id;
  62. NSLog(@"=====%@", params);
  63. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  64. [self.VM ry_formDataRequestPostApi:Size_rewriteCartAddProducts param:params];
  65. }
  66. -(void)reqNet_GoodsDetails_productGetProduct{
  67. NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
  68. // [params setObject:@"55475" forKey:@"productId"];
  69. [params setObject:self.entity_id forKey:@"productId"];
  70. [params setObject:@"USD" forKey:@"currencyCode"];
  71. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  72. [self.VM ry_requestGetApi:Goods_productGetProductsById param:params];
  73. }
  74. -(void)ry_respnsData:(nullable id)data
  75. parseAry:(nullable NSMutableArray *)arry
  76. sucess:(BOOL)sucessOrFail
  77. mark:(NSString *)mark
  78. reqNetType:(ReqNetType)reqNetType{
  79. [MBProgressHUD hideHUDForView:self.view animated:YES];
  80. if(sucessOrFail){
  81. if([mark isEqualToString:Goods_productGetProductsById]){
  82. GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
  83. self.model = model;
  84. self.title = model.name;
  85. [self updateGoodsDetailsData];
  86. } else if([mark isEqualToString:Size_rewriteCartAddProducts]) {
  87. [self.view makeToast:@"Success" duration:2 position:CSToastPositionCenter title:nil image:nil style:nil completion:^(BOOL didTap) {
  88. if (self.bottomClickType == 1) {
  89. Cart_CheckoutC *vc = [[Cart_CheckoutC alloc] init];
  90. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:YES];
  91. }
  92. }];
  93. }
  94. }
  95. }
  96. - (void)updateGoodsDetailsData {
  97. //商品图
  98. NSDictionary *banner = @{@"type":@"banner", @"data":self.model};
  99. [self.TableV.infodata addObject:banner];
  100. //商品名、价格
  101. NSDictionary *titlePrice = @{@"type":@"titlePrice", @"data":self.model};
  102. [self.TableV.infodata addObject:titlePrice];
  103. //规格
  104. NSDictionary *goodsSize = @{@"type":@"size", @"data":self.model};
  105. [self.TableV.infodata addObject:goodsSize];
  106. //保障信息
  107. NSDictionary *guarantee = @{@"type":@"guarantee", @"data":self.model};
  108. [self.TableV.infodata addObject:guarantee];
  109. // //介绍
  110. // NSDictionary *webIntroduce = @{@"type":@"webIntroduce", @"data":self.model};
  111. // [self.TableV.infodata addObject:webIntroduce];
  112. [self loadWebString];
  113. [self.TableV reloadData];
  114. }
  115. - (void)loadWebString {
  116. _footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 0.001)];
  117. self.TableV.tableFooterView = _footView;
  118. ASGoodsIntrouduceWebView *webInfoView = [[ASGoodsIntrouduceWebView alloc] initWithFrame:CGRectZero];
  119. [_footView addSubview:webInfoView];
  120. [webInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.edges.mas_equalTo(0);
  122. }];
  123. [webInfoView loadWebUrlWithData:self.model];
  124. K_WEAK_SELF;
  125. webInfoView.loadFinishBlock = ^(float webHeight) {
  126. K_STRONG_SELF;
  127. self.footView.frame = CGRectMake(0, 0, KScreenWidth, webHeight);
  128. [self.TableV reloadData];
  129. };
  130. }
  131. #pragma mark ---- Touch Event ----
  132. //查看评论
  133. -(void)action_GoodsReviewsListC{
  134. AS_GoodsReviewsListC *allPic = [[AS_GoodsReviewsListC alloc]init];
  135. allPic.goodsM = self.model;
  136. [self.navigationController pushViewController:allPic animated:YES];
  137. }
  138. - (void)ucm_bindvmmodel{
  139. self.VM = [[ASGoodsDetailsVM alloc] initDelegate:self];
  140. }
  141. - (GoodsDetailsBottomV *)bottomV {
  142. if (!_bottomV) {
  143. IPhoneXHeigh
  144. _bottomV = [[GoodsDetailsBottomV alloc] initWithFrame:CGRectMake(0, KScreenHeight - securityBottom_H-65, KScreenWidth, securityBottom_H+65)];
  145. _bottomV.backgroundColor = Col_FFF;
  146. }
  147. return _bottomV;
  148. }
  149. @end