123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- //
- // ZBProductListCell.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/27.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBProductListCell.h"
- @implementation ZBProductListCell
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
- 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.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.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;
- [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;
- }
- @end
|