猎豆优选

LDChildCommissionCell.m 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. //
  2. // LDChildCommissionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDChildCommissionCell.h"
  9. #import "CCCopyLabel.h"
  10. @interface LDChildCommissionCell ()
  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. @property(nonatomic,strong)UIButton *bottomBtn;
  18. @property(nonatomic,strong)UIImageView *redimgV;
  19. @property(nonatomic,strong)UILabel *redpriceLabel;
  20. @end
  21. @implementation LDChildCommissionCell
  22. + (instancetype)cellWithTableView:(UITableView *)tableView {
  23. static NSString *cellID = nil;
  24. cellID = NSStringFromClass([self class]);
  25. LDChildCommissionCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  26. if (!cell) {
  27. cell = [[LDChildCommissionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  28. }
  29. return cell;
  30. }
  31. - (void)awakeFromNib {
  32. [super awakeFromNib];
  33. // Initialization code
  34. }
  35. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  36. [super setSelected:selected animated:animated];
  37. // Configure the view for the selected state
  38. }
  39. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  40. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  41. if (self) {
  42. [self initSubViews];
  43. }
  44. return self;
  45. }
  46. - (void)initSubViews {
  47. [self.contentView addSubview:self.iconView];
  48. [self.contentView addSubview:self.titleLabel];
  49. [self.contentView addSubview:self.makeDate];
  50. [self.contentView addSubview:self.endDate];
  51. [self.contentView addSubview:self.buyPrice];
  52. [self.contentView addSubview:self.endPrice];
  53. [self.contentView addSubview:self.bottomBtn];
  54. [self.bottomBtn addSubview:self.redimgV];
  55. [self.bottomBtn addSubview:self.redpriceLabel];
  56. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.left.mas_equalTo(10);
  58. make.width.height.mas_equalTo(90);
  59. }];
  60. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10);
  62. make.top.mas_equalTo(self.iconView);
  63. make.right.mas_equalTo(-10);
  64. }];
  65. [self.makeDate mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(self.titleLabel);
  67. make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(10);
  68. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  69. }];
  70. [self.endDate mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.right.mas_equalTo(-10);
  72. make.top.mas_equalTo(self.makeDate);
  73. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  74. }];
  75. [self.buyPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(self.titleLabel);
  77. make.bottom.mas_equalTo(self.iconView.mas_bottom);
  78. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  79. }];
  80. [self.endPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.right.mas_equalTo(-10);
  82. make.bottom.mas_equalTo(self.buyPrice);
  83. make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
  84. }];
  85. [self.bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.mas_equalTo(self.endPrice.mas_bottom).offset(10);
  87. make.width.mas_equalTo(SCREEN_WIDTH);
  88. make.height.mas_equalTo(30);
  89. }];
  90. [self.redpriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.right.mas_equalTo(self.mas_right).offset(-15);
  92. make.height.mas_equalTo(16);
  93. make.top.mas_equalTo(4);
  94. }];
  95. [self.redimgV mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.right.mas_equalTo(self.redpriceLabel.mas_left).offset(-5);
  97. make.width.mas_equalTo(17);
  98. make.height.mas_equalTo(19);
  99. make.top.mas_equalTo(2);
  100. }];
  101. }
  102. - (UIImageView *)iconView {
  103. if (!_iconView) {
  104. _iconView = [[UIImageView alloc] init];
  105. _iconView.contentMode = UIViewContentModeScaleAspectFill;
  106. _iconView.backgroundColor = [UIColor yhGrayColor];
  107. }
  108. return _iconView;
  109. }
  110. - (UILabel *)titleLabel {
  111. if (!_titleLabel) {
  112. _titleLabel = [[CCCopyLabel alloc] init];
  113. _titleLabel.numberOfLines = 2;
  114. _titleLabel.font = [UIFont systemFontOfSize:15];
  115. _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
  116. _titleLabel.text = @"未知商品";
  117. }
  118. return _titleLabel;
  119. }
  120. - (UILabel *)makeDate {
  121. if (!_makeDate) {
  122. _makeDate = [[UILabel alloc] init];
  123. _makeDate.textColor = [UIColor YHColorWithHex:0x999999];
  124. _makeDate.font = [UIFont systemFontOfSize:12];
  125. _makeDate.text = @"创建日:无";
  126. }
  127. return _makeDate;
  128. }
  129. - (UILabel *)endDate {
  130. if (!_endDate) {
  131. _endDate = [[UILabel alloc] init];
  132. _endDate.textColor = [UIColor YHColorWithHex:0x999999];
  133. _endDate.font = [UIFont systemFontOfSize:12];
  134. _endDate.text = @"";
  135. }
  136. return _endDate;
  137. }
  138. - (UILabel *)buyPrice {
  139. if (!_buyPrice) {
  140. _buyPrice = [[UILabel alloc] init];
  141. _buyPrice.textColor = [UIColor YHColorWithHex:0x666666];
  142. _buyPrice.font = [UIFont systemFontOfSize:12];
  143. }
  144. return _buyPrice;
  145. }
  146. -(UIButton *)bottomBtn
  147. {
  148. if (!_bottomBtn) {
  149. _bottomBtn =[[UIButton alloc]init];
  150. _bottomBtn.hidden=YES;
  151. _bottomBtn.backgroundColor=[UIColor clearColor];
  152. [_bottomBtn addTarget:self action:@selector(clickRedModel) forControlEvents:UIControlEventTouchUpInside];
  153. }
  154. return _bottomBtn;
  155. }
  156. -(UIImageView *)redimgV
  157. {
  158. if (!_redimgV) {
  159. _redimgV =[[UIImageView alloc]init];
  160. _redimgV.image=[UIImage imageNamed:@"red_detail"];
  161. }
  162. return _redimgV;
  163. }
  164. -(UILabel *)redpriceLabel
  165. {
  166. if (!_redpriceLabel) {
  167. _redpriceLabel =[[UILabel alloc]init];
  168. _redpriceLabel.textColor=[UIColor YHColorWithHex:0xF22E26];
  169. _redpriceLabel.font=[UIFont systemFontOfSize:FITSIZE(11)];
  170. _redpriceLabel.text=@"获得xx元红包,点击查看 >";
  171. }
  172. return _redpriceLabel;
  173. }
  174. - (UILabel *)endPrice {
  175. if (!_endPrice) {
  176. _endPrice = [[UILabel alloc] init];
  177. _endPrice.font = [UIFont systemFontOfSize:16];
  178. NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"待结算佣金 ¥0.00"];
  179. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 6)];
  180. [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(6,AttributedStr.length-6)];
  181. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, 6)];
  182. [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(6,AttributedStr.length-6)];
  183. _endPrice.attributedText = AttributedStr;
  184. }
  185. return _endPrice;
  186. }
  187. -(void)setModel:(LDChildCommissionModel *)model{
  188. _model=model;
  189. self.titleLabel.text=model.name;
  190. self.makeDate.text=[NSString stringWithFormat:@"创建日:%@",model.order_create_at];
  191. /*
  192. 待结算-显示已付款 :用户下单成功后红包直接给到用户,此时为待结算状态
  193. 已结算-显示结算日:下个月25号,如果该订单有效,则变为已结算状态,红包金额进入账户余额,用户可随时提现
  194. 已失效-显示已失效:如果整个过程中,用户发生退货、退款等行为被淘宝判定为失效订单,则红包变为已失效
  195. 0已失效 1已付款 2已结算
  196. */
  197. NSString *moneyTypeStr=@"";
  198. switch ([model.type integerValue]) {//判断是否是红包
  199. case 7:
  200. {
  201. moneyTypeStr=@"红包奖励金";
  202. }
  203. break;
  204. default:
  205. moneyTypeStr=@"佣金";
  206. break;
  207. }
  208. NSMutableAttributedString *AttributedStr2;
  209. switch ([model.status integerValue]) {//0已失效 1已付款 2已结算 status
  210. case 0:
  211. {
  212. NSString *legalStr=@"";
  213. switch ([model.maintain_power integerValue]) {//0不维权 1维权申请 2维权失败 3维权成功
  214. case 1:
  215. {
  216. legalStr=@"维权申请";
  217. }
  218. break;
  219. case 2:
  220. {
  221. legalStr=@"维权失败";
  222. }
  223. break;
  224. case 3:
  225. {
  226. legalStr=@"已失效";
  227. }
  228. break;
  229. default:
  230. break;
  231. }
  232. self.endDate.text=legalStr;
  233. AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已失效%@¥ %@",moneyTypeStr,model.rebate]];
  234. [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)];
  235. [AttributedStr2 addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, AttributedStr2.length)];
  236. }
  237. break;
  238. case 1:
  239. {
  240. self.endDate.text=@"已付款";
  241. AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"待结算%@¥ %@",moneyTypeStr,model.rebate]];
  242. [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, AttributedStr2.length)];
  243. }
  244. break;
  245. case 2:
  246. {
  247. self.endDate.text= [NSString stringWithFormat:@"结算日:%@",model.order_balance_at];
  248. AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已结算%@¥ %@",moneyTypeStr,model.rebate]];
  249. [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)];
  250. }
  251. break;
  252. default:
  253. break;
  254. }
  255. if (AttributedStr2) {
  256. [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 7)];
  257. [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(7,AttributedStr2.length-7)];
  258. self.endPrice.attributedText = AttributedStr2;
  259. }
  260. self.buyPrice.text=[NSString stringWithFormat:@"付款金额 ¥%@",model.money];
  261. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img]];
  262. if (model.order_status.integerValue == 1) {
  263. self.bottomBtn.hidden=NO;
  264. self.redpriceLabel.text=[NSString stringWithFormat:@"获得%@元红包,点击查看 >",model.red_money];
  265. }else{
  266. self.bottomBtn.hidden=YES;
  267. }
  268. }
  269. -(void)clickRedModel
  270. {
  271. if ([self.delegatre respondsToSelector:@selector(ClickModel:)] ) {
  272. [self.delegatre ClickModel:_model];
  273. }
  274. }
  275. @end