123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- //
- // 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.right.mas_equalTo(self.recomVolumeL.mas_left);
- 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.top.mas_equalTo(self.recomVolumeL.mas_bottom).offset(21);
- }];
-
- [self.couponImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.recomShopiconImg.mas_bottom).offset(42);
- 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;
- //设置字体字号和字体类别
- NSString *timetitle= [NSString stringWithFormat:@" 利润 %@ ",model.commission_rate];
- NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
- [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体
- self.recomprofitL.attributedText=timestr;
- [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;
-
- NSString *pricetitle= [NSString stringWithFormat:@"¥%@",model.discount_price];
- NSMutableAttributedString *prictS = [[NSMutableAttributedString alloc] initWithString:pricetitle];
- [prictS addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,1)]; //设置字体
- self.recomPriceL.attributedText=prictS;
- self.recomVolumeL.text=[NSString stringWithFormat:@"月销%@",model.volume];
-
- if (model.coupon_price.floatValue>0) {
- self.couponImgV.hidden=NO;
- self.couponPriceL.text=model.coupon_price;
- [self.recomPriceL mas_updateConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.recomShopiconImg.mas_bottom).offset(11);
- }];
- }else{
- self.couponImgV.hidden=YES;
- [self.recomPriceL mas_updateConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.recomShopiconImg.mas_bottom).offset(25);
- }];
- }
-
- }
- @end
|