// // ZBOrderDataCell.m // ZBProject // // Created by 学丽 on 2019/4/9. // Copyright © 2019 ZB. All rights reserved. // #import "ZBOrderDataCell.h" @implementation ZBOrderDataCell -(instancetype)initWithFrame:(CGRect)frame { self=[super initWithFrame:frame]; if (self) { self.layer.cornerRadius=6; self.layer.masksToBounds=YES; self.backgroundColor=[UIColor whiteColor]; [self addSubview:self.goodImgV]; [self addSubview:self.titleLabel]; [self addSubview:self.shopImg]; [self addSubview:self.shopLabel]; [self addSubview:self.priceLabel]; [self addSubview:self.oldPriceL]; [self addSubview:self.quanImgv]; [self.quanImgv addSubview:self.quanLabel]; [self addSubview:self.salesCountL]; [self addSubview:self.makeLabel]; [self addSubview:self.exclusiveLabel]; [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(110); make.top.left.mas_equalTo(10); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.goodImgV.mas_right).offset(9); make.right.mas_equalTo(-9); make.top.mas_equalTo(self.goodImgV.mas_top).offset(5); make.height.mas_equalTo(22); }]; [self.shopImg mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(14); make.left.mas_equalTo(self.goodImgV.mas_right).offset(10); make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10); }]; [self.shopLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.shopImg.mas_right).offset(5); make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9); make.height.mas_equalTo(16); make.right.mas_equalTo(-10); }]; [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(7); make.left.mas_equalTo(self.goodImgV.mas_right).offset(10); make.height.mas_equalTo(22); }]; [self.exclusiveLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(7); make.left.mas_equalTo(self.goodImgV.mas_right).offset(10); make.height.mas_equalTo(18); make.width.mas_equalTo(42); }]; [self.oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(7); make.left.mas_equalTo(self.priceLabel.mas_right).offset(10); make.height.mas_equalTo(22); }]; [self.quanImgv mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.goodImgV.mas_right).offset(10); make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(9); make.height.mas_equalTo(16); make.width.mas_equalTo(65); }]; [self.quanLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(24); make.right.top.mas_equalTo(0); make.height.mas_equalTo(16); }]; [self.salesCountL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-8); make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9); make.height.mas_equalTo(16); }]; [self.makeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.oldPriceL.mas_bottom).offset(3); make.right.mas_equalTo(-8); make.height.mas_equalTo(26); make.width.mas_equalTo(80); }]; } return self; } -(void)setModel:(ZBGoodModel *)model { _model= model; if (model.selection_tag.length>0) { self.exclusiveLabel.text=model.selection_tag; self.exclusiveLabel.hidden=NO; }else{ self.exclusiveLabel.hidden=YES; } [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]]; self.titleLabel.text=model.title; if (model.shop_type.integerValue == 1) { self.shopImg.image =[UIImage imageNamed:@"tm_icon"]; }else{ self.shopImg.image =[UIImage imageNamed:@"taobao_icon"]; } self.shopLabel.text=model.shop_title; self.salesCountL.text=[NSString stringWithFormat:@"月销%@",model.volume]; self.quanLabel.text=[NSString stringWithFormat:@"%@元",model.coupon_price]; //券的价格为0隐藏 if (model.coupon_price.floatValue == 0) { self.quanImgv.hidden=YES; }else{ self.quanImgv.hidden=NO; } self.priceLabel.text=[NSString stringWithFormat:@"¥%@",model.discount_price]; //原件 NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price]; //中划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; // 赋值 _oldPriceL.attributedText = attribtStr; NSString *title=[NSString stringWithFormat:@"利润%@",model.commission_rate]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title]; [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,2)]; //设置字体字号和字体类别 [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(2,title.length-2)]; //设置字体字号和字体类别 _makeLabel.attributedText=str; } -(UIImageView *)goodImgV { if (!_goodImgV) { _goodImgV=[[UIImageView alloc]init]; _goodImgV.backgroundColor=[UIColor lineColor]; _goodImgV.layer.cornerRadius=4; _goodImgV.layer.masksToBounds=YES; } return _goodImgV; } -(UILabel *)titleLabel { if (!_titleLabel) { _titleLabel=[[UILabel alloc]init]; _titleLabel.font=[UIFont systemFontOfSize:15]; _titleLabel.textColor=[UIColor YHColorWithHex:0x333333]; _titleLabel.text=@"---------"; } return _titleLabel; } -(UILabel *)oldPriceL { if (!_oldPriceL) { _oldPriceL=[[UILabel alloc]init]; _oldPriceL.font=[UIFont systemFontOfSize:10]; _oldPriceL.textColor=[UIColor YHColorWithHex:0xBBB9BB]; // _oldPriceL.text=@"99.99"; NSString *textStr =@"¥99.99"; //中划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; // 赋值 _oldPriceL.attributedText = attribtStr; } return _oldPriceL; } -(UILabel *)priceLabel { if (!_priceLabel) { _priceLabel=[[UILabel alloc]init]; _priceLabel.font=[UIFont systemFontOfSize:16]; _priceLabel.textColor=[UIColor YHColorWithHex:0x393939]; _priceLabel.text=@"¥---"; } return _priceLabel; } -(UIImageView *)shopImg { if (!_shopImg) { _shopImg =[[UIImageView alloc]init]; [_shopImg setImage:[UIImage imageNamed:@"tm_icon"]]; _shopImg.layer.cornerRadius=3; _shopImg.layer.masksToBounds=YES; } return _shopImg; } -(UILabel *)shopLabel { if (!_shopLabel) { _shopLabel=[[UILabel alloc]init]; _shopLabel.text=@"----"; _shopLabel.textColor=[UIColor YHColorWithHex:0x8D8A8A]; _shopLabel.font=[UIFont systemFontOfSize:11]; } return _shopLabel; } -(UIImageView *)quanImgv { if (!_quanImgv) { _quanImgv =[[UIImageView alloc]init]; [_quanImgv setImage:[UIImage imageNamed:@"quan"]]; _quanImgv.layer.cornerRadius=2; _quanImgv.layer.masksToBounds=YES; _quanImgv.hidden=YES; } return _quanImgv; } -(UILabel *)quanLabel { if (!_quanLabel) { _quanLabel=[[UILabel alloc]init]; _quanLabel.textColor=[UIColor YHColorWithHex:0xFF7D00]; _quanLabel.font=[UIFont systemFontOfSize:10]; _quanLabel.textAlignment=NSTextAlignmentCenter; _quanLabel.text=@"--元"; } return _quanLabel; } -(UILabel *)salesCountL { if (!_salesCountL) { _salesCountL=[[UILabel alloc]init]; _salesCountL.text=@"月销--"; _salesCountL.textColor=[UIColor YHColorWithHex:0xBBB9BB]; _salesCountL.font=[UIFont systemFontOfSize:10]; } return _salesCountL; } -(UILabel *)makeLabel { if (!_makeLabel) { _makeLabel=[[UILabel alloc]init]; _makeLabel.layer.cornerRadius=13; _makeLabel.layer.masksToBounds=YES; _makeLabel.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF8300] toColor:[UIColor YHColorWithHex:0xFF5200] withWidth:80]; _makeLabel.font=[UIFont systemFontOfSize:15]; _makeLabel.textColor=[UIColor whiteColor]; _makeLabel.text=@"赚¥--"; _makeLabel.textAlignment=NSTextAlignmentCenter; NSString *title=@"赚¥--"; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title]; [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,1)]; //设置字体字号和字体类别 [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(1,title.length-1)]; //设置字体字号和字体类别 _makeLabel.attributedText=str; } return _makeLabel; } -(UILabel *)exclusiveLabel { if (!_exclusiveLabel) { _exclusiveLabel=[[UILabel alloc]init]; _exclusiveLabel.text=@"专属"; _exclusiveLabel.textColor=[UIColor YHColorWithHex:0xFF7D00]; _exclusiveLabel.font=[UIFont systemFontOfSize:10]; _exclusiveLabel.textAlignment=NSTextAlignmentCenter; _exclusiveLabel.layer.cornerRadius=3; _exclusiveLabel.hidden=YES; _exclusiveLabel.layer.masksToBounds=YES; _exclusiveLabel.layer.borderColor=[UIColor YHColorWithHex:0xFF7D00].CGColor; _exclusiveLabel.layer.borderWidth=0.5; } return _exclusiveLabel; } @end