// // YOUPAIHRLiveRankDetailCell.m // VQU // // Created by xiaohaoran on 2021/10/19. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRLiveRankDetailCell.h" #import "RippleAnimationView.h" #import "YOUPAILZAvatarView.h" #import "YOUPAILZLevelView.h" #import "YOUPAILCIMSessionVC.h" @interface YOUPAIHRLiveRankDetailCell() @property(nonatomic,strong)YOUPAILZAvatarView* youpaipavatarImgV; @property(nonatomic,strong)UIImageView * youpaipanchorTagImgV; @property(nonatomic,strong)UILabel * youpaipnicknameL; @property(nonatomic,strong)UIImageView *youpaipvipV; @property(nonatomic,strong)UIImageView *youpaipbadgeImgV; @property(nonatomic,strong)YOUPAILZLevelView *youpaiplevelView; @property(nonatomic,strong)UILabel *youpaipzuanshiCountLabel; @property(nonatomic,strong)UILabel *youpaiplianmaiLabel; @property(nonatomic,strong)UIButton *youpaipfollowBtn; @end @implementation YOUPAIHRLiveRankDetailCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self youpaifsetSubView]; } return self; } -(void)youpaifsetSubView{ //头像 YOUPAILZAvatarView *avatarImgV = [YOUPAILZAvatarView youpaifavatarViewWithFrame:CGRectMake(0.0f, 0.0f, 40, 40) avatarURL:nil personalityBoxURL:nil]; [self.contentView addSubview:avatarImgV]; self.youpaipavatarImgV = avatarImgV; [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.centerY.mas_equalTo(0); make.size.offset(40); }]; //V avatarImgV.userInteractionEnabled = YES; UIImageView *anchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]]; anchorTagImgV.hidden = YES; [self.contentView addSubview:anchorTagImgV]; self.youpaipanchorTagImgV = anchorTagImgV; [anchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.youpaipavatarImgV.youpaipavatarImgV.mas_right).offset(0.0f); make.bottom.equalTo(self.youpaipavatarImgV.youpaipavatarImgV.mas_bottom).offset(0.0f); make.size.mas_offset(CGSizeMake(10.0f, 10.0f)); }]; //昵称 UILabel *nicknameL = [[UILabel alloc] init]; nicknameL.font = LCBoldFont(14); nicknameL.textColor = LZ273145Color; [self.contentView addSubview:nicknameL]; self.youpaipnicknameL = nicknameL; [nicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(avatarImgV.mas_right).offset(10.0f); make.top.offset(10.0f); make.height.offset(24.5f); }]; //Vip UIImageView *vipV = [[UIImageView alloc] init]; [self addSubview:vipV]; self.youpaipvipV = vipV; vipV.hidden = YES; [vipV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nicknameL.mas_right).offset(3.0f); make.centerY.equalTo(nicknameL); }]; UIImageView *badgeImgV = [[UIImageView alloc] init]; [self addSubview:badgeImgV]; self.youpaipbadgeImgV = badgeImgV; badgeImgV.hidden = YES; [badgeImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nicknameL.mas_right).offset(3.0f); make.centerY.equalTo(nicknameL); }]; YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init]; [self addSubview:levelView]; self.youpaiplevelView = levelView; levelView.hidden = YES; [levelView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nicknameL.mas_right).offset(3.0f); make.centerY.equalTo(nicknameL); }]; //钻石图标 UIImageView *zuanShiImageView = [UIImageView new]; [self.contentView addSubview:zuanShiImageView]; [zuanShiImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(nicknameL); make.top.mas_equalTo(nicknameL.mas_bottom).offset(3); make.size.mas_equalTo(CGSizeMake(10, 10)); }]; zuanShiImageView.image = [UIImage imageNamed:@"vqu_images_D_mine_Money_Icon"]; //钻石数量 UILabel *zuanshiCountLabel = [UILabel new]; self.youpaipzuanshiCountLabel = zuanshiCountLabel; [self.contentView addSubview:zuanshiCountLabel]; [zuanshiCountLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(zuanShiImageView.mas_right).offset(2); make.centerY.mas_equalTo(zuanShiImageView); }]; zuanshiCountLabel.font = [UIFont systemFontOfSize:10]; zuanshiCountLabel.textColor = LZA3AABEColor; //连麦次数展示 UILabel *lianmaiLabel = [UILabel new]; self.youpaiplianmaiLabel = lianmaiLabel; [self.contentView addSubview:lianmaiLabel]; [lianmaiLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(nicknameL); make.top.mas_equalTo(zuanshiCountLabel.mas_bottom).offset(5); }]; lianmaiLabel.text = @"共3次连麦(最后连麦2021-07-23)"; lianmaiLabel.font = [UIFont systemFontOfSize:10]; lianmaiLabel.textColor = HexColorFromRGBA(0xFFFFFF,0.6); //私信 YOUPAIGradualButton *chatBtn = [YOUPAIGradualButton new]; [self.contentView addSubview:chatBtn]; [chatBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-14); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(60, 29)); }]; [chatBtn setTitle:@"私信" forState:UIControlStateNormal]; chatBtn.titleLabel.font = [UIFont systemFontOfSize:12]; //关注 UIButton *followBtn = [UIButton new]; self.youpaipfollowBtn = followBtn; [self.contentView addSubview:followBtn]; [followBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(chatBtn.mas_left).offset(-5); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(60, 29)); }]; followBtn.layer.borderWidth = 1; followBtn.layer.cornerRadius = 14; followBtn.layer.masksToBounds = YES; followBtn.layer.borderColor = HexColorFromRGB(0xF4003F).CGColor; [followBtn setTitle:@"关注" forState:UIControlStateNormal]; followBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [followBtn setTitleColor:HexColorFromRGB(0xF4003F) forState:UIControlStateNormal]; //分割线 UIView *lineView = [UIView new]; [self.contentView addSubview:lineView]; [lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.bottom.mas_equalTo(0); make.right.mas_equalTo(-12); make.height.mas_equalTo(0.5); }]; lineView.backgroundColor = LZF5F4F7Color; //事件 [chatBtn addTarget:self action:@selector(youpaifchatBtnClick) forControlEvents:UIControlEventTouchUpInside]; [followBtn addTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside]; } -(void)youpaifchatBtnClick{ NIMSession *session = [NIMSession session:self.youpaipuserModel.youpaipid type:NIMSessionTypeP2P]; if (session) { [ZCHUDHelper show]; [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { [ZCHUDHelper dismiss]; YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session]; [[LCTools getCurrentVC].navigationController pushViewController:vc animated:YES]; }]; } } -(void)youpaiffollowBtnClick:(UIButton*)sender{ if (self.youpaipuserModel.youpaipis_follow==1) { [LCCommonHttp followUserId:self.youpaipuserModel.youpaipid]; self.youpaipuserModel.youpaipis_follow = 0; }else{ [LCCommonHttp followUserId:self.youpaipuserModel.youpaipid]; self.youpaipuserModel.youpaipis_follow = 1; } [self youpaifupdateBtnStatu]; } -(void)youpaifupdateBtnStatu{ if (self.youpaipuserModel.youpaipis_follow == 1) { self.youpaipfollowBtn.layer.borderWidth = 1; self.youpaipfollowBtn.layer.cornerRadius = 15; self.youpaipfollowBtn.layer.masksToBounds = YES; self.youpaipfollowBtn.layer.borderColor = LZD3D1D7Color.CGColor; [self.youpaipfollowBtn setTitle:@"已关注" forState:UIControlStateNormal]; self.youpaipfollowBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [self.youpaipfollowBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; self.youpaipfollowBtn.backgroundColor = LZD3D1D7Color; }else{ self.youpaipfollowBtn.layer.borderWidth = 1; self.youpaipfollowBtn.layer.cornerRadius = 15; self.youpaipfollowBtn.layer.masksToBounds = YES; self.youpaipfollowBtn.layer.borderColor = LZ7C69FEColor.CGColor; [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal]; self.youpaipfollowBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [self.youpaipfollowBtn setTitleColor:LZ7C69FEColor forState:UIControlStateNormal]; self.youpaipfollowBtn.backgroundColor = UIColor.clearColor; } } -(void)setYoupaipuserModel:(YOUPAIHRsendRankModel *)userModel{ _youpaipuserModel = userModel; self.youpaipavatarImgV.youpaipavatarURL = [LCTools getImageUrlWithAddress:userModel.youpaipavatar]; self.youpaipavatarImgV.youpaippersonalityBoxURL = [LCTools getImageUrlWithAddress:userModel.youpaipavatar_frame]; // [self.avatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:userModel.userinfo.avatar]]; self.youpaipzuanshiCountLabel.text = userModel.youpaipamount; self.youpaiplianmaiLabel.text = userModel.youpaipmsg; self.youpaipnicknameL.text = userModel.youpaipnickname; self.youpaipvipV.hidden = YES; self.youpaipbadgeImgV.hidden = YES; self.youpaiplevelView.hidden = YES; // 1关注 0未关注 -1自己 [self youpaifupdateBtnStatu]; CGFloat width = 0; if (userModel.youpaipnickname.length>5) { NSString *str = [userModel.youpaipnickname substringToIndex:5]; width = [LCTools widthWithString:str withFont:LCBoldFont(14)]+5; }else{ width = [LCTools widthWithString:userModel.youpaipnickname withFont:LCBoldFont(14)]+5; } [self.youpaipnicknameL mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f); make.top.offset(10.0f); make.height.offset(24.5f); make.width.mas_equalTo(width); }]; UIView *frontV; self.youpaiplevelView.hidden = NO; [self.youpaiplevelView youpaifreloadWithIcon:userModel.youpaipgrade.youpaipimg1 iconWidth:userModel.youpaipgrade.youpaipicon_width bgImg:userModel.youpaipgrade.youpaipimg2 bgImgWidth:userModel.youpaipgrade.youpaipicon1_width levelName:userModel.youpaipgrade.youpaipgrade_name level:userModel.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.youpaipuserModel.youpaipvip_icon.length != 0) { self.youpaipvipV.hidden = NO; [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipuserModel.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.youpaipuserModel.youpaiprankInfo.youpaipimg.length != 0) { self.youpaipbadgeImgV.hidden = NO; [self.youpaipbadgeImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipuserModel.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