酷店

KDPHistoryListCell.m 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // KDPHistoryListCell.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPHistoryListCell.h"
  9. @implementation KDPHistoryListCell
  10. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self) {
  14. [self addSubview:self.goodImgV];
  15. [self addSubview:self.deleteButton];
  16. [self addSubview:self.priceLabel];
  17. [self addSubview:self.goodTitleL];
  18. [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  19. make.left.mas_equalTo(16);
  20. make.top.mas_equalTo(9);
  21. make.width.height.mas_equalTo(90);
  22. }];
  23. [self.goodTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.height.mas_equalTo(49);
  25. make.top.mas_equalTo(self.goodImgV.mas_top);
  26. make.left.mas_equalTo(self.goodImgV.mas_right).offset(13);
  27. make.right.mas_equalTo(-15);
  28. }];
  29. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.mas_equalTo(self.goodTitleL.mas_left);
  31. make.top.mas_equalTo(self.goodTitleL.mas_bottom).offset(12);
  32. make.height.mas_equalTo(22);
  33. }];
  34. [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.height.width.mas_equalTo(22);
  36. make.top.mas_equalTo(self.priceLabel.mas_top);
  37. make.right.mas_equalTo(-15);
  38. }];
  39. UIView *lineV=[[UIView alloc]init];
  40. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  41. [self addSubview:lineV];
  42. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(10);
  44. make.right.mas_equalTo(-10);
  45. make.top.mas_equalTo(self.mas_bottom).offset(-1);
  46. make.height.mas_equalTo(1);
  47. }];
  48. }
  49. return self;
  50. }
  51. -(UILabel *)goodTitleL
  52. {
  53. if (!_goodTitleL) {
  54. _goodTitleL=[[UILabel alloc]init];
  55. _goodTitleL.text=@"---";
  56. _goodTitleL.numberOfLines=0;
  57. _goodTitleL.textColor=[UIColor colorWithHexString:fontColor];
  58. _goodTitleL.font=[UIFont systemFontOfSize:15];
  59. }
  60. return _goodTitleL;
  61. }
  62. -(UIButton *)deleteButton
  63. {
  64. if (!_deleteButton) {
  65. _deleteButton=[[UIButton alloc]init];
  66. [_deleteButton setImage:[UIImage imageNamed:@"delete_collection"] forState:UIControlStateNormal];
  67. _deleteButton.adjustsImageWhenHighlighted=NO;
  68. [_deleteButton addTarget:self action:@selector(deleteClickBtn) forControlEvents:UIControlEventTouchUpInside];
  69. }
  70. return _deleteButton;
  71. }
  72. -(UILabel *)priceLabel
  73. {
  74. if (!_priceLabel) {
  75. _priceLabel=[[UILabel alloc]init];
  76. _priceLabel.text=@"---";
  77. _priceLabel.font=[UIFont systemFontOfSize:16];
  78. NSString *prid=@"¥--.- /";
  79. NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ 利润--",prid]];
  80. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(0, prid.length)];
  81. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(prid.length,AttributedStr.length-prid.length)];
  82. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(0, prid.length)];
  83. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(prid.length,AttributedStr.length-prid.length)];
  84. _priceLabel.attributedText=AttributedStr;
  85. }
  86. return _priceLabel;
  87. }
  88. -(UIImageView *)goodImgV
  89. {
  90. if (!_goodImgV) {
  91. _goodImgV=[[UIImageView alloc]init];
  92. _goodImgV.backgroundColor=[UIColor colorWithHexString:LineColor];
  93. _goodImgV.layer.cornerRadius=4;
  94. _goodImgV.layer.masksToBounds=YES;
  95. }
  96. return _goodImgV;
  97. }
  98. -(void)setModel:(KDPGoodsModel *)model
  99. {
  100. _model = model;
  101. [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]];
  102. self.goodTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:model.title linSpacing:5];
  103. NSString *timetitle= [NSString stringWithFormat:@"¥%@/利润%@",model.discount_price,model.commission_rate];
  104. NSString *prices =[NSString stringWithFormat:@"¥%@/",model.discount_price];
  105. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  106. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(0,prices.length)];
  107. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
  108. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
  109. self.priceLabel.attributedText=timestr;
  110. }
  111. -(void)deleteClickBtn
  112. {
  113. if (self.deleteBlock) {
  114. self.deleteBlock(self.model);
  115. }
  116. }
  117. @end