省钱达人

DRChildCommissionCell.m 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. //
  2. // DRChildCommissionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRChildCommissionCell.h"
  9. #import "CCCopyLabel.h"
  10. @interface DRChildCommissionCell ()
  11. @property (nonatomic, strong) UIImageView *iconView;
  12. @property (nonatomic, strong) CCCopyLabel *titleLabel;
  13. @property (nonatomic, strong) UILabel *makeDate;
  14. @property (nonatomic, strong) UILabel *endDate;
  15. @property (nonatomic, strong) UILabel *buyPrice;
  16. @property (nonatomic, strong) UILabel *endPrice;
  17. @end
  18. @implementation DRChildCommissionCell
  19. + (instancetype)cellWithTableView:(UITableView *)tableView {
  20. static NSString *cellID = nil;
  21. cellID = NSStringFromClass([self class]);
  22. DRChildCommissionCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  23. if (!cell) {
  24. cell = [[DRChildCommissionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  25. }
  26. return cell;
  27. }
  28. - (void)awakeFromNib {
  29. [super awakeFromNib];
  30. // Initialization code
  31. }
  32. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  33. [super setSelected:selected animated:animated];
  34. // Configure the view for the selected state
  35. }
  36. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  37. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  38. if (self) {
  39. [self initSubViews];
  40. }
  41. return self;
  42. }
  43. - (void)initSubViews {
  44. [self.contentView addSubview:self.iconView];
  45. [self.contentView addSubview:self.titleLabel];
  46. [self.contentView addSubview:self.makeDate];
  47. [self.contentView addSubview:self.endDate];
  48. [self.contentView addSubview:self.buyPrice];
  49. [self.contentView addSubview:self.endPrice];
  50. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.left.mas_equalTo(10);
  52. make.width.height.mas_equalTo(90);
  53. }];
  54. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10);
  56. make.top.mas_equalTo(self.iconView);
  57. make.right.mas_equalTo(-10);
  58. }];
  59. [self.makeDate mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.mas_equalTo(self.titleLabel);
  61. make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(10);
  62. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  63. }];
  64. [self.endDate mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.right.mas_equalTo(-10);
  66. make.top.mas_equalTo(self.makeDate);
  67. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  68. }];
  69. [self.buyPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.mas_equalTo(self.titleLabel);
  71. make.bottom.mas_equalTo(self.iconView.mas_bottom);
  72. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  73. }];
  74. [self.endPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.right.mas_equalTo(-10);
  76. make.bottom.mas_equalTo(self.buyPrice);
  77. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  78. }];
  79. }
  80. - (UIImageView *)iconView {
  81. if (!_iconView) {
  82. _iconView = [[UIImageView alloc] init];
  83. _iconView.contentMode = UIViewContentModeScaleAspectFill;
  84. _iconView.backgroundColor = [UIColor yhGrayColor];
  85. }
  86. return _iconView;
  87. }
  88. - (UILabel *)titleLabel {
  89. if (!_titleLabel) {
  90. _titleLabel = [[CCCopyLabel alloc] init];
  91. _titleLabel.numberOfLines = 2;
  92. _titleLabel.font = [UIFont systemFontOfSize:15];
  93. _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
  94. _titleLabel.text = @"未知商品";
  95. }
  96. return _titleLabel;
  97. }
  98. - (UILabel *)makeDate {
  99. if (!_makeDate) {
  100. _makeDate = [[UILabel alloc] init];
  101. _makeDate.textColor = [UIColor YHColorWithHex:0x999999];
  102. _makeDate.font = [UIFont systemFontOfSize:12];
  103. _makeDate.text = @"创建日:无";
  104. }
  105. return _makeDate;
  106. }
  107. - (UILabel *)endDate {
  108. if (!_endDate) {
  109. _endDate = [[UILabel alloc] init];
  110. _endDate.textColor = [UIColor YHColorWithHex:0x999999];
  111. _endDate.font = [UIFont systemFontOfSize:12];
  112. _endDate.text = @"";
  113. }
  114. return _endDate;
  115. }
  116. - (UILabel *)buyPrice {
  117. if (!_buyPrice) {
  118. _buyPrice = [[UILabel alloc] init];
  119. _buyPrice.textColor = [UIColor YHColorWithHex:0x666666];
  120. _buyPrice.font = [UIFont systemFontOfSize:12];
  121. }
  122. return _buyPrice;
  123. }
  124. - (UILabel *)endPrice {
  125. if (!_endPrice) {
  126. _endPrice = [[UILabel alloc] init];
  127. _endPrice.font = [UIFont systemFontOfSize:16];
  128. NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"待结算佣金 ¥0.00"];
  129. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 6)];
  130. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(6,AttributedStr.length-6)];
  131. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, 6)];
  132. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(6,AttributedStr.length-6)];
  133. _endPrice.attributedText = AttributedStr;
  134. }
  135. return _endPrice;
  136. }
  137. -(void)setModel:(DRChildCommissionModel *)model{
  138. _model=model;
  139. self.titleLabel.text=model.name;
  140. self.makeDate.text=[NSString stringWithFormat:@"创建日:%@",model.order_create_at];
  141. /*
  142. 待结算-显示已付款 :用户下单成功后红包直接给到用户,此时为待结算状态
  143. 已结算-显示结算日:下个月25号,如果该订单有效,则变为已结算状态,红包金额进入账户余额,用户可随时提现
  144. 已失效-显示已失效:如果整个过程中,用户发生退货、退款等行为被淘宝判定为失效订单,则红包变为已失效
  145. 0已失效 1已付款 2已结算
  146. */
  147. NSString *moneyTypeStr;
  148. switch ([model.type integerValue]) {
  149. case 0:
  150. {
  151. moneyTypeStr=@"红包";
  152. }
  153. break;
  154. default:
  155. moneyTypeStr=@"佣金";
  156. break;
  157. }
  158. NSMutableAttributedString *AttributedStr2;
  159. switch ([model.status integerValue]) {
  160. case 0:
  161. {
  162. NSString *legalStr=@"";
  163. switch ([model.maintain_power integerValue]) {
  164. case 1:
  165. {
  166. legalStr=@"维权申请";
  167. }
  168. break;
  169. case 2:
  170. {
  171. legalStr=@"维权失败";
  172. }
  173. break;
  174. case 3:
  175. {
  176. legalStr=@"已失效";
  177. }
  178. break;
  179. default:
  180. break;
  181. }
  182. self.endDate.text=legalStr;
  183. AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已失效%@¥ %@",moneyTypeStr,model.rebate]];
  184. [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)];
  185. [AttributedStr2 addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, AttributedStr2.length)];
  186. }
  187. break;
  188. case 1:
  189. {
  190. self.endDate.text=@"已付款";
  191. AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"待结算%@¥ %@",moneyTypeStr,model.rebate]];
  192. [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, AttributedStr2.length)];
  193. }
  194. break;
  195. case 2:
  196. {
  197. self.endDate.text=@"已结算";
  198. AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已结算%@¥ %@",moneyTypeStr,model.rebate]];
  199. [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)];
  200. }
  201. break;
  202. default:
  203. break;
  204. }
  205. if (AttributedStr2) {
  206. [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 7)];
  207. [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(7,AttributedStr2.length-7)];
  208. self.endPrice.attributedText = AttributedStr2;
  209. }
  210. self.buyPrice.text=[NSString stringWithFormat:@"付款金额 ¥%@",model.money];
  211. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img]];
  212. }
  213. @end