// // KBChildCommissionCell.m // YouHuiProject // // Created by 小花 on 2018/5/18. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBChildCommissionCell.h" #import "CCCopyLabel.h" @interface KBChildCommissionCell () @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) CCCopyLabel *titleLabel; @property (nonatomic, strong) UILabel *makeDate; @property (nonatomic, strong) UILabel *endDate; @property (nonatomic, strong) UILabel *buyPrice; @property (nonatomic, strong) UILabel *endPrice; @end @implementation KBChildCommissionCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); KBChildCommissionCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[KBChildCommissionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } return cell; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initSubViews]; } return self; } - (void)initSubViews { [self.contentView addSubview:self.iconView]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.makeDate]; [self.contentView addSubview:self.endDate]; [self.contentView addSubview:self.buyPrice]; [self.contentView addSubview:self.endPrice]; [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_equalTo(10); make.width.height.mas_equalTo(90); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10); make.top.mas_equalTo(self.iconView); make.right.mas_equalTo(-10); }]; [self.makeDate mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.titleLabel); make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(10); make.width.mas_equalTo((SCREEN_WIDTH-130)/2); }]; [self.endDate mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.top.mas_equalTo(self.makeDate); make.width.mas_equalTo((SCREEN_WIDTH-130)/2); }]; [self.buyPrice mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.titleLabel); make.bottom.mas_equalTo(self.iconView.mas_bottom); make.width.mas_equalTo((SCREEN_WIDTH-130)/2); }]; [self.endPrice mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.bottom.mas_equalTo(self.buyPrice); make.width.mas_equalTo((SCREEN_WIDTH-130)/2); }]; } - (UIImageView *)iconView { if (!_iconView) { _iconView = [[UIImageView alloc] init]; _iconView.contentMode = UIViewContentModeScaleAspectFill; _iconView.backgroundColor = [UIColor yhGrayColor]; } return _iconView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [[CCCopyLabel alloc] init]; _titleLabel.numberOfLines = 2; _titleLabel.font = [UIFont systemFontOfSize:15]; _titleLabel.textColor = [UIColor YHColorWithHex:0x333333]; _titleLabel.text = @"未知商品"; } return _titleLabel; } - (UILabel *)makeDate { if (!_makeDate) { _makeDate = [[UILabel alloc] init]; _makeDate.textColor = [UIColor YHColorWithHex:0x999999]; _makeDate.font = [UIFont systemFontOfSize:12]; _makeDate.text = @"创建日:无"; } return _makeDate; } - (UILabel *)endDate { if (!_endDate) { _endDate = [[UILabel alloc] init]; _endDate.textColor = [UIColor YHColorWithHex:0x999999]; _endDate.font = [UIFont systemFontOfSize:12]; _endDate.text = @""; } return _endDate; } - (UILabel *)buyPrice { if (!_buyPrice) { _buyPrice = [[UILabel alloc] init]; _buyPrice.textColor = [UIColor YHColorWithHex:0x666666]; _buyPrice.font = [UIFont systemFontOfSize:12]; } return _buyPrice; } - (UILabel *)endPrice { if (!_endPrice) { _endPrice = [[UILabel alloc] init]; _endPrice.font = [UIFont systemFontOfSize:16]; NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"待结算佣金 ¥0.00"]; [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 6)]; [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(6,AttributedStr.length-6)]; [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, 6)]; [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(6,AttributedStr.length-6)]; _endPrice.attributedText = AttributedStr; } return _endPrice; } -(void)setModel:(KBChildCommissionModel *)model{ _model=model; self.titleLabel.text=model.name; self.makeDate.text=[NSString stringWithFormat:@"创建日:%@",model.order_create_at]; /* 待结算-显示已付款 :用户下单成功后红包直接给到用户,此时为待结算状态 已结算-显示结算日:下个月25号,如果该订单有效,则变为已结算状态,红包金额进入账户余额,用户可随时提现 已失效-显示已失效:如果整个过程中,用户发生退货、退款等行为被淘宝判定为失效订单,则红包变为已失效 0已失效 1已付款 2已结算 */ NSString *moneyTypeStr; switch ([model.type integerValue]) { case 0: { moneyTypeStr=@"红包"; } break; default: moneyTypeStr=@"佣金"; break; } NSMutableAttributedString *AttributedStr2; switch ([model.status integerValue]) { case 0: { NSString *legalStr=@""; switch ([model.maintain_power integerValue]) { case 1: { legalStr=@"维权申请"; } break; case 2: { legalStr=@"维权失败"; } break; case 3: { legalStr=@"已失效"; } break; default: break; } self.endDate.text=legalStr; AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已失效%@¥ %@",moneyTypeStr,model.rebate]]; [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)]; [AttributedStr2 addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, AttributedStr2.length)]; } break; case 1: { self.endDate.text=@"已付款"; AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"待结算%@¥ %@",moneyTypeStr,model.rebate]]; [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, AttributedStr2.length)]; } break; case 2: { self.endDate.text=@"已结算"; AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已结算%@¥ %@",moneyTypeStr,model.rebate]]; [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)]; } break; default: break; } if (AttributedStr2) { [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 7)]; [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(7,AttributedStr2.length-7)]; self.endPrice.attributedText = AttributedStr2; } self.buyPrice.text=[NSString stringWithFormat:@"付款金额 ¥%@",model.money]; [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img]]; } @end