123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- //
- // KDPTodayListCell.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/9.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPTodayListCell.h"
- @implementation KDPTodayListCell
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self addSubview:self.todayGoodImgV];
- [self addSubview:self.todayTitleL];
- [self addSubview:self.numL];
- [self addSubview:self.timeLabel];
- [self addSubview:self.oldPriceL];
- [self addSubview:self.livePriceL];
-
- [self.todayGoodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(9);
- make.left.mas_equalTo(14);
- make.width.height.mas_equalTo(96);
- }];
-
- [self.todayTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.todayGoodImgV.mas_top);
- make.height.mas_equalTo(38);
- make.left.mas_equalTo(self.todayGoodImgV.mas_right).offset(10);
- make.right.mas_equalTo(-10);
-
- }];
-
- [self.oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.todayGoodImgV.mas_right).offset(10);
- make.height.mas_equalTo(16);
- make.top.mas_equalTo(self.todayTitleL.mas_bottom).offset(9);
- }];
-
- [self.livePriceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.todayGoodImgV.mas_right).offset(10);
- make.height.mas_equalTo(22);
- make.top.mas_equalTo(self.oldPriceL.mas_bottom).offset(9);
- }];
-
- [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.bottom.mas_equalTo(self.mas_bottom).offset(-13);
- make.height.mas_equalTo(22);
- }];
-
- [self.numL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(22);
- make.top.mas_equalTo(self.livePriceL.mas_top);
- }];
-
-
- 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 *)todayGoodImgV
- {
- if (!_todayGoodImgV) {
- _todayGoodImgV=[[UIImageView alloc]init];
- _todayGoodImgV.layer.cornerRadius=5;
- _todayGoodImgV.layer.masksToBounds=YES;
- _todayGoodImgV.backgroundColor=[UIColor colorWithHexString:LineColor];
-
- }
- return _todayGoodImgV;
- }
- -(UILabel *)todayTitleL
- {
- if (!_todayTitleL) {
- _todayTitleL=[[UILabel alloc]init];
- _todayTitleL.numberOfLines=0;
- _todayTitleL.text=@"---";
- _todayTitleL.font=[UIFont systemFontOfSize:14];
- _todayTitleL.textColor=[UIColor colorWithHexString:@"#333333"];
-
- }
- return _todayTitleL;
- }
- -(UILabel *)oldPriceL
- {
- if (!_oldPriceL) {
- _oldPriceL=[[UILabel alloc]init];
- _oldPriceL.textColor=[UIColor colorWithHexString:@"#BBB9BB"];
- _oldPriceL.text=@"--";
- _oldPriceL.font=[UIFont systemFontOfSize:11];
-
- }
- return _oldPriceL;
- }
- -(UILabel *)livePriceL
- {
- if (!_livePriceL) {
- _livePriceL=[[UILabel alloc]init];
- _livePriceL.textColor=[UIColor colorWithHexString:@"#BBB9BB"];
- _livePriceL.text=@"---";
- _livePriceL.font=[UIFont systemFontOfSize:12];
- }
- return _livePriceL;
- }
- -(UILabel *)timeLabel
- {
- if (!_timeLabel) {
- _timeLabel=[[UILabel alloc]init];
- _timeLabel.font=[UIFont systemFontOfSize:11];
- _timeLabel.textColor=[UIColor colorWithHexString:@"#BBB9BB"];
-
- }
- return _timeLabel;
- }
- -(UILabel *)numL
- {
- if (!_numL) {
- _numL=[[UILabel alloc]init];
- _numL.font=[UIFont systemFontOfSize:16];
- _numL.backgroundColor=[UIColor colorWithHexString:ThemeColor];
- _numL.text=@" --人下单 ";
- _numL.textColor=[UIColor whiteColor];
- _numL.layer.cornerRadius=4;
- _numL.layer.masksToBounds=YES;
- _numL.textAlignment=NSTextAlignmentCenter;
- }
- return _numL;
- }
- -(void)setModel:(KDPGoodsModel *)model
- {
- _model=model;
- NSString *textStr =[NSString stringWithFormat:@"¥%@",model.zk_final_price];
-
- //中划线
- NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
- NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
- // 赋值
- self.oldPriceL.attributedText = attribtStr;
- self.numL.text=[NSString stringWithFormat:@" %@人下单 ",model.order_count];
- //计算下单时间
- NSString *imter= [KDPublicMethod CalculateCurrentDate:model.create_at];
- NSString *timetitle= [NSString stringWithFormat:@"%@前下单",imter];
- NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
- [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#FC6708"] range:NSMakeRange(0,timetitle.length-3)];
-
- [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,timetitle.length-3)]; //设置字体字号和字体类别
- [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#ADAAAD"] range:NSMakeRange(timetitle.length-3,3)];
-
- _timeLabel.attributedText = timestr;
- NSString *title=[NSString stringWithFormat:@"直播价¥%@",model.discount_price];
- NSMutableAttributedString *newstr = [[NSMutableAttributedString alloc] initWithString:title];
- [newstr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#ADAAAD"] range:NSMakeRange(0,3)];
- [newstr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体字号和字体类别
- [newstr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#393939"] range:NSMakeRange(3,title.length-3)];
-
- self.livePriceL.attributedText = newstr;
-
- self.todayTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:model.name linSpacing:5];
- [self.todayGoodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]];
- }
- @end
|