// // KDPRecommendGoodCell.m // KuDianProject // // Created by 学丽 on 2019/7/4. // Copyright © 2019 KDP. All rights reserved. // #import "KDPRecommendGoodCell.h" @implementation KDPRecommendGoodCell -(instancetype)initWithFrame:(CGRect)frame { self=[super initWithFrame:frame]; if (self) { UIView *backV =[[UIView alloc]init]; backV.backgroundColor=[UIColor whiteColor]; [self addSubview:backV]; [backV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo (10); make.right.mas_equalTo(-10); make.top.mas_equalTo(0); make.bottom.mas_equalTo(-1); }]; [backV addSubview:self.couponImgV]; [self.couponImgV addSubview:self.couponPriceL]; [backV addSubview:self.recomImgV]; [backV addSubview:self.recomTitleL]; [backV addSubview:self.recomShopL]; [backV addSubview:self.recomShopiconImg]; [backV addSubview:self.recomVolumeL]; [backV addSubview:self.recomPriceL]; [backV addSubview:self.recomOriginL]; [backV addSubview:self.recomprofitL]; [self.recomImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.mas_equalTo(10); make.bottom.mas_equalTo(-11); make.width.height.mas_equalTo(100); }]; [self.recomTitleL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.recomImgV.mas_right).offset(10); make.top.mas_equalTo(self.recomImgV.mas_top); make.height.mas_equalTo(21); make.right.mas_equalTo(-10); }]; [self.recomShopiconImg mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.recomTitleL.mas_left); make.top.mas_equalTo(self.recomTitleL.mas_bottom).offset(9); make.width.height.mas_equalTo(13); }]; [self.recomShopL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.recomShopiconImg.mas_right).offset(6); make.top.mas_equalTo(self.recomTitleL.mas_bottom).offset(7); make.height.mas_equalTo(17); }]; [self.recomVolumeL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.top.mas_equalTo(self.recomTitleL.mas_bottom).offset(7); make.height.mas_equalTo(17); }]; [self.recomPriceL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.recomTitleL.mas_left); make.top.mas_equalTo(self.recomShopiconImg.mas_bottom).offset(11); make.height.mas_equalTo(25); }]; [self.recomOriginL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.recomPriceL.mas_right).offset(8); make.height.mas_equalTo(25); make.top.mas_equalTo(self.recomPriceL.mas_top); }]; [self.recomprofitL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.height.mas_equalTo(26); make.width.mas_equalTo(78); make.top.mas_equalTo(self.recomVolumeL.mas_bottom).offset(21); }]; [self.couponImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.recomPriceL.mas_bottom).offset(6); make.height.mas_equalTo(16); make.width.mas_equalTo(60); make.left.mas_equalTo(self.recomPriceL.mas_left); }]; [self.couponPriceL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20); make.top.right.bottom.mas_equalTo(0); }]; UIView *lineV=[[UIView alloc]init]; lineV.backgroundColor=[UIColor colorWithHexString:LineColor]; [self addSubview:lineV]; [lineV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.top.mas_equalTo(self.mas_bottom).offset(-1); make.height.mas_equalTo(1); }]; } return self; } -(UIImageView *)recomImgV { if (!_recomImgV) { _recomImgV=[[UIImageView alloc]init]; _recomImgV.backgroundColor=[UIColor colorWithHexString:@"D8D8D8"]; _recomImgV.layer.cornerRadius=8; _recomImgV.layer.masksToBounds=YES; } return _recomImgV; } -(UILabel *)recomTitleL { if (!_recomTitleL) { _recomTitleL=[[UILabel alloc]init]; _recomTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:@"这是一个商品名这是一个商品名商品名这是一个商品名这是一个商品名商品名" linSpacing:5]; _recomTitleL.numberOfLines=0; _recomTitleL.font=[UIFont systemFontOfSize:15]; _recomTitleL.textColor=[UIColor colorWithHexString:fontColor]; } return _recomTitleL; } -(UIImageView *)recomShopiconImg { if (!_recomShopiconImg) { _recomShopiconImg=[[UIImageView alloc]init]; _recomShopiconImg.image=[UIImage imageNamed:@"taobao_icon"]; } return _recomShopiconImg; } -(UILabel *)recomShopL { if (!_recomShopL) { _recomShopL=[[UILabel alloc]init]; _recomShopL.text=@"-------"; _recomShopL.textColor=[UIColor colorWithHexString:@"#666666"]; _recomShopL.font=[UIFont systemFontOfSize:12]; } return _recomShopL; } -(UILabel *)recomPriceL { if (!_recomPriceL) { _recomPriceL=[[UILabel alloc]init]; _recomPriceL.textColor=[UIColor colorWithHexString:fontColor]; _recomPriceL.font=[UIFont boldSystemFontOfSize:18]; _recomPriceL.text=@"¥--"; } return _recomPriceL; } -(UILabel *)recomOriginL { if (!_recomOriginL) { _recomOriginL =[[UILabel alloc]init]; _recomOriginL.textColor=[UIColor colorWithHexString:@"#999999"]; _recomOriginL.font=[UIFont systemFontOfSize:13]; //中划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"¥---" attributes:attribtDic]; // 赋值 _recomOriginL.attributedText = attribtStr; } return _recomOriginL; } -(UILabel *)recomVolumeL { if (!_recomVolumeL) { _recomVolumeL =[[UILabel alloc]init]; _recomVolumeL.text=@"月销:--"; _recomVolumeL.textAlignment=NSTextAlignmentRight; _recomVolumeL.textColor=[UIColor colorWithHexString:@"#999999"]; _recomVolumeL.font=[UIFont systemFontOfSize:12]; } return _recomVolumeL; } -(UILabel *)recomprofitL { if (!_recomprofitL) { _recomprofitL =[[UILabel alloc]init]; _recomprofitL.text=@"利润 --%"; _recomprofitL.textColor=[UIColor whiteColor]; _recomprofitL.backgroundColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:78]; _recomprofitL.layer.cornerRadius=6; _recomprofitL.layer.masksToBounds=YES; _recomprofitL.textAlignment=NSTextAlignmentCenter; } return _recomprofitL; } -(UIImageView *)couponImgV { if (!_couponImgV) { _couponImgV=[[UIImageView alloc]init]; _couponImgV.image=[UIImage imageNamed:@"coupon_icon"]; UILabel *quanL=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 16)]; quanL.text=@"券"; quanL.font=[UIFont systemFontOfSize:12]; quanL.textColor=[UIColor whiteColor]; quanL.textAlignment=NSTextAlignmentCenter; [_couponImgV addSubview:quanL]; } return _couponImgV; } -(UILabel *)couponPriceL { if (!_couponPriceL) { _couponPriceL=[[UILabel alloc]init]; _couponPriceL.text=@"---"; _couponPriceL.textColor=[UIColor colorWithHexString:ThemeColor]; _couponPriceL.font=[UIFont systemFontOfSize:12]; _couponPriceL.textAlignment=NSTextAlignmentCenter; } return _couponPriceL; } -(void)setModel:(KDPGoodsModel *)model { _model = model; //设置字体字号和字体类别 self.recomprofitL.text=[NSString stringWithFormat:@"利润%@",model.commission_rate]; [self.recomImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]]; self.recomShopL.text=model.shop_title; self.recomTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:model.title linSpacing:5]; if (model.shop_type.integerValue == 1) { self.recomShopiconImg.image =[UIImage imageNamed:@"tm_icon"]; }else{ self.recomShopiconImg.image =[UIImage imageNamed:@"taobao_icon"]; } //原件 NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price]; //中划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; // 赋值 self.recomOriginL.attributedText = attribtStr; self.recomPriceL.text=[NSString stringWithFormat:@"¥%@",model.discount_price]; self.recomVolumeL.text=[NSString stringWithFormat:@"月销%@",model.volume]; if (model.coupon_price.floatValue>0) { self.couponImgV.hidden=NO; self.couponPriceL.text=model.coupon_price; }else{ self.couponImgV.hidden=YES; } } @end