// // YOUPAIHRHorizontalPageCell.m // VQU // // Created by xiaohaoran on 2021/11/1. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRHorizontalPageCell.h" @implementation YOUPAIHRHorizontalPageCell -(instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { self.youpaipbgV = [[UIView alloc] init]; [self.contentView addSubview:self.youpaipbgV]; [self.youpaipbgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.offset(0.0f); make.bottom.offset(0.0f); make.left.offset(6.5f); make.right.offset(-6.5f); }]; CGFloat width = 51.0f; self.youpaipimgView = [[UIImageView alloc] init]; self.youpaipimgView.contentMode = UIViewContentModeScaleAspectFit; [self.youpaipbgV addSubview:self.youpaipimgView]; [self.youpaipimgView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.offset(2.0f); make.size.mas_offset(CGSizeMake(width, width)); }]; self.youpaiptitleL = [[UILabel alloc] init]; self.youpaiptitleL.font = [UIFont systemFontOfSize:12]; self.youpaiptitleL.textColor = HexColorFromRGBA(0xffffff,1.0); self.youpaiptitleL.textAlignment = NSTextAlignmentCenter; [self.youpaipbgV addSubview:self.youpaiptitleL]; [self.youpaiptitleL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(0.0f); make.right.offset(0.0f); make.top.equalTo(self.youpaipimgView.mas_bottom); make.height.offset(15.0f); }]; self.youpaippriceL = [[UILabel alloc]init]; self.youpaippriceL.font = [UIFont systemFontOfSize:10]; self.youpaippriceL.textColor = HexColorFromRGBA(0xffffff,0.5); self.youpaippriceL.textAlignment = NSTextAlignmentCenter; [self.youpaipbgV addSubview:self.youpaippriceL]; [self.youpaippriceL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.mas_centerX).offset(6.0f); make.top.equalTo(self.youpaiptitleL.mas_bottom).offset(3); }]; UIImageView *coinImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_user_show_zuanshi"]]; [self.youpaipbgV addSubview:coinImgV]; [coinImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.youpaippriceL.mas_left).offset(-3.0f); make.centerY.equalTo(self.youpaippriceL); make.size.mas_offset(CGSizeMake(9, 9)); }]; //角标 self.youpaipbageBtn = [UIButton new]; [self.youpaipbgV addSubview:self.youpaipbageBtn]; [self.youpaipbageBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(24, 15)); }]; [self.youpaipbageBtn setTitle:@"活动" forState:UIControlStateNormal]; [self.youpaipbageBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; self.youpaipbageBtn.titleLabel.font = [UIFont systemFontOfSize:9]; self.youpaipbageBtn.layer.cornerRadius = 2.0f; self.youpaipbageBtn.layer.masksToBounds = YES; self.youpaipbageBtn.backgroundColor = HexColorFromRGB(0xFF41A4); self.youpaipbageBtn.hidden = YES; //个数 self.youpaipcountLabel = [[UILabel alloc]init]; self.youpaipcountLabel.font = [UIFont systemFontOfSize:9]; self.youpaipcountLabel.textColor = HexColorFromRGBA(0xFF41A4,1.0); [self.youpaipbgV addSubview:self.youpaipcountLabel]; [self.youpaipcountLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(2); make.top.mas_equalTo(2); make.height.offset(15); // make.size.mas_equalTo(CGSizeMake(40, 15)); }]; self.youpaipbageBtn.layer.zPosition = MAXFLOAT; } return self; } -(void)setYoupaipmodel:(YOUPAILCGiftModel *)youpaipmodel{ _youpaipmodel = youpaipmodel; // self.youpaipimgView.image = [LCTools giftImgWithGiftUrlStr:model.img]; //modify by leo 解决主线程卡死问题 20191204 NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,youpaipmodel.youpaipimg]; [self.youpaipimgView sd_setImageWithURL:[NSURL URLWithString:urlStr]]; // self.youpaiptitleL.text = self.model.name; // self.youpaippriceL.text = [NSString stringWithFormat:@"%zd",self.model.price]; if (youpaipmodel.youpaipnum>0) { self.youpaipcountLabel.text = [NSString stringWithFormat:@"×%ld",(long)youpaipmodel.youpaipnum]; } NSString *signStr =[NSString stringWithFormat:@"%@",youpaipmodel.youpaipsign]; if (signStr.length>0) { self.youpaipbageBtn.hidden = NO; [self.youpaipbageBtn setTitle:youpaipmodel.youpaipsign forState:UIControlStateNormal]; NSLog(@"签名是:%@",youpaipmodel.youpaipsign); }else{ self.youpaipbageBtn.hidden = YES; } self.youpaiptitleL.text = self.youpaipmodel.youpaipname; self.youpaippriceL.text = [NSString stringWithFormat:@"%zd",self.youpaipmodel.youpaipprice]; if (youpaipmodel.youpaipselected) { self.youpaipbgV.layer.borderColor = HexColorFromRGB(0xFF3A00).CGColor; self.youpaipbgV.layer.borderWidth = 1.0; self.youpaipbgV.layer.cornerRadius = 8; }else{ self.youpaipbgV.layer.borderColor = [UIColor clearColor].CGColor; self.youpaipbgV.layer.borderWidth = 0; self.youpaipbgV.layer.cornerRadius = 0; } } @end