123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // LDModuleCollectionCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/4.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDModuleCollectionCell.h"
- @interface LDModuleCollectionCell()
- @property (nonatomic, strong) UIImageView *iconView;
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *priceLabel;
- @property (nonatomic, strong) UILabel *disPrice;
- @property (nonatomic, strong) UILabel *commissionLabel;
- @end
- @implementation LDModuleCollectionCell
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.layer.cornerRadius = 6;
- self.layer.masksToBounds = YES;
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self.contentView addSubview:self.iconView];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.priceLabel];
- [self.contentView addSubview:self.disPrice];
- [self.iconView addSubview:self.commissionLabel];
-
- [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.mas_equalTo(0);
- make.height.mas_equalTo(self.iconView.mas_width);
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(0);
- make.top.mas_equalTo(self.iconView.mas_bottom).mas_offset(Fitsize(10));
- }];
-
- [self.disPrice mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(Fitsize(6));
- }];
-
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.disPrice.mas_right).mas_offset(3);
- make.bottom.mas_equalTo(self.disPrice.mas_bottom).mas_offset(-1);
- }];
-
- [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_offset(0);
- make.height.mas_equalTo(20);
- }];
- }
- - (void)setModel:(LDChildGoodModel *)model {
- _model = model;
- [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:Placehold_Img];
- self.titleLabel.text = model.title;
- self.disPrice.text = [NSString stringWithFormat:@"¥%.2f",[model.discount_price floatValue]];
- NSString *price=[NSString stringWithFormat:@"%.2f",[model.price floatValue]];
- NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:price];
- [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, price.length)];
- [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor YHColorWithHex:0x999999] range:NSMakeRange(0, price.length)];
- self.priceLabel.attributedText = attri;
-
- //预估佣金视图
- if (model.commission_price.length > 0) {
- self.commissionLabel.text = [NSString stringWithFormat:@"预估佣金¥%.2f",[model.commission_price floatValue]];
- self.commissionLabel.hidden = NO;
- }else {
- self.commissionLabel.hidden = YES;
- }
- }
- #pragma mark --- layzer ---
- - (UIImageView *)iconView {
- if (!_iconView) {
- _iconView = [[UIImageView alloc] init];
- _iconView.backgroundColor = [UIColor yhGrayColor];
- _iconView.layer.cornerRadius = 5;
- _iconView.layer.masksToBounds = YES;
- }
- return _iconView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.numberOfLines = 1;
- _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
- _titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
- }
- return _titleLabel;
- }
- - (UILabel *)priceLabel {
- if (!_priceLabel) {
- _priceLabel = [[UILabel alloc] init];
- _priceLabel.textColor = [UIColor YHColorWithHex:0x999999];
- _priceLabel.font = [UIFont systemFontOfSize:Fitsize(11)];
- }
- return _priceLabel;
- }
- - (UILabel *)disPrice {
- if (!_disPrice) {
- _disPrice = [[UILabel alloc] init];
- _disPrice.font = [UIFont systemFontOfSize:Fitsize(15)];
- _disPrice.textColor = [UIColor homeRedColor];
- }
- return _disPrice;
- }
- - (UILabel *)commissionLabel {
- if (!_commissionLabel) {
- _commissionLabel = [[UILabel alloc] init];
- _commissionLabel.font = [UIFont systemFontOfSize:11];
- _commissionLabel.textColor = [UIColor whiteColor];
- _commissionLabel.textAlignment = NSTextAlignmentCenter;
- _commissionLabel.backgroundColor = [UIColor homeRedColor];
- }
- return _commissionLabel;
- }
- @end
|