// // DRChildOrderCell.m // YouHuiProject // // Created by 小花 on 2018/5/18. // Copyright © 2018年 kuxuan. All rights reserved. // #import "DRChildOrderCell.h" #import "CCCopyLabel.h" @interface DRChildOrderCell () @property (nonatomic, strong) UIImageView *icon; @property (nonatomic, strong) CCCopyLabel *orderTitle; @property (nonatomic, strong) UILabel *orderDate; @property (nonatomic, strong) UILabel *orderPrice; @property (nonatomic, strong) UILabel *orderType; @end @implementation DRChildOrderCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); DRChildOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[DRChildOrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } return cell; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initSubView]; } return self; } - (void)initSubView { [self.contentView addSubview:self.icon]; [self.contentView addSubview:self.orderTitle]; [self.contentView addSubview:self.orderDate]; [self.contentView addSubview:self.orderPrice]; [self.contentView addSubview:self.orderType]; [self.icon mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.centerY.mas_equalTo(self.mas_centerY); make.width.height.mas_equalTo(28); }]; [self.orderTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.icon.mas_right).mas_offset(15); make.top.mas_equalTo(13); }]; [self.orderDate mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.orderTitle); make.top.mas_equalTo(self.orderTitle.mas_bottom).mas_offset(4); }]; [self.orderPrice mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15); make.centerY.mas_equalTo(self); }]; [self.orderType mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.orderDate.mas_right).offset(FITSIZE(12)); make.centerY.equalTo(self.orderDate.mas_centerY); }]; } - (UILabel *)orderTitle { if (!_orderTitle) { _orderTitle = [[CCCopyLabel alloc] init]; _orderTitle.font = [UIFont systemFontOfSize:16]; _orderTitle.text = @"佣金收入"; _orderTitle.textColor = [UIColor YHColorWithHex:0x666666]; } return _orderTitle; } - (UILabel *)orderDate { if (!_orderDate) { _orderDate = [[UILabel alloc] init]; _orderDate.textColor = [UIColor YHColorWithHex:0x999999]; _orderDate.font = [UIFont systemFontOfSize:12]; _orderDate.text = @"日期:--"; } return _orderDate; } - (UILabel *)orderPrice { if (!_orderPrice) { _orderPrice = [[UILabel alloc] init]; _orderPrice.font = [UIFont systemFontOfSize:18]; _orderPrice.textAlignment = NSTextAlignmentRight; _orderPrice.text = @"+0.00"; } return _orderPrice; } -(UILabel *)orderType{ if (!_orderType) { _orderType=[[UILabel alloc]init]; _orderType.textColor = [UIColor YHColorWithHex:0x999999]; _orderType.font = [UIFont systemFontOfSize:12]; _orderType.text = @""; } return _orderType; } - (UIImageView *)icon { if (!_icon) { _icon = [[UIImageView alloc] init]; _icon.image = [UIImage imageNamed:@"comission_left"]; _icon.layer.cornerRadius = 14; } return _icon; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(void)setModel:(DRChildOrderModel *)model{ _model=model; switch ([model.type integerValue]) { case 0: { self.orderTitle.text=@"红包收入"; } break; case 1: case 3: { self.orderTitle.text=@"佣金收入"; } break; case 2: { self.orderTitle.text=@"提现扣除"; } break; default: break; } self.orderDate.text=[NSString stringWithFormat:@"%@",model.create_at]; NSString *type=@"+"; if ([model.type integerValue]==2) { self.orderPrice.textColor=[UIColor YHColorWithHex:0xEC1B1B]; type=@"-"; //提现 switch ([model.state_of_embodiment integerValue]) { case 0: { self.orderType.text=@"申请中"; } break; case 1: { self.orderType.text=@"已通过"; } break; case 2: { self.orderType.text=@"未通过"; } break; default: break; } }else{ self.orderPrice.textColor=[UIColor YHColorWithHex:0x15CB6C]; self.orderType.text=@""; } self.orderPrice.text=[NSString stringWithFormat:@"%@%@",type,model.rebate]; } @end