// // YOUPAILZLiveOnlineMemberCell.m // VQU // // Created by CY on 2021/6/23. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZLiveOnlineMemberCell.h" #import "YOUPAILZLevelView.h" #import "YOUPAILZAvatarView.h" @interface YOUPAILZLiveOnlineMemberCell () @property (nonatomic, weak) UIImageView *youpaiprankImgV; @property (nonatomic, weak) UILabel *youpaiprankL; @property (nonatomic, weak) YOUPAILZAvatarView *youpaipavatarView; @property (nonatomic, weak) UILabel *youpaipnicknameL; @property (nonatomic, weak) UIImageView *youpaipsexV; @property (nonatomic, weak) UIImageView *youpaipvipImgV; @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView; @property (nonatomic, weak) UILabel *youpaipcontributionL; @property (nonatomic, weak) UIButton *youpaipfollowBtn; @property (nonatomic, strong) YOUPAILZLiveMemberModel *youpaipmemberModel; @property (nonatomic, strong) UIColor *youpaipthemeColor; @end @implementation YOUPAILZLiveOnlineMemberCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ UIImageView *youpaiprankImgV = [[UIImageView alloc] init]; [self.contentView addSubview:youpaiprankImgV]; self.youpaiprankImgV = youpaiprankImgV; [youpaiprankImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(7.0f); make.centerY.equalTo(self.contentView); make.size.mas_offset(CGSizeMake(38.0f, 28.0f)); }]; UILabel *youpaiprankL = [[UILabel alloc] init]; youpaiprankL.textColor = HexColorFromRGB(0x9F9DA5); youpaiprankL.textAlignment = NSTextAlignmentCenter; youpaiprankL.font = LCFont12; [self.contentView addSubview:youpaiprankL]; self.youpaiprankL = youpaiprankL; [youpaiprankL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(7.0f); make.centerY.equalTo(self.centerY); make.size.mas_offset(CGSizeMake(38.0f, 28.0f)); }]; YOUPAILZAvatarView *youpaipavatarView = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0, 0, 40, 40) avatarURL:nil personalityBoxURL:nil]; [self.contentView addSubview:youpaipavatarView]; self.youpaipavatarView = youpaipavatarView; [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(52.0f); make.centerY.equalTo(self.contentView.mas_centerY); make.size.mas_offset(CGSizeMake(40.0f, 40.0f)); }]; UILabel *youpaipnicknameL = [[UILabel alloc] init]; youpaipnicknameL.font = LCBoldFont(14.0f); youpaipnicknameL.textColor = [UIColor whiteColor]; [self.contentView addSubview:youpaipnicknameL]; self.youpaipnicknameL = youpaipnicknameL; [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f); make.top.offset(15.0f); }]; UIImageView *youpaipsexV = [[UIImageView alloc] init]; [self.contentView addSubview:youpaipsexV]; self.youpaipsexV = youpaipsexV; [youpaipsexV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipnicknameL.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); make.size.mas_offset(CGSizeMake(15.0f, 15.0f)); }]; UIImageView *youpaipvipImgV = [[UIImageView alloc] init]; [self.contentView addSubview:youpaipvipImgV]; self.youpaipvipImgV = youpaipvipImgV; [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipsexV.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init]; [self.contentView addSubview:youpaiplevelView]; self.youpaiplevelView = youpaiplevelView; [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipsexV.mas_right).offset(3.0f); make.centerY.equalTo(youpaipnicknameL); }]; UILabel *youpaipcontributionL = [[UILabel alloc] init]; youpaipcontributionL.font = LCFont(10.0f); youpaipcontributionL.textColor = [UIColor whiteColor]; [self.contentView addSubview:youpaipcontributionL]; self.youpaipcontributionL = youpaipcontributionL; [youpaipcontributionL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipavatarView.mas_right).offset(8.0f); make.top.equalTo(youpaipnicknameL.mas_bottom).offset(2.0f); }]; UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom]; youpaipfollowBtn.layer.cornerRadius = 11.0f; youpaipfollowBtn.clipsToBounds = YES; youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0xFFDD8D).CGColor; youpaipfollowBtn.layer.borderWidth = 0.5f; [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal]; [youpaipfollowBtn setTitleColor:HexColorFromRGB(0xFFDD8D) forState:UIControlStateNormal]; youpaipfollowBtn.titleLabel.font = LCFont12; [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.contentView addSubview:youpaipfollowBtn]; self.youpaipfollowBtn = youpaipfollowBtn; [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.contentView); make.right.offset(-12.0f); make.size.mas_offset(CGSizeMake(56.0f, 22.0f)); }]; } - (void)youpaifreloadWithModel:(YOUPAILZLiveMemberModel *)member indexPath:(NSIndexPath *)indexPath type:(LZLiveMemberListType)type youpaipthemeColor:(UIColor *)youpaipthemeColor{ self.youpaipmemberModel = member; self.youpaipthemeColor = youpaipthemeColor; if (indexPath.row + 1 <= 3 && type != LZLiveMemberListTypeOnline) { self.youpaiprankImgV.hidden = NO; self.youpaiprankL.hidden = YES; self.youpaiprankImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_L_live_rank_consumption_%@",@(indexPath.row + 1)]]; NSArray *colors = @[HexColorFromRGB(0xF5C686),HexColorFromRGB(0xDFF6FF),HexColorFromRGB(0xB8CC8B)]; self.youpaipavatarView.youpaipavatarImgV.layer.borderColor = colors[indexPath.row].CGColor; }else{ self.youpaiprankImgV.hidden = YES; self.youpaiprankL.hidden = NO; self.youpaipavatarView.youpaipavatarImgV.layer.borderColor = HexColorFromRGB(0x9F9DA5).CGColor; } self.youpaiprankL.text = [NSString stringWithFormat:@"%@",@(indexPath.row + 1)]; self.youpaipfollowBtn.hidden = NO; if (member.youpaipis_follow == 1){ self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor; [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal]; [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal]; }else if (member.youpaipis_follow == 0){ self.youpaipfollowBtn.layer.borderColor = youpaipthemeColor.CGColor; [self.youpaipfollowBtn setTitleColor:youpaipthemeColor forState:UIControlStateNormal]; [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal]; }else{ self.youpaipfollowBtn.hidden = YES; } self.youpaipavatarView.youpaipavatarURL = [LCTools getImageUrlWithAddress:member.youpaipavatar]; self.youpaipavatarView.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:member.youpaipavatar_frame]; self.youpaipnicknameL.text = member.youpaipnickname; if (member.youpaipgender == 1) {//0未知 1女 2男 self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"]; }else{ self.youpaipsexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"]; } self.youpaipvipImgV.hidden = YES; self.youpaiplevelView.hidden = YES; UIView *frontV; if (member.youpaipvip_icon.length != 0) { self.youpaipvipImgV.hidden = NO; [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:member.youpaipvip_icon]]; [self.youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipsexV.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.youpaipvipImgV; } self.youpaiplevelView.hidden = NO; [self.youpaiplevelView youpaifreloadWithIcon:member.youpaipgrade.youpaipimg1 iconWidth:member.youpaipgrade.youpaipicon_width bgImg:member.youpaipgrade.youpaipimg2 bgImgWidth:member.youpaipgrade.youpaipicon1_width levelName:member.youpaipgrade.youpaipgrade_name level:member.youpaipgrade.youpaipgrade]; [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(self.youpaipsexV.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); }]; self.youpaipcontributionL.attributedText = [LCTools setRichTextWithTitle:@"贡献值:" subTitle:[NSString stringWithFormat:@"%@",member.youpaipscore] titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:10.0f subTitleFontSize:10.0f]; } - (void)youpaiffollowBtnClick{ self.youpaipmemberModel.youpaipis_follow = self.youpaipmemberModel.youpaipis_follow == 1 ? 0 : 1; if (self.youpaipmemberModel.youpaipis_follow== 1){ self.youpaipfollowBtn.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor; [self.youpaipfollowBtn setTitleColor:HexColorFromRGB(0x4F4B5B) forState:UIControlStateNormal]; [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal]; }else{ self.youpaipfollowBtn.layer.borderColor = self.youpaipthemeColor.CGColor; [self.youpaipfollowBtn setTitleColor:self.youpaipthemeColor forState:UIControlStateNormal]; [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal]; } [LCCommonHttp followUserId:self.youpaipmemberModel.youpaipid]; } @end