ASGoodsTitlePriceCell.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // ASGoodsTitlePriceCell.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/20.
  6. //
  7. #import "ASGoodsTitlePriceCell.h"
  8. @interface ASGoodsTitlePriceCell()
  9. @property (nonatomic, strong) QMUILabel *titleLab;
  10. @property (nonatomic, strong) QMUILabel *soldLab;
  11. @property (nonatomic, strong) QMUILabel *reviewsLab;
  12. @property (nonatomic, strong) QMUILabel *priceLab;
  13. @property (nonatomic, strong) QMUILabel *saveLab;
  14. @end
  15. @implementation ASGoodsTitlePriceCell
  16. - (void)setupSubviewS{
  17. // self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  18. [self.contentView addSubview:self.titleLab];
  19. [self.contentView addSubview:self.soldLab];
  20. [self.contentView addSubview:self.reviewsLab];
  21. [self.contentView addSubview:self.priceLab];
  22. [self.contentView addSubview:self.saveLab];
  23. [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.mas_equalTo(10);
  25. make.width.mas_equalTo(KScreenWidth-20);
  26. make.top.mas_equalTo(10);
  27. make.height.mas_lessThanOrEqualTo(45);
  28. }];
  29. [self.soldLab mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.mas_equalTo(10);
  31. make.height.mas_equalTo(16);
  32. make.top.equalTo(self.titleLab.mas_bottom).offset(10);
  33. }];
  34. [self.reviewsLab mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.right.equalTo(self.titleLab.mas_right);
  36. make.height.mas_equalTo(16);
  37. make.top.equalTo(self.titleLab.mas_bottom).offset(10);
  38. }];
  39. [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.mas_equalTo(10);
  41. make.top.equalTo(self.reviewsLab.mas_bottom).offset(20);
  42. make.height.mas_equalTo(24);
  43. make.bottom.mas_equalTo(-10);
  44. }];
  45. [self.saveLab mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.equalTo(self.priceLab.mas_right).offset(10);
  47. make.height.mas_equalTo(20);
  48. make.centerY.equalTo(self.priceLab);
  49. }];
  50. }
  51. - (void)configData:(id)Data{
  52. GoodsInformationM *model = (GoodsInformationM *)Data;
  53. _infoModel = model;
  54. self.titleLab.text =MM_str(model.name);
  55. self.soldLab.text = [NSString stringWithFormat:@"SOLD: %@",model.sold] ;
  56. NSMutableAttributedString *reviewsStr = [[NSMutableAttributedString alloc]
  57. initWithString:[NSString stringWithFormat:@"REVIEWS:%@",model.review_nums]];
  58. NSRange contentRange = {0,[reviewsStr length]};
  59. [reviewsStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
  60. self.reviewsLab.attributedText = reviewsStr;
  61. self.reviewsLab.textAlignment = NSTextAlignmentRight;
  62. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,model.final_prices]];
  63. [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
  64. [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
  65. NSString *saveStr = @"";
  66. if(model.final_prices == model.price){
  67. self.saveLab.hidden = YES;
  68. }else{
  69. self.saveLab.hidden = NO;
  70. double savePrice = [model.price doubleValue]-[model.final_prices doubleValue];
  71. saveStr = [NSString stringWithFormat:@"Save %@%.2f",model.currency_symbol,savePrice];
  72. [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@" "]];
  73. NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",model.price]];
  74. [priceAtrSub1 addAttribute:NSForegroundColorAttributeName
  75. value:[UIColor colorWithHexString:@"#8c8c8c"]
  76. range:NSMakeRange(0, priceAtrSub1.length)];
  77. [priceAtrSub1 addAttribute:NSFontAttributeName
  78. value:[UIFont fontWithName:Rob_Regular size:14]
  79. range:NSMakeRange(0, priceAtrSub1.length)];
  80. [priceAtrSub1 addAttribute:NSStrikethroughStyleAttributeName
  81. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  82. range:NSMakeRange(0, priceAtrSub1.length)];
  83. [priceAtr appendAttributedString:priceAtrSub1];
  84. }
  85. self.priceLab.attributedText = priceAtr;
  86. self.infoModel.priceAtr = priceAtr;
  87. self.saveLab.text = saveStr;
  88. }
  89. -(void)tap_reviewsClick{
  90. if (self.currencyparameterClose) {
  91. self.currencyparameterClose(1, self.infoModel);
  92. }
  93. }
  94. - (QMUILabel *)titleLab {
  95. if (!_titleLab) {
  96. _titleLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  97. _titleLab.textAlignment = NSTextAlignmentLeft;
  98. _titleLab.numberOfLines = 2;
  99. _titleLab.textColor = [UIColor colorWithHexString:@"#000000"];
  100. _titleLab.font = [UIFont fontWithName:Rob_Bold size:16];
  101. }
  102. return _titleLab;
  103. }
  104. - (QMUILabel *)soldLab {
  105. if (!_soldLab) {
  106. _soldLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  107. _soldLab.textAlignment = NSTextAlignmentLeft;
  108. _soldLab.textColor = [UIColor colorWithHexString:@"#666666"];
  109. _soldLab.font = [UIFont systemFontOfSize:12];
  110. }
  111. return _soldLab;
  112. }
  113. - (QMUILabel *)reviewsLab {
  114. if (!_reviewsLab) {
  115. _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  116. _reviewsLab.textAlignment = NSTextAlignmentRight;
  117. _reviewsLab.textColor = [UIColor colorWithHexString:@"#666666"];
  118. _reviewsLab.font = [UIFont fontWithName:Rob_Regular size:12];
  119. _reviewsLab.userInteractionEnabled = YES;
  120. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap_reviewsClick)];
  121. [_reviewsLab addGestureRecognizer:tap];
  122. // reviewsStr.underlineStyle = NSUnderlineStyleSingle;
  123. }
  124. return _reviewsLab;
  125. }
  126. - (QMUILabel *)priceLab {
  127. if (!_priceLab) {
  128. _priceLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  129. _priceLab.textAlignment = NSTextAlignmentLeft;
  130. _priceLab.textColor = [UIColor blackColor];
  131. _priceLab.font = [UIFont systemFontOfSize:18];
  132. }
  133. return _priceLab;
  134. }
  135. - (QMUILabel *)saveLab {
  136. if (!_saveLab) {
  137. _saveLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  138. _saveLab.contentEdgeInsets= UIEdgeInsetsMake(10, 10, 10, 10);
  139. _saveLab.backgroundColor = [UIColor colorWithHexString:@"#E0FFF5"];
  140. _saveLab.textAlignment = NSTextAlignmentCenter;
  141. _saveLab.textColor = [UIColor colorWithHexString:@"#113632"];
  142. _saveLab.font = [UIFont fontWithName:Rob_Bold size:12];
  143. }
  144. return _saveLab;
  145. }
  146. @end