// // KDPForecastOrderCell.m // KuDianProject // // Created by 学丽 on 2019/7/8. // Copyright © 2019 KDP. All rights reserved. // #import "KDPForecastOrderCell.h" @implementation KDPForecastOrderCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self addSubview:self.goodImgV]; [self addSubview:self.addTimeL]; [self addSubview:self.moneyL]; [self addSubview:self.accountLabel]; [self addSubview:self.forecastLabel]; [self addSubview:self.goodTitleLabel]; [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.mas_equalTo(10); make.width.height.mas_equalTo(90); }]; [self.goodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.goodImgV.mas_top); make.left.mas_equalTo(self.goodImgV.mas_right).offset(9); make.right.mas_equalTo(-10); make.height.mas_equalTo(42); }]; [self.addTimeL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.goodTitleLabel.mas_bottom).offset(6); make.height.mas_equalTo(17); make.left.mas_equalTo(self.goodTitleLabel.mas_left); }]; [self.accountLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.goodTitleLabel.mas_bottom).offset(6); make.height.mas_equalTo(17); make.right.mas_equalTo(-10); }]; [self.moneyL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.goodTitleLabel.mas_left); make.height.mas_equalTo(17); make.top.mas_equalTo(self.addTimeL.mas_bottom).offset(10); }]; [self.forecastLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.height.mas_equalTo(17); make.top.mas_equalTo(self.addTimeL.mas_bottom).offset(10); }]; } return self; } -(void)setModel:(KDPOrderModel *)model { _model = model; self.goodTitleLabel.text=model.name; self.addTimeL.text=[NSString stringWithFormat:@"创建日:%@",model.order_create_at]; [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]]; NSMutableAttributedString *forastcaStr; switch ([model.status integerValue]) {//0已失效 1已付款 2已结算 status case 0: { NSString *legalStr=@""; switch ([model.maintain_power integerValue]) {//0不维权 1维权申请 2维权失败 3维权成功 case 1: { legalStr=@"维权申请"; } break; case 2: { legalStr=@"维权失败"; } break; case 3: { legalStr=@"已失效"; } break; default: break; } self.accountLabel.text=legalStr; forastcaStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已失效¥ %@",model.rebate]]; [forastcaStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#FF1E00"] range:NSMakeRange(0, forastcaStr.length)]; [forastcaStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, forastcaStr.length)]; } break; case 1: { self.accountLabel.text=@"已付款"; forastcaStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"待结算¥ %@",model.rebate]]; [forastcaStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#3E97FF"] range:NSMakeRange(0, forastcaStr.length)]; } break; case 2: { self.accountLabel.text= [NSString stringWithFormat:@"结算日:%@",model.order_balance_at]; forastcaStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已结算¥ %@",model.rebate]]; [forastcaStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#FF1E00"] range:NSMakeRange(0, forastcaStr.length)]; } break; default: break; } if (forastcaStr) { [forastcaStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 7)]; [forastcaStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(7,forastcaStr.length-7)]; self.forecastLabel.attributedText = forastcaStr; } self.moneyL.text=[NSString stringWithFormat:@"付款金额 ¥%@",model.money]; } -(UIImageView *)goodImgV { if (!_goodImgV) { _goodImgV=[[UIImageView alloc]init]; _goodImgV.backgroundColor=[UIColor colorWithHexString:LineColor]; } return _goodImgV; } -(UILabel *)goodTitleLabel { if (!_goodTitleLabel) { _goodTitleLabel=[[UILabel alloc]init]; _goodTitleLabel.numberOfLines=0; _goodTitleLabel.font=[UIFont systemFontOfSize:15]; _goodTitleLabel.textColor=[UIColor colorWithHexString:fontColor]; } return _goodTitleLabel; } -(UILabel *)addTimeL { if (!_addTimeL) { _addTimeL=[[UILabel alloc]init]; _addTimeL.textColor=[UIColor colorWithHexString:@"#999999"]; _addTimeL.font=[UIFont systemFontOfSize:12]; _addTimeL.text=@"创建日:--"; } return _addTimeL; } -(UILabel *)accountLabel { if (!_accountLabel) { _accountLabel=[[UILabel alloc]init]; _accountLabel.textColor=[UIColor colorWithHexString:@"#999999"]; _accountLabel.font=[UIFont systemFontOfSize:12]; _accountLabel.text=@"结算日:--"; } return _accountLabel; } -(UILabel *)moneyL { if (!_moneyL) { _moneyL=[[UILabel alloc]init]; _moneyL.textColor=[UIColor colorWithHexString:@"#4A4A4A"]; _moneyL.font=[UIFont systemFontOfSize:12]; _moneyL.text=@"付款金额¥--"; } return _moneyL; } -(UILabel *)forecastLabel { if (!_forecastLabel) { _forecastLabel=[[UILabel alloc]init]; _forecastLabel.textColor=[UIColor colorWithHexString:@"#666666"]; _forecastLabel.font=[UIFont systemFontOfSize:12]; NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"结算佣金¥-.--"]; [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(0, 6)]; [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(5,AttributedStr.length-5)]; [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#666666"] range:NSMakeRange(0, 5)]; [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(5,AttributedStr.length-5)]; _forecastLabel.attributedText=AttributedStr; } return _forecastLabel; } @end