// // YOUPAILZLiveUserInfoWindow.m // VQU // // Created by CY on 2021/6/21. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZLiveUserInfoWindow.h" #import "YOUPAILZLevelView.h" #import "YOUPAILZAvatarView.h" #import "YOUPAIHRAgeSexView.h" @interface YOUPAILZLiveUserInfoWindow () @property (nonatomic, strong) YOUPAILCUserShowModel *youpaipmodel; @property (nonatomic, assign) BOOL youpaipisAnchor; @property (nonatomic, assign) BOOL youpaipisManage; @end @implementation YOUPAILZLiveUserInfoWindow - (instancetype)initWithModel:(YOUPAILCUserShowModel *)model isAnchor:(BOOL)youpaipisAnchor isManage:(BOOL)youpaipisManage{ if (self = [super init]) { _youpaipmodel = model; _youpaipisAnchor = youpaipisAnchor; _youpaipisManage = youpaipisManage; } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.baseView.hidden = YES; [self youpaifinitUI]; } - (void)youpaifinitUI{ UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 228.0f + SafeHeight)]; // bgV.backgroundColor = [UIColor clearColor]; // [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(8.0f, 8.0f)]; [self.view addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(-0.5f); make.bottom.right.offset(0.5f); make.height.offset(228.0f + SafeHeight); }]; UIImageView *avatarBgV = [[UIImageView alloc] init]; // avatarBgV.backgroundColor = [UIColor whiteColor]; [bgV addSubview:avatarBgV]; [avatarBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }]; avatarBgV.image = [UIImage imageNamed:@"vqu_images_L_live_card_bg"]; avatarBgV.userInteractionEnabled = YES; if (self.youpaipmodel.youpaipcard_info.youpaipfile.length != 0) { [avatarBgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipcard_info.youpaipfile]]; } // UIImageView *cardImgV = [[UIImageView alloc] init]; // [cardImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.model.card_info.file]]; // [self.view addSubview:cardImgV]; // [cardImgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.right.offset(0.0f); // make.top.equalTo(avatarBgV.mas_top).offset(ScaleSize(-10.0f-(65.0f/2.0f))); // make.height.offset(ScaleSize(192.0f)); // }]; YOUPAILZAvatarView *youpaipavatarView = [[YOUPAILZAvatarView alloc] initWithFrame:CGRectMake(0, 0, 55.0f, 55.0f) avatarURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipinfo.youpaipavatar] personalityBoxURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipinfo.youpaipavatar_frame]]; [self.view addSubview:youpaipavatarView]; [youpaipavatarView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.offset(0.0f); make.top.equalTo(bgV.mas_top).offset(2.0f); make.size.mas_equalTo(CGSizeMake(55.0f, 55.0f)); }]; UITapGestureRecognizer *avatarTapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifavatarBtnClick)]; [youpaipavatarView addGestureRecognizer:avatarTapG]; // UIButton *avatarBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // avatarBtn.layer.cornerRadius = 55/2; // avatarBtn.clipsToBounds = YES; // avatarBtn.imageView.contentMode = UIViewContentModeScaleAspectFill; // [avatarBtn sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.model.info.avatar] forState:UIControlStateNormal]; // [avatarBtn addTarget:self action:@selector(avatarBtnClick) forControlEvents:UIControlEventTouchUpInside]; // [avatarBgV addSubview:avatarBtn]; // [avatarBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.centerX.offset(2.0f); // make.top.offset(10.5f); // make.size.mas_equalTo(CGSizeMake(55, 55)); // }]; // CGFloat topHeight; // if (Is_iPhoneX) { // topHeight = 44; // }else{ // topHeight = 34; // } UIButton *reportBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [reportBtn setTitle:@"举报" forState:UIControlStateNormal]; [reportBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; reportBtn.titleLabel.font = LCFont(10.0f); [reportBtn addTarget:self action:@selector(youpaifreportBtnClick) forControlEvents:UIControlEventTouchUpInside]; [avatarBgV addSubview:reportBtn]; [reportBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-14.0f); make.top.offset(36.0f); // make.size.mas_offset(CGSizeMake(70.0f, 30.0f)); }]; if (self.youpaipisAnchor || self.youpaipisManage) { UIButton *manageBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [manageBtn setTitle:@"管理" forState:UIControlStateNormal]; [manageBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; manageBtn.titleLabel.font = LCFont(10.0f); [manageBtn addTarget:self action:@selector(youpaifmanageBtnClick) forControlEvents:UIControlEventTouchUpInside]; [avatarBgV addSubview:manageBtn]; [manageBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(reportBtn.mas_left).offset(-7.0f); make.top.offset(36.0f); // make.size.mas_offset(CGSizeMake(70.0f, 30.0f)); }]; } UILabel* nickLab = [[UILabel alloc]init]; nickLab.textColor = [UIColor whiteColor]; nickLab.font = LCBoldFont(14.0f); [avatarBgV addSubview:nickLab]; [nickLab makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(youpaipavatarView).offset(-9.0f); make.top.mas_equalTo(youpaipavatarView.mas_bottom).offset(14.0f); make.height.offset(14.0f); }]; nickLab.text = self.youpaipmodel.youpaipinfo.youpaipnickname; nickLab.textAlignment = NSTextAlignmentLeft; YOUPAIHRAgeSexView *sexView = [YOUPAIHRAgeSexView new]; [avatarBgV addSubview:sexView]; [sexView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nickLab.right).offset(@3); make.centerY.equalTo(nickLab); make.size.mas_equalTo(CGSizeMake(30, 14)); }]; [sexView youpaifreloadWith:self.youpaipmodel.youpaipinfo.youpaipgender Age:self.youpaipmodel.youpaipinfo.youpaipage]; //标签背景 UIView *tagBgV = [UIView new]; [avatarBgV addSubview:tagBgV]; [tagBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(nickLab.mas_bottom).offset(5); make.centerX.equalTo(avatarBgV.mas_centerX); make.height.offset(17.0f); }]; // 贵族 UIImageView *youpaipvipImgV = [[UIImageView alloc] init]; [tagBgV addSubview:youpaipvipImgV]; // 榜单 UIImageView *youpaipboardImgV = [[UIImageView alloc] init]; [tagBgV addSubview:youpaipboardImgV]; // 勋章 UIImageView *youpaipbadgeImgV = [[UIImageView alloc] init]; [tagBgV addSubview:youpaipbadgeImgV]; // 等级 YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init]; [tagBgV addSubview:youpaiplevelView]; //花舞号 UIView *IDbgView = [UIView new]; [avatarBgV addSubview:IDbgView]; [IDbgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(91); make.right.mas_equalTo(-91); make.top.mas_equalTo(tagBgV.mas_bottom).offset(7); make.height.mas_equalTo(15); }]; UIButton *idBtn = [UIButton buttonWithType:UIButtonTypeCustom]; idBtn.titleLabel.font = [UIFont systemFontOfSize:10]; [idBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [idBtn setTitle:[NSString stringWithFormat:@"花舞号:%@",self.youpaipmodel.youpaipinfo.youpaipusercode] forState:UIControlStateNormal]; [idBtn addTarget:self action:@selector(youpaifcopyBtnClick) forControlEvents:UIControlEventTouchUpInside]; [IDbgView addSubview:idBtn]; [idBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(0.0f); make.centerY.offset(0.0f); make.height.offset(12.0f); }]; UIButton *copyIDBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [copyIDBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_copy_code"] forState:UIControlStateNormal]; [copyIDBtn addTarget:self action:@selector(youpaifcopyBtnClick) forControlEvents:UIControlEventTouchUpInside]; [IDbgView addSubview:copyIDBtn]; [copyIDBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(idBtn.mas_right).offset(4.0f); make.centerY.equalTo(idBtn.mas_centerY); make.size.mas_offset(CGSizeMake(12.0f, 12.0f)); }]; UIView *line1 = [[UIView alloc] init]; line1.backgroundColor = [UIColor whiteColor]; [IDbgView addSubview:line1]; [line1 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(copyIDBtn.mas_right).offset(10.0f); make.centerY.equalTo(idBtn.mas_centerY); make.size.mas_offset(CGSizeMake(0.5f, 7.0f)); }]; UILabel* youpaipcountL = [[UILabel alloc]init]; youpaipcountL.textColor = [UIColor whiteColor]; youpaipcountL.font = LCFont(10.0f); [IDbgView addSubview:youpaipcountL]; [youpaipcountL makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(line1.mas_right).offset(7); make.centerY.equalTo(0); make.height.offset(11.0f); }]; youpaipcountL.text = [NSString stringWithFormat:@"粉丝 %@ | 关注 %@",@(self.youpaipmodel.youpaipinfo.youpaipfans_count),@(self.youpaipmodel.youpaipinfo.youpaipfollow_count)]; //简介 UILabel* contentLabel = [[UILabel alloc]init]; contentLabel.textColor = [UIColor whiteColor]; contentLabel.font = LCFont(10.0f); [avatarBgV addSubview:contentLabel]; [contentLabel makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(0); make.top.equalTo(IDbgView.mas_bottom).offset(3); make.height.offset(10.0f); make.width.mas_lessThanOrEqualTo(200); }]; contentLabel.text = self.youpaipmodel.youpaipinfo.youpaipsign; contentLabel.lineBreakMode = NSLineBreakByTruncatingTail; //赠送砖石 UILabel* dashangLabel = [[UILabel alloc]init]; dashangLabel.textColor = HexColorFromRGB(0xffffff); dashangLabel.font = LCFont(10.0f); [avatarBgV addSubview:dashangLabel]; [dashangLabel makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(0); make.top.equalTo(contentLabel.mas_bottom).offset(12); make.height.offset(10.0f); }]; dashangLabel.text = [NSString stringWithFormat:@"赠送钻石:%d",[self.youpaipmodel.youpaipgr.youpaipgrade.youpaiptotal_growth intValue]]; UIView *line = [[UIView alloc] init]; line.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4f]; [avatarBgV addSubview:line]; [line mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.offset(0.0f); make.top.equalTo(dashangLabel.mas_bottom).offset(15.0f); make.height.offset(0.5f); }]; NSArray *btnContents = @[ @{@"image":[UIImage new],@"selectedImage":[UIImage new],@"title":@"关注",@"selectedTitle":@"取消关注",@"titleColor":HexColorFromRGB(0xffffff),@"selectedTitleColor":HexColorFromRGB(0xffffff),@"isSelected":@(self.youpaipmodel.youpaipinfo.youpaipis_follow)}, @{@"image":[UIImage imageNamed:@"vqu_images_IM_card_shouhu"],@"selectedImage":[UIImage imageNamed:@"vqu_images_IM_card_shouhu"],@"title":@"守护",@"selectedTitle":@"守护",@"titleColor":HexColorFromRGB(0xffffff),@"selectedTitleColor":HexColorFromRGB(0xffffff),@"isSelected":@(NO)}, @{@"image":[UIImage imageNamed:@"vqu_images_L_live_userinfo_gift_new"],@"selectedImage":[UIImage imageNamed:@"vqu_images_L_live_userinfo_gift_new"],@"title":@"送礼",@"selectedTitle":@"送礼",@"titleColor":HexColorFromRGB(0xffffff),@"selectedTitleColor":HexColorFromRGB(0xffffff),@"isSelected":@(NO),}, @{@"image":[UIImage new],@"selectedImage":[UIImage new],@"title":@"私信",@"selectedTitle":@"私信",@"titleColor":HexColorFromRGB(0xffffff),@"selectedTitleColor":HexColorFromRGB(0xffffff),@"isSelected":@(NO),} ]; NSMutableArray *youpaipbtns = [NSMutableArray array]; for (NSInteger i = 0; i < btnContents.count; i ++) { NSDictionary *dict = btnContents[i]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [btn setTitle:dict[@"title"] forState:UIControlStateNormal]; [btn setTitle:dict[@"selectedTitle"] forState:UIControlStateSelected]; [btn setTitleColor:dict[@"titleColor"] forState:UIControlStateNormal]; [btn setTitleColor:dict[@"selectedTitleColor"] forState:UIControlStateSelected]; [btn setImage:dict[@"image"] forState:UIControlStateNormal]; [btn setImage:dict[@"selectedImage"] forState:UIControlStateSelected]; btn.selected = [dict[@"isSelected"] boolValue]; btn.titleLabel.font = LCFont13; btn.tag = i; [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside]; [avatarBgV addSubview:btn]; [youpaipbtns addObject:btn]; } [youpaipbtns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0]; [youpaipbtns mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(line.mas_bottom).offset(0.0f); make.height.equalTo(44.0f); }]; CGFloat x = KScreenWidth / 4.0f; for (NSInteger i = 0; i < 3; i ++) { UIView *v = [[UIView alloc] init]; v.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4f]; [avatarBgV addSubview:v]; [v mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset((i + 1) * x); make.top.equalTo(line.mas_bottom).offset(15.0f); make.width.offset(0.5f); make.height.offset(14.0f); }]; } UIImageView *anchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]]; [self.view addSubview:anchorTagImgV]; [anchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(youpaipavatarView.youpaipavatarImgV.mas_right).offset(0.0f); make.bottom.equalTo(youpaipavatarView.youpaipavatarImgV.mas_bottom).offset(0.0f); make.size.mas_offset(CGSizeMake(10.0f, 10.0f)); }]; anchorTagImgV.hidden = self.youpaipmodel.youpaipinfo.youpaipis_live != 1; UIView *frontV; if (self.youpaipmodel.youpaipinfo.youpaipvip_icon.length != 0) { [youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipinfo.youpaipvip_icon]]; [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.offset(0.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(0.0f); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; frontV = youpaipvipImgV; } if (self.youpaipmodel.youpaipgr.youpaiprank.youpaipimg.length != 0) { [youpaipboardImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipgr.youpaiprank.youpaipimg]]; [youpaipboardImgV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.offset(0.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(0.0f); make.size.mas_offset(CGSizeMake(21.0f, 18.0f)); }]; frontV = youpaipboardImgV; } if (self.youpaipmodel.youpaipbadge_info.youpaipfile.length != 0) { [youpaipbadgeImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipbadge_info.youpaipfile]]; [youpaipbadgeImgV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.offset(0.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(0.0f); make.size.mas_offset(CGSizeMake(self.youpaipmodel.youpaipbadge_info.youpaipwidth, 17.0f)); }]; frontV = youpaipbadgeImgV; } [youpaiplevelView youpaifreloadWithIcon:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipimg1 iconWidth:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipicon_width bgImg:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipimg2 bgImgWidth:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipicon1_width levelName:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipgrade_name level:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipgrade]; [youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.offset(0.0f); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.centerY.equalTo(0); make.size.mas_offset(youpaiplevelView.mj_size); make.right.offset(0.0f); }]; } // 复制ID点击事件 - (void)youpaifcopyBtnClick{ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = self.youpaipmodel.youpaipinfo.youpaipusercode; [ZCHUDHelper showTitle:@"复制成功"]; } - (void)youpaifavatarBtnClick{ if(!self.youpaipisAnchor){ [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipuserShowBlock != nil) { self.youpaipuserShowBlock(self.youpaipmodel); } }]; } } - (void)youpaifreportBtnClick{ if(!self.youpaipisAnchor){ [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipreportBlock != nil) { self.youpaipreportBlock(self.youpaipmodel); } }]; } } - (void)youpaifmanageBtnClick{ [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipmanageBlock != nil) { self.youpaipmanageBlock(self.youpaipmodel,self.youpaipisAnchor); } }]; } - (void)youpaifbtnClick:(UIButton *)sender{ if ([self.youpaipmodel.youpaipinfo.youpaipuserid isEqual:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id] && sender.tag == 0) { [ZCHUDHelper showTitle:@"不能关注自己哦~"]; return; } sender.selected = !sender.selected; if (sender.tag == 0) { [LCCommonHttp followUserId:self.youpaipmodel.youpaipinfo.youpaipuserid]; }else if (sender.tag == 1){ [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipguardBlock != nil) { self.youpaipguardBlock(self.youpaipmodel); } }]; }else if (sender.tag == 2){ [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipgiftBlock != nil) { self.youpaipgiftBlock(self.youpaipmodel); } }]; }else if (sender.tag == 3){ [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipsiXinBlock != nil) { self.youpaipsiXinBlock(self.youpaipmodel); } }]; } } @end