酷店

KDPTodayListCell.m 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //
  2. // KDPTodayListCell.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPTodayListCell.h"
  9. @implementation KDPTodayListCell
  10. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self) {
  14. [self addSubview:self.todayGoodImgV];
  15. [self addSubview:self.todayTitleL];
  16. [self addSubview:self.numL];
  17. [self addSubview:self.timeLabel];
  18. [self addSubview:self.oldPriceL];
  19. [self addSubview:self.livePriceL];
  20. [self.todayGoodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.top.mas_equalTo(9);
  22. make.left.mas_equalTo(14);
  23. make.width.height.mas_equalTo(96);
  24. }];
  25. [self.todayTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.mas_equalTo(self.todayGoodImgV.mas_top);
  27. make.height.mas_equalTo(38);
  28. make.left.mas_equalTo(self.todayGoodImgV.mas_right).offset(10);
  29. make.right.mas_equalTo(-10);
  30. }];
  31. [self.oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.mas_equalTo(self.todayGoodImgV.mas_right).offset(10);
  33. make.height.mas_equalTo(16);
  34. make.top.mas_equalTo(self.todayTitleL.mas_bottom).offset(9);
  35. }];
  36. [self.livePriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(self.todayGoodImgV.mas_right).offset(10);
  38. make.height.mas_equalTo(22);
  39. make.top.mas_equalTo(self.oldPriceL.mas_bottom).offset(9);
  40. }];
  41. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.right.mas_equalTo(-10);
  43. make.bottom.mas_equalTo(self.mas_bottom).offset(-13);
  44. make.height.mas_equalTo(22);
  45. }];
  46. [self.numL mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.right.mas_equalTo(-10);
  48. make.height.mas_equalTo(22);
  49. make.top.mas_equalTo(self.livePriceL.mas_top);
  50. }];
  51. UIView *lineV=[[UIView alloc]init];
  52. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  53. [self addSubview:lineV];
  54. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.mas_equalTo(10);
  56. make.right.mas_equalTo(-10);
  57. make.top.mas_equalTo(self.mas_bottom).offset(-1);
  58. make.height.mas_equalTo(1);
  59. }];
  60. }
  61. return self;
  62. }
  63. -(UIImageView *)todayGoodImgV
  64. {
  65. if (!_todayGoodImgV) {
  66. _todayGoodImgV=[[UIImageView alloc]init];
  67. _todayGoodImgV.layer.cornerRadius=5;
  68. _todayGoodImgV.layer.masksToBounds=YES;
  69. _todayGoodImgV.backgroundColor=[UIColor colorWithHexString:LineColor];
  70. }
  71. return _todayGoodImgV;
  72. }
  73. -(UILabel *)todayTitleL
  74. {
  75. if (!_todayTitleL) {
  76. _todayTitleL=[[UILabel alloc]init];
  77. _todayTitleL.numberOfLines=0;
  78. _todayTitleL.text=@"---";
  79. _todayTitleL.font=[UIFont systemFontOfSize:14];
  80. _todayTitleL.textColor=[UIColor colorWithHexString:@"#333333"];
  81. }
  82. return _todayTitleL;
  83. }
  84. -(UILabel *)oldPriceL
  85. {
  86. if (!_oldPriceL) {
  87. _oldPriceL=[[UILabel alloc]init];
  88. _oldPriceL.textColor=[UIColor colorWithHexString:@"#BBB9BB"];
  89. _oldPriceL.text=@"--";
  90. _oldPriceL.font=[UIFont systemFontOfSize:11];
  91. }
  92. return _oldPriceL;
  93. }
  94. -(UILabel *)livePriceL
  95. {
  96. if (!_livePriceL) {
  97. _livePriceL=[[UILabel alloc]init];
  98. _livePriceL.textColor=[UIColor colorWithHexString:@"#BBB9BB"];
  99. _livePriceL.text=@"---";
  100. _livePriceL.font=[UIFont systemFontOfSize:12];
  101. }
  102. return _livePriceL;
  103. }
  104. -(UILabel *)timeLabel
  105. {
  106. if (!_timeLabel) {
  107. _timeLabel=[[UILabel alloc]init];
  108. _timeLabel.font=[UIFont systemFontOfSize:11];
  109. _timeLabel.textColor=[UIColor colorWithHexString:@"#BBB9BB"];
  110. }
  111. return _timeLabel;
  112. }
  113. -(UILabel *)numL
  114. {
  115. if (!_numL) {
  116. _numL=[[UILabel alloc]init];
  117. _numL.font=[UIFont systemFontOfSize:16];
  118. _numL.backgroundColor=[UIColor colorWithHexString:ThemeColor];
  119. _numL.text=@" --人下单 ";
  120. _numL.textColor=[UIColor whiteColor];
  121. _numL.layer.cornerRadius=4;
  122. _numL.layer.masksToBounds=YES;
  123. _numL.textAlignment=NSTextAlignmentCenter;
  124. }
  125. return _numL;
  126. }
  127. -(void)setModel:(KDPGoodsModel *)model
  128. {
  129. _model=model;
  130. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.zk_final_price];
  131. //中划线
  132. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  133. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  134. // 赋值
  135. self.oldPriceL.attributedText = attribtStr;
  136. self.numL.text=[NSString stringWithFormat:@" %@人下单 ",model.order_count];
  137. //计算下单时间
  138. NSString *imter= [KDPublicMethod CalculateCurrentDate:model.create_at];
  139. NSString *timetitle= [NSString stringWithFormat:@"%@前下单",imter];
  140. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  141. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#FC6708"] range:NSMakeRange(0,timetitle.length-3)];
  142. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,timetitle.length-3)]; //设置字体字号和字体类别
  143. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#ADAAAD"] range:NSMakeRange(timetitle.length-3,3)];
  144. _timeLabel.attributedText = timestr;
  145. NSString *title=[NSString stringWithFormat:@"直播价¥%@",model.discount_price];
  146. NSMutableAttributedString *newstr = [[NSMutableAttributedString alloc] initWithString:title];
  147. [newstr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#ADAAAD"] range:NSMakeRange(0,3)];
  148. [newstr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体字号和字体类别
  149. [newstr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#393939"] range:NSMakeRange(3,title.length-3)];
  150. self.livePriceL.attributedText = newstr;
  151. self.todayTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:model.name linSpacing:5];
  152. [self.todayGoodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]];
  153. }
  154. @end