123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- //
- // KBNativeShopCarCollectionCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/11/6.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBNativeShopCarCollectionCell.h"
- @interface KBNativeShopCarCollectionCell ()
- @property (nonatomic, strong) UIImageView *icon;
- @property (nonatomic, strong) UILabel *title;
- @property (nonatomic, strong) YYLabel *couple_price;
- @property (nonatomic, strong) YYLabel *price;
- @property (nonatomic, strong) YYLabel *endTime;
- @property (nonatomic, strong) UILabel *couple_label;
- @property (nonatomic, strong) UILabel *commissionLabel;
- @property (nonatomic, strong) UILabel *fanLabel;
- @property (nonatomic, strong) UIImageView *discountImgV;
- @property (nonatomic, strong) UILabel *numlabel;
- @property (nonatomic, strong) UILabel *redpriceLabel;//红包
- @property (nonatomic, strong) UIImageView *redImgV;
- @end
- @implementation KBNativeShopCarCollectionCell
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- self.contentView.backgroundColor = [UIColor whiteColor];
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self.contentView addSubview:self.icon];
- [self.contentView addSubview:self.title];
- [self.contentView addSubview:self.couple_price];
- [self.contentView addSubview:self.price];
- [self.contentView addSubview:self.endTime];
- [self.contentView addSubview:self.couple_label];
- [self.icon addSubview:self.commissionLabel];
- [self.contentView addSubview:self.discountImgV];
- [self.discountImgV addSubview:self.numlabel];
- [self.contentView addSubview:self.fanLabel];
- [self.contentView addSubview:self.redImgV];
- [self.contentView addSubview:self.redpriceLabel];
- [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(0);
- make.width.height.mas_equalTo(100);
- }];
-
- [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.icon.mas_right).mas_offset(5);
- make.top.mas_equalTo(self.icon.mas_top);
- make.height.mas_equalTo(40);
- make.right.mas_equalTo(-10);
- }];
-
- [self.endTime mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.title.mas_left);
- make.bottom.mas_equalTo(self.icon.mas_bottom);
- }];
-
- [self.couple_price mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.title.mas_left);
- make.top.mas_equalTo(self.title.mas_bottom).mas_offset(10);
- }];
-
- [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.couple_price.mas_right).mas_offset(20);
- make.bottom.mas_equalTo(self.couple_price.mas_bottom);
- }];
-
- [self.couple_label mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.endTime.mas_bottom);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(23);
- }];
-
- [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(0);
- make.height.mas_equalTo(12);
- }];
- [self.redImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.icon.mas_right).mas_offset(5);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- make.width.mas_equalTo(13);
- make.height.mas_equalTo(FITSIZE(15));
-
- }];
- [self.redpriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redImgV.mas_right);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- make.width.mas_equalTo(65);
- make.height.mas_equalTo(FITSIZE(15));
-
- }];
-
- [self.fanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- make.width.mas_equalTo(FITSIZE(50));
- make.height.mas_equalTo(FITSIZE(15));
- }];
-
- [self.discountImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.fanLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- make.width.mas_equalTo(FITSIZE(60));
- make.height.mas_equalTo(FITSIZE(15));
- }];
-
- [self.numlabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.top.mas_equalTo(0);
- make.width.mas_equalTo(FITSIZE(40));
- make.height.mas_equalTo(FITSIZE(15));
- }];
- }
- - (void)setModel:(LDChildGoodModel *)model {
- _model = model;
-
-
-
- [self.icon sd_setFadeImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:0 progress:nil completed:nil];
- self.title.text = model.title;
-
- self.couple_price.text = [NSString stringWithFormat:@"¥%@",model.discount_price];
- self.couple_price.font = [UIFont systemFontOfSize:16];
- self.couple_label.hidden=YES;
-
- self.endTime.hidden =YES;
- self.price.hidden = ![model.is_coupon boolValue];
- self.commissionLabel.hidden = YES;
- self.discountImgV.hidden=YES;
- self.fanLabel.hidden=YES;
- self.redpriceLabel.text=[NSString stringWithFormat:@" %@元红包 ",model.red_active_money];
- self.numlabel.text = [NSString stringWithFormat:@"¥%@",model.coupon_price];
- self.fanLabel.text = [NSString stringWithFormat:@"返¥%@ ",model.commission_price];
-
- if ([model.red_active_status boolValue]) {//有红包
- self.redpriceLabel.hidden=NO;
- self.redImgV.hidden=NO;
- [self.redImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(13);
- }];
- [self.redpriceLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(65);
- }];
- if (model.is_coupon.integerValue == 1 && model.commission_price.length>0) {//佣金和优惠券都存在的时候
- self.discountImgV.hidden=NO;
- self.fanLabel.hidden=NO;
-
- [self.fanLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- [self.discountImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.fanLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- }else if (model.is_coupon.integerValue ==1)//优惠券
- {
- self.fanLabel.hidden=YES;
- self.discountImgV.hidden=NO;
-
- [self.discountImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- }else if(model.commission_price.length>0){
- self.discountImgV.hidden=YES;
- self.fanLabel.hidden=NO;
-
- [self.discountImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.fanLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- }else{
- self.discountImgV.hidden=YES;
- self.fanLabel.hidden=YES;
- }
- }else{//没有红包的时候
- [self.redImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(0);
-
- }];
- [self.redpriceLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(0);
-
- }];
- self.redpriceLabel.hidden=YES;
- self.redImgV.hidden=YES;
- if (model.is_coupon.integerValue == 1 && model.commission_price.length>0) {//佣金和优惠券都存在的时候
- self.discountImgV.hidden=NO;
- self.fanLabel.hidden=NO;
-
- [self.fanLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.icon.mas_right).mas_offset(5);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- [self.discountImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.fanLabel.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- }else if (model.is_coupon.integerValue ==1)//优惠券
- {
- self.fanLabel.hidden=YES;
- self.discountImgV.hidden=NO;
- [self.discountImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- }else if(model.commission_price.length>0){//返佣金
- self.discountImgV.hidden=YES;
- self.fanLabel.hidden=NO;
-
- [self.fanLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right);
- make.top.mas_equalTo(self.couple_price.mas_bottom).mas_offset(10);
- }];
- }else{
- self.discountImgV.hidden=YES;
- self.fanLabel.hidden=YES;
- }
- }
-
-
-
- }
- #pragma mark -----
- - (UIImageView *)icon {
- if (!_icon) {
- _icon = [[UIImageView alloc] init];
- _icon.layer.cornerRadius = 6;
- _icon.layer.masksToBounds=YES;
- _icon.backgroundColor = [UIColor yhGrayColor];
- }
- return _icon;
- }
- - (UILabel *)title {
- if (!_title) {
- _title = [[UILabel alloc] init];
- _title.numberOfLines = 2;
- _title.font = [UIFont systemFontOfSize:14];
- }
- return _title;
- }
- - (YYLabel *)couple_price {
- if (!_couple_price) {
- _couple_price = [[YYLabel alloc] init];
- _couple_price.textColor = [UIColor YHColorWithHex:0xEE000E];
- _couple_price.font = [UIFont systemFontOfSize:18];
- _couple_price.displaysAsynchronously = YES;
- }
- return _couple_price;
- }
- - (YYLabel *)price {
- if (!_price) {
- _price = [[YYLabel alloc] init];
- _price.textColor = [UIColor YHColorWithHex:0xA2A0A0];
- _price.font = [UIFont systemFontOfSize:12];
- _price.displaysAsynchronously = YES;
- }
- return _price;
- }
- - (YYLabel *)endTime {
- if (!_endTime) {
- _endTime = [[YYLabel alloc] init];
- _endTime.font = [UIFont systemFontOfSize:11];
- _endTime.textColor = [UIColor YHColorWithHex:0xA2A0A0];
- _endTime.displaysAsynchronously = YES;
- }
- return _endTime;
- }
- - (UILabel *)couple_label {
- if (!_couple_label) {
- _couple_label = [[UILabel alloc] init];
- _couple_label.textColor = [UIColor whiteColor];
- _couple_label.font = [UIFont systemFontOfSize:13];
- _couple_label.textAlignment = NSTextAlignmentCenter;
- _couple_label.backgroundColor = [UIColor homeRedColor];
- }
- return _couple_label;
- }
- - (UILabel *)commissionLabel {
- if (!_commissionLabel) {
- _commissionLabel = [[UILabel alloc] init];
- _commissionLabel.font = [UIFont systemFontOfSize:11];
- _commissionLabel.textColor = [UIColor whiteColor];
- _commissionLabel.textAlignment = NSTextAlignmentCenter;
- _commissionLabel.backgroundColor = [UIColor homeRedColor];
- _commissionLabel.adjustsFontSizeToFitWidth = YES;
- }
- return _commissionLabel;
- }
- -(UILabel *)fanLabel
- {
- if (!_fanLabel) {
- _fanLabel =[[UILabel alloc]init];
- _fanLabel.backgroundColor=[UIColor YHColorWithHex:0xFFF4DF];
- _fanLabel.textColor=[UIColor YHColorWithHex:0x99520F];
- _fanLabel.font=[UIFont systemFontOfSize:FITSIZE(10)];
- _fanLabel.textAlignment=NSTextAlignmentCenter;
- }
- return _fanLabel;
- }
- -(UILabel *)numlabel
- {
- if (!_numlabel) {
- _numlabel =[[UILabel alloc]init];
- _numlabel.textColor=[UIColor YHColorWithHex:0xFA2D36];
- _numlabel.font=[UIFont systemFontOfSize:FITSIZE(10)];
- _numlabel.textAlignment=NSTextAlignmentCenter;
- }
- return _numlabel;
- }
- -(UIImageView *)discountImgV
- {
- if (!_discountImgV) {
- _discountImgV =[[UIImageView alloc]init];
- _discountImgV.image=[UIImage imageNamed:@"quan_bg"];
-
- UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, FITSIZE(15))];
- label.textColor=[UIColor YHColorWithHex:0xFA2D36];
- label.font=[UIFont systemFontOfSize:FITSIZE(10)];
- label.textAlignment=NSTextAlignmentCenter;
- label.text=@"券";
- [_discountImgV addSubview:label];
- }
- return _discountImgV;
- }
- -(UIImageView *)redImgV
- {
- if (!_redImgV) {
- _redImgV = [[UIImageView alloc] init];
- // _redImgV.backgroundColor=[UIColor redColor];
- _redImgV.image = [UIImage imageNamed:@"red_detail"];
- }
- return _redImgV;
- }
- -(UILabel *)redpriceLabel
- {
- if (!_redpriceLabel) {
- _redpriceLabel = [[UILabel alloc] init];
- _redpriceLabel.textColor = [UIColor YHColorWithHex:0x99520F];
- _redpriceLabel.backgroundColor=[UIColor YHColorWithHex:0xFFF4DF];
- _redpriceLabel.font = [UIFont systemFontOfSize:10];
- _redpriceLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _redpriceLabel;
- }
- @end
|