dkahgld

ZBHotSaleListCell.m 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. //
  2. // ZBHotSaleListCell.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/19.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBHotSaleListCell.h"
  9. @implementation ZBHotSaleListCell
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. self.layer.cornerRadius=6;
  15. self.layer.masksToBounds=YES;
  16. self.backgroundColor=[UIColor whiteColor];
  17. [self addSubview:self.goodImgV];
  18. [self addSubview:self.titleLabel];
  19. [self addSubview:self.shopImg];
  20. [self addSubview:self.shopLabel];
  21. [self addSubview:self.priceLabel];
  22. [self addSubview:self.saleImgV];
  23. [self.saleImgV addSubview:self.salesCountL];
  24. [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.width.height.mas_equalTo(110);
  26. make.top.left.mas_equalTo(10);
  27. }];
  28. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.mas_equalTo(self.goodImgV.mas_right).offset(9);
  30. make.right.mas_equalTo(-9);
  31. make.top.mas_equalTo(self.goodImgV.mas_top).offset(5);
  32. make.height.mas_equalTo(22);
  33. }];
  34. [self.shopImg mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.width.height.mas_equalTo(14);
  36. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  37. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
  38. }];
  39. [self.shopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.mas_equalTo(self.shopImg.mas_right).offset(5);
  41. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9);
  42. make.height.mas_equalTo(16);
  43. make.right.mas_equalTo(-10);
  44. }];
  45. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(7);
  47. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  48. make.height.mas_equalTo(22);
  49. }];
  50. [self.saleImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(9);
  52. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  53. make.height.mas_equalTo(18);
  54. make.width.mas_equalTo(100);
  55. }];
  56. [self.salesCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.right.mas_equalTo(-5);
  58. make.top.mas_equalTo(0);
  59. make.left.mas_equalTo(24);
  60. make.bottom.mas_equalTo(0);
  61. make.height.mas_equalTo(18);
  62. }];
  63. }
  64. return self;
  65. }
  66. -(void)setModel:(ZBGoodModel *)model
  67. {
  68. _model= model;
  69. [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]];
  70. self.titleLabel.text=model.title;
  71. if (model.shop_type.integerValue == 1) {
  72. self.shopImg.image =[UIImage imageNamed:@"tm_icon"];
  73. }else{
  74. self.shopImg.image =[UIImage imageNamed:@"taobao_icon"];
  75. }
  76. self.shopLabel.text=model.shop_title;
  77. self.salesCountL.text=[NSString stringWithFormat:@"月销%@",model.volume];
  78. NSString *timetitle= [NSString stringWithFormat:@"¥%@/利润%@",model.discount_price,model.commission_rate];
  79. NSString *prices =[NSString stringWithFormat:@"¥%@/",model.discount_price];
  80. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  81. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x333333] range:NSMakeRange(0,prices.length)];
  82. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
  83. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF7D00] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
  84. self.priceLabel.attributedText=timestr;
  85. }
  86. -(UIImageView *)saleImgV
  87. {
  88. if (!_saleImgV) {
  89. _saleImgV=[[UIImageView alloc]init];
  90. _saleImgV.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xDDC179] toColor:[UIColor YHColorWithHex:0xC19E43] withWidth:100];
  91. _saleImgV.layer.cornerRadius=9;
  92. _saleImgV.layer.masksToBounds=YES;
  93. }
  94. return _saleImgV;
  95. }
  96. -(UIImageView *)goodImgV
  97. {
  98. if (!_goodImgV) {
  99. _goodImgV=[[UIImageView alloc]init];
  100. _goodImgV.backgroundColor=[UIColor lineColor];
  101. _goodImgV.layer.cornerRadius=4;
  102. _goodImgV.layer.masksToBounds=YES;
  103. }
  104. return _goodImgV;
  105. }
  106. -(UILabel *)titleLabel
  107. {
  108. if (!_titleLabel) {
  109. _titleLabel=[[UILabel alloc]init];
  110. _titleLabel.font=[UIFont systemFontOfSize:15];
  111. _titleLabel.textColor=[UIColor YHColorWithHex:0x333333];
  112. _titleLabel.text=@"---------";
  113. }
  114. return _titleLabel;
  115. }
  116. -(UILabel *)priceLabel
  117. {
  118. if (!_priceLabel) {
  119. _priceLabel=[[UILabel alloc]init];
  120. _priceLabel.font=[UIFont systemFontOfSize:16];
  121. _priceLabel.textColor=[UIColor YHColorWithHex:0x393939];
  122. _priceLabel.text=@"¥---";
  123. }
  124. return _priceLabel;
  125. }
  126. -(UIImageView *)shopImg
  127. {
  128. if (!_shopImg) {
  129. _shopImg =[[UIImageView alloc]init];
  130. [_shopImg setImage:[UIImage imageNamed:@"tm_icon"]];
  131. _shopImg.layer.cornerRadius=3;
  132. _shopImg.layer.masksToBounds=YES;
  133. }
  134. return _shopImg;
  135. }
  136. -(UILabel *)shopLabel
  137. {
  138. if (!_shopLabel) {
  139. _shopLabel=[[UILabel alloc]init];
  140. _shopLabel.text=@"----";
  141. _shopLabel.textColor=[UIColor YHColorWithHex:0x8D8A8A];
  142. _shopLabel.font=[UIFont systemFontOfSize:11];
  143. }
  144. return _shopLabel;
  145. }
  146. -(UILabel *)salesCountL
  147. {
  148. if (!_salesCountL) {
  149. _salesCountL=[[UILabel alloc]init];
  150. _salesCountL.text=@"月销--";
  151. _salesCountL.textColor=[UIColor whiteColor];
  152. _salesCountL.font=[UIFont systemFontOfSize:10];
  153. }
  154. return _salesCountL;
  155. }
  156. @end