123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- //
- // LDGroupChildGoodCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/12/13.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDGroupChildGoodCell.h"
- @interface LDGroupChildGoodCell ()
- @property (nonatomic, strong) UIImageView *imgView; //大图
- @property (nonatomic, strong) UILabel *titleLabel; //标题
- @property (nonatomic, strong) UIImageView *ticketNumber; //
- @property (nonatomic, strong) UILabel *ticketType;
- @property (nonatomic, strong) UILabel *zheKou; //
- @property (nonatomic, strong) YYLabel *disPriceL; // 优惠后价格
- @property (nonatomic, strong) UIImageView *commissionBg;
- @property (nonatomic, strong) UILabel *commissionLabel;
- @end
- @implementation LDGroupChildGoodCell
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- self.layer.cornerRadius = 4;
- self.layer.masksToBounds = YES;
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self.contentView addSubview:self.imgView];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.ticketNumber];
- [self.ticketNumber addSubview:self.ticketType];
- [self.ticketNumber addSubview:self.zheKou];
- [self.contentView addSubview:self.disPriceL];
- [self.contentView addSubview:self.commissionBg];
- [self.commissionBg addSubview:self.commissionLabel];
-
- [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.right.left.mas_equalTo(0);
- make.height.mas_equalTo(Fitsize(115));
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(5);
- make.right.mas_equalTo(-5);
- make.top.mas_equalTo(self.imgView.mas_bottom).mas_offset(Fitsize(5));
- }];
-
- [self.disPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(3);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(Fitsize(8));
- }];
-
- [self.ticketNumber mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-5);
- make.width.mas_equalTo(52);
- make.height.mas_equalTo(52*14/64);
- make.centerY.mas_equalTo(self.disPriceL.mas_centerY);
- }];
-
-
- [self.ticketType mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.mas_equalTo(0);
- make.width.mas_equalTo(14);
- }];
-
- [self.zheKou mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.ticketType.mas_right);
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(52*14/64);
- make.width.mas_equalTo(38);
- }];
-
- [self.commissionBg mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(self.imgView.mas_bottom).mas_offset(-10);
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(40*27/69);
- }];
-
- [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(4);
- make.right.mas_equalTo(-2);
- make.centerY.mas_equalTo(self.commissionBg.mas_centerY);
- }];
-
- }
- - (void)setModel:(LDChildGoodModel *)model {
- _model = model;
- self.titleLabel.text = model.title;
- [self.imgView sd_setFadeImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:0 progress:nil completed:nil];
- self.disPriceL.text = [NSString stringWithFormat:@"¥%.2f",[model.discount_price floatValue]];
- //折后价
- if ([model.is_coupon boolValue]) {
- self.zheKou.text = [NSString stringWithFormat:@"%@元",model.coupon_price];
- self.ticketType.text = @"券";
- }else {
- self.zheKou.text = [NSString stringWithFormat:@"%@折",model.coupon_price];
- self.ticketType.text = @"折";
- }
- self.ticketNumber.hidden = ![model.is_coupon boolValue];
-
- //
- self.commissionLabel.text = [NSString stringWithFormat:@"赚¥%.2f",[model.commission_price floatValue]];
- if (model.commission_price.length > 0) {
- self.commissionBg.hidden = NO;
- }else {
- self.commissionBg.hidden = YES;
- }
- self.commissionBg.hidden = YES;
- }
- - (UIImageView *)imgView {
- if (!_imgView) {
- _imgView = [[UIImageView alloc] init];
- _imgView.backgroundColor = [UIColor yhGrayColor];
- }
- return _imgView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
- _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
- _titleLabel.numberOfLines = 1;
- }
- return _titleLabel;
- }
- - (UIImageView *)ticketNumber {
- if (!_ticketNumber) {
- _ticketNumber = [[UIImageView alloc] init];
- _ticketNumber.image = [UIImage imageNamed:@"quan_bg"];
- }
- return _ticketNumber;
- }
- - (UILabel *)zheKou {
- if (!_zheKou) {
- _zheKou = [[UILabel alloc] init];
- _zheKou.textColor = [UIColor homeRedColor];
- _zheKou.textAlignment = NSTextAlignmentCenter;
- _zheKou.font = [UIFont systemFontOfSize:9];
- }
- return _zheKou;
- }
- - (UILabel *)ticketType {
- if (!_ticketType) {
- _ticketType = [[UILabel alloc] init];
- _ticketType.font = [UIFont systemFontOfSize:8];
- _ticketType.textAlignment = NSTextAlignmentCenter;
- _ticketType.textColor = [UIColor homeRedColor];
- }
- return _ticketType;
- }
- - (YYLabel *)disPriceL {
- if (!_disPriceL) {
- _disPriceL = [[YYLabel alloc] init];
- _disPriceL.displaysAsynchronously = YES;
- _disPriceL.font = [UIFont systemFontOfSize:12];
- _disPriceL.textColor = [UIColor homeRedColor];
- }
- return _disPriceL;
- }
- - (UIImageView *)commissionBg {
- if (!_commissionBg) {
- _commissionBg = [[UIImageView alloc] init];
- _commissionBg.image = [UIImage imageNamed:@"Shape"];
- }
- return _commissionBg;
- }
- - (UILabel *)commissionLabel {
- if (!_commissionLabel) {
- _commissionLabel = [[UILabel alloc] init];
- _commissionLabel.textAlignment = NSTextAlignmentCenter;
- _commissionLabel.font = [UIFont systemFontOfSize:8];
- _commissionLabel.adjustsFontSizeToFitWidth = YES;
- _commissionLabel.textColor = [UIColor whiteColor];
- }
- return _commissionLabel;
- }
- @end
|