GoodsDetailSrcView.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //
  2. // GoodsDetailSrcView.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2023/5/8.
  6. //
  7. #import "GoodsDetailSrcView.h"
  8. #import "WKM_goodsBanner.h"
  9. #import "GoodsDetailsPayV.h"
  10. #import "GoodsDetailsIntroduceV.h"
  11. @interface GoodsDetailSrcView ()
  12. @property (nonatomic, strong) GoodsInformationM *infoModel;
  13. @property (nonatomic, strong) WKM_goodsBanner *goodsBanner;
  14. @property (nonatomic, strong) QMUILabel *titleLab;
  15. @property (nonatomic, strong) QMUILabel *soldLab;
  16. @property (nonatomic, strong) QMUILabel *reviewsLab;
  17. @property (nonatomic, strong) QMUILabel *priceLab;
  18. @property (nonatomic, strong) QMUILabel *saveLab;
  19. @property (nonatomic, strong) QMUILabel *couponLab;
  20. @property (nonatomic, strong) QMUILabel *sizeLab;
  21. @property (nonatomic, strong) GoodsDetailsPayV *datails_payV;
  22. @property (nonatomic, strong) GoodsDetailsIntroduceV *datails_IntroduceV;
  23. @end
  24. @implementation GoodsDetailSrcView
  25. - (void)tt_addsubviewS{
  26. [self addSubview:self.goodsBanner];
  27. [self addSubview:self.titleLab];
  28. [self addSubview:self.soldLab];
  29. [self addSubview:self.reviewsLab];
  30. [self addSubview:self.priceLab];
  31. [self addSubview:self.saveLab];
  32. [self addSubview:self.couponLab];
  33. [self addSubview:self.sizeLab];
  34. [self addSubview:self.datails_payV];
  35. [self addSubview:self.datails_IntroduceV];
  36. [self.goodsBanner mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.top.mas_equalTo(0);
  38. make.width.mas_equalTo(KScreenWidth);
  39. make.height.mas_equalTo(KScreenWidth+112+10);
  40. }];
  41. [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.left.mas_equalTo(10);
  43. make.width.mas_equalTo(KScreenWidth-20);
  44. make.top.equalTo(self.goodsBanner.mas_bottom).offset(20);
  45. make.height.mas_equalTo(45);
  46. }];
  47. [self.soldLab mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(10);
  49. make.height.mas_equalTo(16);
  50. make.top.equalTo(self.titleLab.mas_bottom).offset(10);
  51. }];
  52. [self.reviewsLab mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.right.equalTo(self.titleLab.mas_right);
  54. make.height.mas_equalTo(16);
  55. make.top.equalTo(self.titleLab.mas_bottom).offset(10);
  56. }];
  57. [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.mas_equalTo(10);
  59. make.top.equalTo(self.reviewsLab.mas_bottom).offset(20);
  60. make.height.mas_equalTo(24);
  61. }];
  62. [self.saveLab mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.equalTo(self.priceLab.mas_right).offset(10);
  64. make.height.mas_equalTo(20);
  65. make.centerY.equalTo(self.priceLab);
  66. }];
  67. [self.couponLab mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.mas_equalTo(10);
  69. make.top.equalTo(self.priceLab.mas_bottom).offset(20);
  70. make.width.mas_equalTo(KScreenWidth-20);
  71. make.height.mas_equalTo(45);
  72. }];
  73. [self.sizeLab mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.mas_equalTo(10);
  75. make.top.equalTo(self.couponLab.mas_bottom).offset(10);
  76. make.width.mas_equalTo(KScreenWidth-20);
  77. make.height.mas_equalTo(45);
  78. }];
  79. [self.datails_payV mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.mas_equalTo(10);
  81. make.top.equalTo(self.sizeLab.mas_bottom).offset(10);
  82. make.width.mas_equalTo(KScreenWidth-20);
  83. make.height.mas_equalTo(78);
  84. }];
  85. [self.datails_IntroduceV mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.mas_equalTo(10);
  87. make.top.equalTo(self.datails_payV.mas_bottom).offset(10);
  88. make.width.mas_equalTo(KScreenWidth-20);
  89. make.height.mas_equalTo(120);
  90. }];
  91. }
  92. - (void)tt_configData:(id)data{
  93. GoodsInformationM *model = (GoodsInformationM *)data;
  94. self.infoModel = model;
  95. [self.goodsBanner tt_confignewdata:model];
  96. self.titleLab.text =MM_str(model.name);
  97. //wm_todo soldLab\ reviewsLab\ coupon 和 size
  98. self.soldLab.text = [NSString stringWithFormat:@"SOLD: %@",model.sold] ;
  99. NSMutableAttributedString *reviewsStr = [[NSMutableAttributedString alloc]
  100. initWithString:[NSString stringWithFormat:@"REVIEWS:%@",model.review_nums]];
  101. NSRange contentRange = {0,[reviewsStr length]};
  102. [reviewsStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
  103. self.reviewsLab.attributedText = reviewsStr;
  104. self.reviewsLab.textAlignment = NSTextAlignmentRight;
  105. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,model.final_prices]];
  106. [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
  107. [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
  108. NSString *saveStr = @"";
  109. if(model.final_prices == model.price){
  110. self.saveLab.hidden = YES;
  111. }else{
  112. self.saveLab.hidden = NO;
  113. double savePrice = [model.price doubleValue]-[model.final_prices doubleValue];
  114. saveStr = [NSString stringWithFormat:@"Save %@%.2f",model.currency_symbol,savePrice];
  115. [priceAtr yy_appendString:@" "];
  116. NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",model.price]];
  117. priceAtrSub1.yy_color = [UIColor colorWithHexString:@"#8c8c8c"];
  118. priceAtrSub1.yy_font = [UIFont fontWithName:Rob_Regular size:14];
  119. priceAtrSub1.yy_strikethroughStyle = NSUnderlineStyleSingle;
  120. [priceAtr appendAttributedString:priceAtrSub1];
  121. }
  122. self.priceLab.attributedText = priceAtr;
  123. self.saveLab.text = saveStr;
  124. self.datails_payV.titleLab.text = [NSString stringWithFormat:@"Pay in 4 interest-free payments of %@%.2f with",model.currency_symbol,[model.final_prices floatValue]/4];
  125. }
  126. #pragma mark - **************** handle ****************
  127. -(void)tap_sizeLab{ ///展开size 规格选择的页面
  128. }
  129. -(void)handle_couponEvent:(UIButton *)btn{
  130. //wm_todo
  131. btn.selected = !btn.selected;
  132. }
  133. - (WKM_goodsBanner *)goodsBanner {
  134. if (!_goodsBanner) {
  135. _goodsBanner = [[WKM_goodsBanner alloc] init];
  136. }
  137. return _goodsBanner;
  138. }
  139. - (QMUILabel *)titleLab {
  140. if (!_titleLab) {
  141. _titleLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  142. _titleLab.textAlignment = NSTextAlignmentLeft;
  143. _titleLab.numberOfLines = 2;
  144. _titleLab.textColor = [UIColor colorWithHexString:@"#000000"];
  145. _titleLab.font = [UIFont fontWithName:Rob_Bold size:16];
  146. }
  147. return _titleLab;
  148. }
  149. - (QMUILabel *)soldLab {
  150. if (!_soldLab) {
  151. _soldLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  152. _soldLab.textAlignment = NSTextAlignmentLeft;
  153. _soldLab.textColor = [UIColor colorWithHexString:@"#666666"];
  154. _soldLab.font = [UIFont systemFontOfSize:12];
  155. }
  156. return _soldLab;
  157. }
  158. - (QMUILabel *)reviewsLab {
  159. if (!_reviewsLab) {
  160. _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  161. _reviewsLab.textAlignment = NSTextAlignmentRight;
  162. _reviewsLab.textColor = [UIColor colorWithHexString:@"#666666"];
  163. _reviewsLab.font = [UIFont fontWithName:Rob_Regular size:12];
  164. // reviewsStr.underlineStyle = NSUnderlineStyleSingle;
  165. }
  166. return _reviewsLab;
  167. }
  168. - (QMUILabel *)priceLab {
  169. if (!_priceLab) {
  170. _priceLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  171. _priceLab.textAlignment = NSTextAlignmentLeft;
  172. _priceLab.textColor = [UIColor blackColor];
  173. _priceLab.font = [UIFont systemFontOfSize:18];
  174. }
  175. return _priceLab;
  176. }
  177. - (QMUILabel *)saveLab {
  178. if (!_saveLab) {
  179. _saveLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  180. _saveLab.contentEdgeInsets= UIEdgeInsetsMake(10, 10, 10, 10);
  181. _saveLab.backgroundColor = [UIColor colorWithHexString:@"#E0FFF5"];
  182. _saveLab.textAlignment = NSTextAlignmentCenter;
  183. _saveLab.textColor = [UIColor colorWithHexString:@"#113632"];
  184. _saveLab.font = [UIFont fontWithName:Rob_Bold size:12];
  185. }
  186. return _saveLab;
  187. }
  188. - (QMUILabel *)couponLab {
  189. if (!_couponLab) {
  190. _couponLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  191. _couponLab.mj_size = CGSizeMake(KScreenWidth-20, 45);
  192. _couponLab.backgroundColor = [UIColor colorWithHexString:@"#113632"];
  193. _couponLab.textAlignment = NSTextAlignmentLeft;
  194. _couponLab.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
  195. _couponLab.font = [UIFont fontWithName:Rob_Bold size:14];
  196. _couponLab.text = @"COUPON";
  197. _couponLab.layer.cornerRadius = 4;
  198. _couponLab.clipsToBounds = YES;
  199. _couponLab.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  200. UIButton *btn = [[UIButton alloc]init];
  201. btn.selected = NO;
  202. [btn addTarget:self action:@selector(handle_couponEvent:) forControlEvents:UIControlEventTouchUpInside];
  203. btn.frame = CGRectMake(_couponLab.mj_w-45-10, 0, 45, 45);
  204. [btn setImage:[UIImage imageNamed:@"base_add_white"] forState:UIControlStateNormal];
  205. [btn setImage:[UIImage imageNamed:@"base_subtract_white"] forState:UIControlStateSelected];
  206. [_couponLab addSubview:btn];
  207. }
  208. return _couponLab;
  209. }
  210. - (QMUILabel *)sizeLab {
  211. if (!_sizeLab) {
  212. _sizeLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  213. _sizeLab.mj_size = CGSizeMake(KScreenWidth-20, 45);
  214. _sizeLab.backgroundColor = [UIColor colorWithHexString:@"#113632"];
  215. _sizeLab.textAlignment = NSTextAlignmentLeft;
  216. _sizeLab.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
  217. _sizeLab.font = [UIFont fontWithName:Rob_Bold size:14];
  218. _sizeLab.text = @"Size Selection";
  219. _sizeLab.layer.cornerRadius = 4;
  220. _sizeLab.clipsToBounds = YES;
  221. _sizeLab.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  222. UIImageView *imgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"base_add_white"]];
  223. imgV.frame = CGRectMake(_sizeLab.mj_w-45-10, 0, 45, 45);
  224. imgV.userInteractionEnabled = YES;
  225. imgV.contentMode = UIViewContentModeCenter;
  226. [_sizeLab addSubview:imgV];
  227. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap_sizeLab)];
  228. [_sizeLab addGestureRecognizer:tap];
  229. }
  230. return _sizeLab;
  231. }
  232. -(GoodsDetailsPayV *)datails_payV{
  233. if (!_datails_payV) {
  234. _datails_payV = [[GoodsDetailsPayV alloc]initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 78)];
  235. _datails_payV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  236. _datails_payV.layer.cornerRadius = 4;
  237. _datails_payV.clipsToBounds = YES;
  238. }
  239. return _datails_payV;
  240. }
  241. - (GoodsDetailsIntroduceV *)datails_IntroduceV {
  242. if (!_datails_IntroduceV) {
  243. _datails_IntroduceV = [[GoodsDetailsIntroduceV alloc] initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 120)];
  244. _datails_IntroduceV.backgroundColor = _F5F5F5;
  245. _datails_IntroduceV.clipsToBounds = YES;
  246. }
  247. return _datails_IntroduceV;
  248. }
  249. @end