123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- //
- // LDTodayHorizontalGoodCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/12/11.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDTodayHorizontalGoodCell.h"
- @interface LDTodayHorizontalGoodCell ()
- @property (nonatomic, strong) UIImageView *imgView; //大图
- @property (nonatomic, strong) YYLabel *titleLabel; //标题
- @property (nonatomic, strong) UILabel *priceLabel; //原价
- @property (nonatomic, strong) UILabel *disPriceL; // 优惠后价格
- @property (nonatomic, strong) UIImageView *ticketNumber; //
- @property (nonatomic, strong) UILabel *zheKou; // 几折,或者几元券
- @property (nonatomic, strong) UILabel *ticketType;
- @property (nonatomic, strong) YYLabel *shopInfo;
- @property (nonatomic, strong) UIView *commissionBg;
- @property (nonatomic, strong) UILabel *commissionLabel;
- @property (nonatomic, strong) UILabel *volum;
- @property (nonatomic, strong) UILabel *redpriceLabel;//红包
- @property (nonatomic, strong) UIImageView *redImgV;
- @end
- @implementation LDTodayHorizontalGoodCell
- - (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.imgView];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.priceLabel];
- [self.contentView addSubview:self.disPriceL];
- [self.contentView addSubview:self.ticketNumber];
- [self.ticketNumber addSubview:self.zheKou];
- [self.ticketNumber addSubview:self.ticketType];
- [self.contentView addSubview:self.shopInfo];
- [self.contentView addSubview:self.commissionBg];
- [self.commissionBg addSubview:self.commissionLabel];
- [self.contentView addSubview:self.volum];
- [self.contentView addSubview:self.redpriceLabel];
- [self.contentView addSubview:self.redImgV];
- [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(16);
- make.left.mas_equalTo(8);
- make.width.height.mas_equalTo(115);
- }];
-
-
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.imgView.mas_right).mas_offset(12);
- make.top.mas_equalTo(self.imgView).mas_offset(3);
- make.right.mas_equalTo(-10);
- }];
-
- [self.shopInfo mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.titleLabel);
- make.centerY.mas_equalTo(self.imgView.mas_centerY);
- }];
-
- [self.disPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.shopInfo.mas_left);
- make.top.mas_equalTo(self.shopInfo.mas_bottom).mas_offset(6);
- }];
- [self.redImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.imgView.mas_bottom).mas_offset(-2);
- make.left.mas_equalTo(self.titleLabel.mas_left);
- make.width.mas_equalTo(13);
- make.height.mas_equalTo(15);
- }];
- [self.redpriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.imgView.mas_bottom).mas_offset(-2);
- make.left.mas_equalTo(self.redImgV.mas_right);
- make.height.mas_equalTo(15);
- }];
- [self.ticketNumber mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.imgView.mas_bottom).mas_offset(-2);
- make.left.mas_equalTo(self.redpriceLabel.mas_right);
- make.width.mas_equalTo(64);
- make.height.mas_equalTo(15);
- }];
-
- [self.ticketType mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.mas_equalTo(0);
- make.width.mas_equalTo(20);
- }];
-
- [self.zheKou mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.top.bottom.right.mas_equalTo(0);
- }];
-
-
- [self.commissionBg mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(10);
- make.width.mas_equalTo(65);
- make.height.mas_equalTo(15);
- make.bottom.mas_equalTo(self.imgView.mas_bottom).mas_offset(-2);
- }];
-
- [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
- }];
-
- [self.volum mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.disPriceL.mas_right).mas_offset(10);
- make.centerY.mas_equalTo(self.disPriceL.mas_centerY);
- }];
-
- }
- - (void)setModel:(LDChildGoodModel *)model {
-
- //标题
- //标题
- NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",model.title]];
- attri.yy_font = [UIFont boldSystemFontOfSize:14];
- attri.yy_color = [UIColor blackColor];
- attri.yy_lineSpacing = 6;
- self.titleLabel.attributedText = attri;
- if (model.red_active_status.integerValue == 1) {//判断是否有红包
- self.redpriceLabel.text=[NSString stringWithFormat:@" %@元红包 ",model.red_active_money];
- [self.redImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(13);
- }];
- }else{
- [self.redImgV mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(0);
- }];
- }
- //店铺信息
- if (model.shop_title.length > 0) {
- UIImage *img;
- if ([model.shop_type isEqualToString:@"1"]) {
- img= [UIImage imageNamed:@"tm_shop"];
- }else {
- img= [UIImage imageNamed:@"taobao_shop"];
- }
- YYAnimatedImageView *imgeView = [[YYAnimatedImageView alloc] initWithImage:img];
- imgeView.frame = CGRectMake(0, 0, 15, 15);
- NSMutableAttributedString *shopAtti = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@",model.shop_title]];
-
- NSMutableAttributedString *mua = [NSMutableAttributedString yy_attachmentStringWithContent:imgeView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imgeView.frame.size alignToFont:[UIFont systemFontOfSize:14] alignment:YYTextVerticalAlignmentCenter];
- [shopAtti insertAttributedString:mua atIndex:0];
- shopAtti.yy_font = [UIFont systemFontOfSize:12];
- shopAtti.yy_color = [UIColor YHColorWithHex:0x9B9B9B];
- self.shopInfo.attributedText = shopAtti;
- self.shopInfo.hidden = NO;
- }else {
- self.shopInfo.hidden = YES;
- }
-
- //
-
-
-
- //大图
- [self.imgView yy_setImageWithURL:[NSURL URLWithString:model.img] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
-
-
-
- //折后价
- NSString *disStr;
- if ([model.is_coupon boolValue]) {
- disStr = [NSString stringWithFormat:@"¥%.2f",[model.discount_price floatValue]];
- self.zheKou.text = [NSString stringWithFormat:@"%@元",model.coupon_price];
- self.ticketType.text = @"券";
- }else {
- disStr = [NSString stringWithFormat:@"¥%.2f",[model.discount_price floatValue]];
- self.zheKou.text = [NSString stringWithFormat:@"%@折",model.coupon_price];
- self.ticketType.text = @"折";
- }
- NSMutableAttributedString *disAttr = [[NSMutableAttributedString alloc] initWithString:disStr];
- [disAttr addAttributes:@{NSForegroundColorAttributeName:[UIColor homeRedColor]} range:NSMakeRange(0, disAttr.length)];
- [disAttr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} range:NSMakeRange(0, 1)];
- self.disPriceL.attributedText = disAttr;
-
- self.volum.text = [NSString stringWithFormat:@"月销 %@",model.volume];
-
- //券相关
- self.ticketNumber.hidden = ![model.is_coupon boolValue];
- CGFloat width = [model.is_coupon boolValue] ? 64 : 0;
- //券的位置
- [self.ticketNumber mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(width);
- }];
- // 预估佣金视图
- if (model.commission_price.floatValue>0) {//判断是否有预估佣金,
- [self.ticketNumber mas_updateConstraints:^(MASConstraintMaker *make) {
- if (model.red_active_status.integerValue == 1) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(85);
- }else{
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(75);
- }
- }];
- [self.commissionBg mas_updateConstraints:^(MASConstraintMaker *make) {
- if (model.red_active_status.integerValue == 1) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(10);
- }else{
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(0);
- }
-
- }];
- }else {
- [self.ticketNumber mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.redpriceLabel.mas_right).mas_offset(5);
- }];
- }
- self.commissionLabel.text = [NSString stringWithFormat:@"返¥%.2f",[model.commission_price floatValue]];
- if (model.commission_price.floatValue > 0) {
- self.commissionBg.hidden = NO;
- }else {
- self.commissionBg.hidden = YES;
- }
-
- }
- - (UIImageView *)imgView {
- if (!_imgView) {
- _imgView = [[UIImageView alloc] init];
- _imgView.backgroundColor = [UIColor YHColorWithHex:0xf0f0f0];
- }
- return _imgView;
- }
- - (YYLabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[YYLabel alloc] init];
- _titleLabel.font = [UIFont boldSystemFontOfSize:15];
- _titleLabel.textColor = [UIColor YHColorWithHex:0x000000];
- _titleLabel.numberOfLines = 2;
- _titleLabel.preferredMaxLayoutWidth = SCREEN_WIDTH-145;
- }
- return _titleLabel;
- }
- - (UILabel *)priceLabel {
- if (!_priceLabel) {
- _priceLabel = [[UILabel alloc] init];
- _priceLabel.font = [UIFont systemFontOfSize:11];
- _priceLabel.textColor = [UIColor YHColorWithHex:0x999999];
- }
- return _priceLabel;
- }
- - (UILabel *)disPriceL {
- if (!_disPriceL) {
- _disPriceL = [[UILabel alloc] init];
- _disPriceL.font = [UIFont systemFontOfSize:15];
- _disPriceL.textColor = [UIColor homeRedColor];
- }
- return _disPriceL;
- }
- - (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:10];
- }
- return _zheKou;
- }
- - (UILabel *)ticketType {
- if (!_ticketType) {
- _ticketType = [[UILabel alloc] init];
- _ticketType.font = [UIFont systemFontOfSize:10];
- _ticketType.textAlignment = NSTextAlignmentCenter;
- _ticketType.textColor = [UIColor homeRedColor];
- }
- return _ticketType;
- }
- - (YYLabel *)shopInfo {
- if (!_shopInfo) {
- _shopInfo = [[YYLabel alloc] init];
- _shopInfo.displaysAsynchronously = YES;
- _shopInfo.font = [UIFont systemFontOfSize:12];
- _shopInfo.textColor = [UIColor YHColorWithHex:0x9B9B9B];
- }
- return _shopInfo;
- }
- - (UIView *)commissionBg {
- if (!_commissionBg) {
- _commissionBg = [[UIView alloc] init];
- _commissionBg.backgroundColor = [UIColor YHColorWithHex:0xFFF4DF];
- }
- return _commissionBg;
- }
- - (UILabel *)commissionLabel {
- if (!_commissionLabel) {
- _commissionLabel = [[UILabel alloc] init];
- _commissionLabel.textColor = [UIColor YHColorWithHex:0x99520F];
- _commissionLabel.font = [UIFont systemFontOfSize:10];
- _commissionLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _commissionLabel;
- }
- - (UILabel *)volum {
- if (!_volum) {
- _volum = [[UILabel alloc] init];
- _volum.textColor = [UIColor YHColorWithHex:0xBBB9BB];
- _volum.font = [UIFont systemFontOfSize:10];
- }
- return _volum;
- }
- -(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
|