123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- //
- // 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 *commissionLabel;
- @property (nonatomic, strong) UIImageView *discountImgV;
- @property (nonatomic, strong) UILabel *numlabel;
- @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.icon addSubview:self.commissionLabel];
- [self.contentView addSubview:self.discountImgV];
- [self.discountImgV addSubview:self.numlabel];
-
- [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.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(0);
- make.height.mas_equalTo(12);
- }];
-
- [self.discountImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.title.mas_left);
- 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:(DRChildGoodModel *)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.endTime.hidden =YES;
- self.price.hidden = ![model.is_coupon boolValue];
- self.commissionLabel.hidden = YES;
- self.discountImgV.hidden= ![model.is_coupon boolValue];
-
- if (model.is_coupon.integerValue == 1) {//佣金和优惠券都存在的时候
- self.numlabel.text = [NSString stringWithFormat:@"¥%@",model.coupon_price];
- }
- }
- #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 *)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 *)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;
- }
- @end
|