酷店

KDPForecastOrderCell.m 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // KDPForecastOrderCell.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/8.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPForecastOrderCell.h"
  9. @implementation KDPForecastOrderCell
  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.addTimeL];
  16. [self addSubview:self.moneyL];
  17. [self addSubview:self.accountLabel];
  18. [self addSubview:self.forecastLabel];
  19. [self addSubview:self.goodTitleLabel];
  20. [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.left.top.mas_equalTo(10);
  22. make.width.height.mas_equalTo(90);
  23. }];
  24. [self.goodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.top.mas_equalTo(self.goodImgV.mas_top);
  26. make.left.mas_equalTo(self.goodImgV.mas_right).offset(9);
  27. make.right.mas_equalTo(-10);
  28. make.height.mas_equalTo(42);
  29. }];
  30. [self.addTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.mas_equalTo(self.goodTitleLabel.mas_bottom).offset(6);
  32. make.height.mas_equalTo(17);
  33. make.left.mas_equalTo(self.goodTitleLabel.mas_left);
  34. }];
  35. [self.accountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.mas_equalTo(self.goodTitleLabel.mas_bottom).offset(6);
  37. make.height.mas_equalTo(17);
  38. make.right.mas_equalTo(-10);
  39. }];
  40. [self.moneyL mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.mas_equalTo(self.goodTitleLabel.mas_left);
  42. make.height.mas_equalTo(17);
  43. make.top.mas_equalTo(self.addTimeL.mas_bottom).offset(10);
  44. }];
  45. [self.forecastLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.right.mas_equalTo(-10);
  47. make.height.mas_equalTo(17);
  48. make.top.mas_equalTo(self.addTimeL.mas_bottom).offset(10);
  49. }];
  50. }
  51. return self;
  52. }
  53. -(void)setModel:(KDPOrderModel *)model
  54. {
  55. _model = model;
  56. self.goodTitleLabel.text=model.name;
  57. self.addTimeL.text=[NSString stringWithFormat:@"创建日:%@",model.order_create_at];
  58. [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]];
  59. NSMutableAttributedString *forastcaStr;
  60. switch ([model.status integerValue]) {//0已失效 1已付款 2已结算 status
  61. case 0:
  62. {
  63. NSString *legalStr=@"";
  64. switch ([model.maintain_power integerValue]) {//0不维权 1维权申请 2维权失败 3维权成功
  65. case 1:
  66. {
  67. legalStr=@"维权申请";
  68. }
  69. break;
  70. case 2:
  71. {
  72. legalStr=@"维权失败";
  73. }
  74. break;
  75. case 3:
  76. {
  77. legalStr=@"已失效";
  78. }
  79. break;
  80. default:
  81. break;
  82. }
  83. self.accountLabel.text=legalStr;
  84. forastcaStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已失效¥ %@",model.rebate]];
  85. [forastcaStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#FF1E00"] range:NSMakeRange(0, forastcaStr.length)];
  86. [forastcaStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, forastcaStr.length)];
  87. }
  88. break;
  89. case 1:
  90. {
  91. self.accountLabel.text=@"已付款";
  92. forastcaStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"待结算¥ %@",model.rebate]];
  93. [forastcaStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#3E97FF"] range:NSMakeRange(0, forastcaStr.length)];
  94. }
  95. break;
  96. case 2:
  97. {
  98. self.accountLabel.text= [NSString stringWithFormat:@"结算日:%@",model.order_balance_at];
  99. forastcaStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已结算¥ %@",model.rebate]];
  100. [forastcaStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#FF1E00"] range:NSMakeRange(0, forastcaStr.length)];
  101. }
  102. break;
  103. default:
  104. break;
  105. }
  106. if (forastcaStr) {
  107. [forastcaStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 7)];
  108. [forastcaStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(7,forastcaStr.length-7)];
  109. self.forecastLabel.attributedText = forastcaStr;
  110. }
  111. self.moneyL.text=[NSString stringWithFormat:@"付款金额 ¥%@",model.money];
  112. }
  113. -(UIImageView *)goodImgV
  114. {
  115. if (!_goodImgV) {
  116. _goodImgV=[[UIImageView alloc]init];
  117. _goodImgV.backgroundColor=[UIColor colorWithHexString:LineColor];
  118. }
  119. return _goodImgV;
  120. }
  121. -(UILabel *)goodTitleLabel
  122. {
  123. if (!_goodTitleLabel) {
  124. _goodTitleLabel=[[UILabel alloc]init];
  125. _goodTitleLabel.numberOfLines=0;
  126. _goodTitleLabel.font=[UIFont systemFontOfSize:15];
  127. _goodTitleLabel.textColor=[UIColor colorWithHexString:fontColor];
  128. }
  129. return _goodTitleLabel;
  130. }
  131. -(UILabel *)addTimeL
  132. {
  133. if (!_addTimeL) {
  134. _addTimeL=[[UILabel alloc]init];
  135. _addTimeL.textColor=[UIColor colorWithHexString:@"#999999"];
  136. _addTimeL.font=[UIFont systemFontOfSize:12];
  137. _addTimeL.text=@"创建日:--";
  138. }
  139. return _addTimeL;
  140. }
  141. -(UILabel *)accountLabel
  142. {
  143. if (!_accountLabel) {
  144. _accountLabel=[[UILabel alloc]init];
  145. _accountLabel.textColor=[UIColor colorWithHexString:@"#999999"];
  146. _accountLabel.font=[UIFont systemFontOfSize:12];
  147. _accountLabel.text=@"结算日:--";
  148. }
  149. return _accountLabel;
  150. }
  151. -(UILabel *)moneyL
  152. {
  153. if (!_moneyL) {
  154. _moneyL=[[UILabel alloc]init];
  155. _moneyL.textColor=[UIColor colorWithHexString:@"#4A4A4A"];
  156. _moneyL.font=[UIFont systemFontOfSize:12];
  157. _moneyL.text=@"付款金额¥--";
  158. }
  159. return _moneyL;
  160. }
  161. -(UILabel *)forecastLabel
  162. {
  163. if (!_forecastLabel) {
  164. _forecastLabel=[[UILabel alloc]init];
  165. _forecastLabel.textColor=[UIColor colorWithHexString:@"#666666"];
  166. _forecastLabel.font=[UIFont systemFontOfSize:12];
  167. NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"结算佣金¥-.--"];
  168. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(0, 6)];
  169. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(5,AttributedStr.length-5)];
  170. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#666666"] range:NSMakeRange(0, 5)];
  171. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(5,AttributedStr.length-5)];
  172. _forecastLabel.attributedText=AttributedStr;
  173. }
  174. return _forecastLabel;
  175. }
  176. @end