猎豆优选

LDGroupChildGoodCell.m 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // LDGroupChildGoodCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/12/13.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDGroupChildGoodCell.h"
  9. @interface LDGroupChildGoodCell ()
  10. @property (nonatomic, strong) UIImageView *imgView; //大图
  11. @property (nonatomic, strong) UILabel *titleLabel; //标题
  12. @property (nonatomic, strong) UIImageView *ticketNumber; //
  13. @property (nonatomic, strong) UILabel *ticketType;
  14. @property (nonatomic, strong) UILabel *zheKou; //
  15. @property (nonatomic, strong) YYLabel *disPriceL; // 优惠后价格
  16. @property (nonatomic, strong) UIImageView *commissionBg;
  17. @property (nonatomic, strong) UILabel *commissionLabel;
  18. @end
  19. @implementation LDGroupChildGoodCell
  20. - (instancetype)initWithFrame:(CGRect)frame
  21. {
  22. self = [super initWithFrame:frame];
  23. if (self) {
  24. self.backgroundColor = [UIColor whiteColor];
  25. self.layer.cornerRadius = 4;
  26. self.layer.masksToBounds = YES;
  27. [self initSubViews];
  28. }
  29. return self;
  30. }
  31. - (void)initSubViews {
  32. [self.contentView addSubview:self.imgView];
  33. [self.contentView addSubview:self.titleLabel];
  34. [self.contentView addSubview:self.ticketNumber];
  35. [self.ticketNumber addSubview:self.ticketType];
  36. [self.ticketNumber addSubview:self.zheKou];
  37. [self.contentView addSubview:self.disPriceL];
  38. [self.contentView addSubview:self.commissionBg];
  39. [self.commissionBg addSubview:self.commissionLabel];
  40. [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.right.left.mas_equalTo(0);
  42. make.height.mas_equalTo(Fitsize(115));
  43. }];
  44. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(5);
  46. make.right.mas_equalTo(-5);
  47. make.top.mas_equalTo(self.imgView.mas_bottom).mas_offset(Fitsize(5));
  48. }];
  49. [self.disPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(3);
  51. make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(Fitsize(8));
  52. }];
  53. [self.ticketNumber mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.right.mas_equalTo(-5);
  55. make.width.mas_equalTo(52);
  56. make.height.mas_equalTo(52*14/64);
  57. make.centerY.mas_equalTo(self.disPriceL.mas_centerY);
  58. }];
  59. [self.ticketType mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.top.bottom.mas_equalTo(0);
  61. make.width.mas_equalTo(14);
  62. }];
  63. [self.zheKou mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.left.mas_equalTo(self.ticketType.mas_right);
  65. make.top.mas_equalTo(0);
  66. make.height.mas_equalTo(52*14/64);
  67. make.width.mas_equalTo(38);
  68. }];
  69. [self.commissionBg mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.right.mas_equalTo(0);
  71. make.bottom.mas_equalTo(self.imgView.mas_bottom).mas_offset(-10);
  72. make.width.mas_equalTo(40);
  73. make.height.mas_equalTo(40*27/69);
  74. }];
  75. [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(4);
  77. make.right.mas_equalTo(-2);
  78. make.centerY.mas_equalTo(self.commissionBg.mas_centerY);
  79. }];
  80. }
  81. - (void)setModel:(LDChildGoodModel *)model {
  82. _model = model;
  83. self.titleLabel.text = model.title;
  84. [self.imgView sd_setFadeImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:0 progress:nil completed:nil];
  85. self.disPriceL.text = [NSString stringWithFormat:@"¥%.2f",[model.discount_price floatValue]];
  86. //折后价
  87. if ([model.is_coupon boolValue]) {
  88. self.zheKou.text = [NSString stringWithFormat:@"%@元",model.coupon_price];
  89. self.ticketType.text = @"券";
  90. }else {
  91. self.zheKou.text = [NSString stringWithFormat:@"%@折",model.coupon_price];
  92. self.ticketType.text = @"折";
  93. }
  94. self.ticketNumber.hidden = ![model.is_coupon boolValue];
  95. //
  96. self.commissionLabel.text = [NSString stringWithFormat:@"赚¥%.2f",[model.commission_price floatValue]];
  97. if (model.commission_price.length > 0) {
  98. self.commissionBg.hidden = NO;
  99. }else {
  100. self.commissionBg.hidden = YES;
  101. }
  102. self.commissionBg.hidden = YES;
  103. }
  104. - (UIImageView *)imgView {
  105. if (!_imgView) {
  106. _imgView = [[UIImageView alloc] init];
  107. _imgView.backgroundColor = [UIColor yhGrayColor];
  108. }
  109. return _imgView;
  110. }
  111. - (UILabel *)titleLabel {
  112. if (!_titleLabel) {
  113. _titleLabel = [[UILabel alloc] init];
  114. _titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
  115. _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
  116. _titleLabel.numberOfLines = 1;
  117. }
  118. return _titleLabel;
  119. }
  120. - (UIImageView *)ticketNumber {
  121. if (!_ticketNumber) {
  122. _ticketNumber = [[UIImageView alloc] init];
  123. _ticketNumber.image = [UIImage imageNamed:@"quan_bg"];
  124. }
  125. return _ticketNumber;
  126. }
  127. - (UILabel *)zheKou {
  128. if (!_zheKou) {
  129. _zheKou = [[UILabel alloc] init];
  130. _zheKou.textColor = [UIColor homeRedColor];
  131. _zheKou.textAlignment = NSTextAlignmentCenter;
  132. _zheKou.font = [UIFont systemFontOfSize:9];
  133. }
  134. return _zheKou;
  135. }
  136. - (UILabel *)ticketType {
  137. if (!_ticketType) {
  138. _ticketType = [[UILabel alloc] init];
  139. _ticketType.font = [UIFont systemFontOfSize:8];
  140. _ticketType.textAlignment = NSTextAlignmentCenter;
  141. _ticketType.textColor = [UIColor homeRedColor];
  142. }
  143. return _ticketType;
  144. }
  145. - (YYLabel *)disPriceL {
  146. if (!_disPriceL) {
  147. _disPriceL = [[YYLabel alloc] init];
  148. _disPriceL.displaysAsynchronously = YES;
  149. _disPriceL.font = [UIFont systemFontOfSize:12];
  150. _disPriceL.textColor = [UIColor homeRedColor];
  151. }
  152. return _disPriceL;
  153. }
  154. - (UIImageView *)commissionBg {
  155. if (!_commissionBg) {
  156. _commissionBg = [[UIImageView alloc] init];
  157. _commissionBg.image = [UIImage imageNamed:@"Shape"];
  158. }
  159. return _commissionBg;
  160. }
  161. - (UILabel *)commissionLabel {
  162. if (!_commissionLabel) {
  163. _commissionLabel = [[UILabel alloc] init];
  164. _commissionLabel.textAlignment = NSTextAlignmentCenter;
  165. _commissionLabel.font = [UIFont systemFontOfSize:8];
  166. _commissionLabel.adjustsFontSizeToFitWidth = YES;
  167. _commissionLabel.textColor = [UIColor whiteColor];
  168. }
  169. return _commissionLabel;
  170. }
  171. @end