// // YOUPAIHRMembershipApplicationCell.m // VQU // // Created by xiaohaoran on 2021/11/5. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRMembershipApplicationCell.h" #import "YOUPAILZLevelView.h" @interface YOUPAIHRMembershipApplicationCell () @property(nonatomic,strong)UIImageView *youpaipavatarImgV; @property(nonatomic,strong)UILabel * youpaipnicknameL; @property(nonatomic,strong)UIImageView *youpaipvipV; @property(nonatomic,strong)UIImageView *youpaipbadgeImgV; @property(nonatomic,strong)YOUPAILZLevelView *youpaiplevelView; @property(nonatomic,strong)UILabel *youpaipIDLabel; @property(nonatomic,strong)UILabel *youpaiptimeLabel; @end @implementation YOUPAIHRMembershipApplicationCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self youpaifsetSubView]; } return self; } -(void)youpaifsetSubView{ //头像 UIImageView *youpaipavatarImgV = [[UIImageView alloc]init]; [self.contentView addSubview:youpaipavatarImgV]; self.youpaipavatarImgV = youpaipavatarImgV; [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(40, 40));; }]; // youpaipavatarImgV.image = [UIImage imageNamed:@"AppIcon"]; youpaipavatarImgV.layer.cornerRadius = 20; youpaipavatarImgV.layer.masksToBounds = YES; //V youpaipavatarImgV.userInteractionEnabled = YES; //昵称 UILabel *youpaipnicknameL = [[UILabel alloc] init]; youpaipnicknameL.font = LCBoldFont(14); youpaipnicknameL.textColor = [UIColor whiteColor]; [self.contentView addSubview:youpaipnicknameL]; self.youpaipnicknameL = youpaipnicknameL; [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipavatarImgV.mas_right).offset(8.0f); make.top.offset(10.0f); make.height.offset(24.5f); }]; youpaipnicknameL.text = @"傻孩子"; //Vip UIImageView *youpaipvipV = [[UIImageView alloc] init]; [self addSubview:youpaipvipV]; self.youpaipvipV = youpaipvipV; [youpaipvipV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; UIImageView *youpaipbadgeImgV = [[UIImageView alloc] init]; [self addSubview:youpaipbadgeImgV]; self.youpaipbadgeImgV = youpaipbadgeImgV; [youpaipbadgeImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipvipV.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; //等级 UIImageView *leveImgV = [[UIImageView alloc] init]; [self addSubview:leveImgV]; [leveImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipbadgeImgV.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; // YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init]; // [self addSubview:youpaiplevelView]; // self.youpaiplevelView = youpaiplevelView; // youpaiplevelView.hidden = YES; // [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f); // make.centerY.equalTo(youpaipnicknameL); // }]; //年份月份 UILabel *youpaiptimeLabel = [UILabel new]; self.youpaiptimeLabel = youpaiptimeLabel; [self.contentView addSubview:youpaiptimeLabel]; [youpaiptimeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-14); make.top.mas_equalTo(12); }]; youpaiptimeLabel.text = @"2021-11-22 08:56"; youpaiptimeLabel.textColor = HexColorFromRGB(0x9F9DA5); youpaiptimeLabel.font = [UIFont systemFontOfSize:11]; //同意 UIButton *agreeBtn = [UIButton new]; [self.contentView addSubview:agreeBtn]; [agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-14); make.top.mas_equalTo(youpaiptimeLabel.mas_bottom).offset(10); make.size.mas_equalTo(CGSizeMake(56, 22)); }]; [agreeBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56, 22) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal]; [agreeBtn setTitle:@"同意" forState:UIControlStateNormal]; [agreeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; agreeBtn.titleLabel.font = [UIFont systemFontOfSize:12]; agreeBtn.layer.cornerRadius = 12; agreeBtn.clipsToBounds = YES; //拒绝 UIButton *RefuseBtn = [UIButton new]; [self.contentView addSubview:RefuseBtn]; [RefuseBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(agreeBtn.mas_left).offset(-10); make.top.mas_equalTo(youpaiptimeLabel.mas_bottom).offset(10); make.size.mas_equalTo(CGSizeMake(56, 22)); }]; [RefuseBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(56, 22) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:1] forState:UIControlStateNormal]; [RefuseBtn setTitle:@"拒绝" forState:UIControlStateNormal]; [RefuseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; RefuseBtn.titleLabel.font = [UIFont systemFontOfSize:12]; RefuseBtn.layer.cornerRadius = 12; RefuseBtn.clipsToBounds = YES; //id UILabel *youpaipIDLabel = [UILabel new]; self.youpaipIDLabel = youpaipIDLabel; [self.contentView addSubview:youpaipIDLabel]; [youpaipIDLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(youpaipavatarImgV.mas_right).offset(8); make.top.mas_equalTo(youpaipnicknameL.mas_bottom).offset(6); }]; youpaipIDLabel.text = @"花舞号:54332"; youpaipIDLabel.textColor = HexColorFromRGB(0x9F9DA5); youpaipIDLabel.font = [UIFont systemFontOfSize:12]; //分割线 UIView *lineView = [UIView new]; [self.contentView addSubview:lineView]; [lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(14); make.right.mas_equalTo(-14); make.bottom.mas_equalTo(0); make.height.mas_equalTo(0.5); }]; lineView.backgroundColor = HexColorFromRGB(0x28262D); //事件 [agreeBtn addTarget:self action:@selector(youpaifagreeBtnClick) forControlEvents:UIControlEventTouchUpInside]; [RefuseBtn addTarget:self action:@selector(youpaifRefuseBtnClick) forControlEvents:UIControlEventTouchUpInside]; } //同意 -(void)youpaifagreeBtnClick{ if (self.youpaipagreeBlock) { self.youpaipagreeBlock(self.youpaipmodel); } } //拒绝 -(void)youpaifRefuseBtnClick{ if (self.youpaiprefuseBlock) { self.youpaiprefuseBlock(self.youpaipmodel); } } -(void)setYoupaipmodel:(YOUPAIHRMembershipApplicationModel *)model{ _youpaipmodel = model; [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipavatar] placeholderImage:nil]; self.youpaipnicknameL.text = model.youpaipnickname; self.youpaipIDLabel.text = [NSString stringWithFormat:@"花舞号:%@",model.youpaipusercode]; self.youpaiptimeLabel.text = model.youpaipcreate_date; CGFloat width = 0; if (model.youpaipnickname.length>5) { NSString *str = [model.youpaipnickname substringToIndex:5]; width = [LCTools widthWithString:str withFont:LCBoldFont(14)]+5; }else{ width = [LCTools widthWithString:model.youpaipnickname withFont:LCBoldFont(14)]+5; } [self.youpaipnicknameL mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(8.0f); make.top.offset(10); make.height.offset(24.5f); }]; UIView *frontV; self.youpaiplevelView.hidden = NO; [self.youpaiplevelView youpaifreloadWithIcon:model.youpaipgrade.youpaipimg1 iconWidth:model.youpaipgrade.youpaipicon_width bgImg:model.youpaipgrade.youpaipimg2 bgImgWidth:model.youpaipgrade.youpaipicon1_width levelName:model.youpaipgrade.youpaipgrade_name level:model.youpaipgrade.youpaipgrade]; [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(self.youpaipnicknameL); make.size.mas_offset(self.youpaiplevelView.mj_size); }]; frontV = self.youpaiplevelView; if (self.youpaipmodel.youpaipvip_icon.length != 0) { self.youpaipvipV.hidden = NO; [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipvip_icon]]; [self.youpaipvipV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(self.youpaipnicknameL); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; frontV = self.youpaipvipV; } if (self.youpaipmodel.youpaiprankInfo.youpaipimg.length != 0) { self.youpaipbadgeImgV.hidden = NO; [self.youpaipbadgeImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaiprankInfo.youpaipimg]]; [self.youpaipbadgeImgV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(self.youpaipnicknameL); make.size.mas_offset(CGSizeMake(20, 17.0f)); }]; } } @end