《省钱达人》与《猎豆优选》UI相同版。域名tbk

KBNativeShopCarCollectionCell.m 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. //
  2. // KBNativeShopCarCollectionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/11/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBNativeShopCarCollectionCell.h"
  9. @interface KBNativeShopCarCollectionCell ()
  10. @property (nonatomic, strong) UIImageView *icon;
  11. @property (nonatomic, strong) UILabel *title;
  12. @property (nonatomic, strong) YYLabel *couple_price;
  13. @property (nonatomic, strong) YYLabel *price;
  14. @property (nonatomic, strong) YYLabel *endTime;
  15. @property (nonatomic, strong) UILabel *commissionLabel;
  16. @property (nonatomic, strong) UIImageView *discountImgV;
  17. @property (nonatomic, strong) UILabel *numlabel;
  18. @end
  19. @implementation KBNativeShopCarCollectionCell
  20. - (instancetype)initWithFrame:(CGRect)frame
  21. {
  22. self = [super initWithFrame:frame];
  23. if (self) {
  24. self.contentView.backgroundColor = [UIColor whiteColor];
  25. [self initSubViews];
  26. }
  27. return self;
  28. }
  29. - (void)initSubViews {
  30. [self.contentView addSubview:self.icon];
  31. [self.contentView addSubview:self.title];
  32. [self.contentView addSubview:self.couple_price];
  33. [self.contentView addSubview:self.price];
  34. [self.contentView addSubview:self.endTime];
  35. [self.icon addSubview:self.commissionLabel];
  36. [self.contentView addSubview:self.discountImgV];
  37. [self.discountImgV addSubview:self.numlabel];
  38. [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.left.mas_equalTo(10);
  40. make.top.mas_equalTo(0);
  41. make.width.height.mas_equalTo(100);
  42. }];
  43. [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(self.icon.mas_right).mas_offset(5);
  45. make.top.mas_equalTo(self.icon.mas_top);
  46. make.height.mas_equalTo(40);
  47. make.right.mas_equalTo(-10);
  48. }];
  49. [self.endTime mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(self.title.mas_left);
  51. make.bottom.mas_equalTo(self.icon.mas_bottom);
  52. }];
  53. [self.couple_price mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(self.title.mas_left);
  55. make.top.mas_equalTo(self.title.mas_bottom).mas_offset(10);
  56. }];
  57. [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.mas_equalTo(self.couple_price.mas_right).mas_offset(20);
  59. make.bottom.mas_equalTo(self.couple_price.mas_bottom);
  60. }];
  61. [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.right.bottom.mas_equalTo(0);
  63. make.height.mas_equalTo(12);
  64. }];
  65. [self.discountImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(self.title.mas_left);
  67. make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
  68. make.width.mas_equalTo(FITSIZE(60));
  69. make.height.mas_equalTo(FITSIZE(15));
  70. }];
  71. [self.numlabel mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.mas_equalTo(20);
  73. make.top.mas_equalTo(0);
  74. make.width.mas_equalTo(FITSIZE(40));
  75. make.height.mas_equalTo(FITSIZE(15));
  76. }];
  77. }
  78. - (void)setModel:(DRChildGoodModel *)model {
  79. _model = model;
  80. [self.icon sd_setFadeImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:0 progress:nil completed:nil];
  81. self.title.text = model.title;
  82. self.couple_price.text = [NSString stringWithFormat:@"¥%@",model.discount_price];
  83. self.couple_price.font = [UIFont systemFontOfSize:16];
  84. self.endTime.hidden =YES;
  85. self.price.hidden = ![model.is_coupon boolValue];
  86. self.commissionLabel.hidden = YES;
  87. self.discountImgV.hidden= ![model.is_coupon boolValue];
  88. if (model.is_coupon.integerValue == 1) {//佣金和优惠券都存在的时候
  89. self.numlabel.text = [NSString stringWithFormat:@"¥%@",model.coupon_price];
  90. }
  91. }
  92. #pragma mark -----
  93. - (UIImageView *)icon {
  94. if (!_icon) {
  95. _icon = [[UIImageView alloc] init];
  96. _icon.layer.cornerRadius = 6;
  97. _icon.layer.masksToBounds=YES;
  98. _icon.backgroundColor = [UIColor yhGrayColor];
  99. }
  100. return _icon;
  101. }
  102. - (UILabel *)title {
  103. if (!_title) {
  104. _title = [[UILabel alloc] init];
  105. _title.numberOfLines = 2;
  106. _title.font = [UIFont systemFontOfSize:14];
  107. }
  108. return _title;
  109. }
  110. - (YYLabel *)couple_price {
  111. if (!_couple_price) {
  112. _couple_price = [[YYLabel alloc] init];
  113. _couple_price.textColor = [UIColor YHColorWithHex:0xEE000E];
  114. _couple_price.font = [UIFont systemFontOfSize:18];
  115. _couple_price.displaysAsynchronously = YES;
  116. }
  117. return _couple_price;
  118. }
  119. - (YYLabel *)price {
  120. if (!_price) {
  121. _price = [[YYLabel alloc] init];
  122. _price.textColor = [UIColor YHColorWithHex:0xA2A0A0];
  123. _price.font = [UIFont systemFontOfSize:12];
  124. _price.displaysAsynchronously = YES;
  125. }
  126. return _price;
  127. }
  128. - (YYLabel *)endTime {
  129. if (!_endTime) {
  130. _endTime = [[YYLabel alloc] init];
  131. _endTime.font = [UIFont systemFontOfSize:11];
  132. _endTime.textColor = [UIColor YHColorWithHex:0xA2A0A0];
  133. _endTime.displaysAsynchronously = YES;
  134. }
  135. return _endTime;
  136. }
  137. - (UILabel *)commissionLabel {
  138. if (!_commissionLabel) {
  139. _commissionLabel = [[UILabel alloc] init];
  140. _commissionLabel.font = [UIFont systemFontOfSize:11];
  141. _commissionLabel.textColor = [UIColor whiteColor];
  142. _commissionLabel.textAlignment = NSTextAlignmentCenter;
  143. _commissionLabel.backgroundColor = [UIColor homeRedColor];
  144. _commissionLabel.adjustsFontSizeToFitWidth = YES;
  145. }
  146. return _commissionLabel;
  147. }
  148. -(UILabel *)numlabel
  149. {
  150. if (!_numlabel) {
  151. _numlabel =[[UILabel alloc]init];
  152. _numlabel.textColor=[UIColor YHColorWithHex:0xFA2D36];
  153. _numlabel.font=[UIFont systemFontOfSize:FITSIZE(10)];
  154. _numlabel.textAlignment=NSTextAlignmentCenter;
  155. }
  156. return _numlabel;
  157. }
  158. -(UIImageView *)discountImgV
  159. {
  160. if (!_discountImgV) {
  161. _discountImgV =[[UIImageView alloc]init];
  162. _discountImgV.image=[UIImage imageNamed:@"quan_bg"];
  163. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, FITSIZE(15))];
  164. label.textColor=[UIColor YHColorWithHex:0xFA2D36];
  165. label.font=[UIFont systemFontOfSize:FITSIZE(10)];
  166. label.textAlignment=NSTextAlignmentCenter;
  167. label.text=@"券";
  168. [_discountImgV addSubview:label];
  169. }
  170. return _discountImgV;
  171. }
  172. @end