// // YOUPAIHRGuildCenterDetailHeaderView.m // VQU // // Created by xiaohaoran on 2021/11/4. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRGuildCenterDetailHeaderView.h" #import "YOUPAIHRGuildCenterBtn.h" #import "YOUPAIHRChatRoomGuildBalanceVC.h" #import "YOUPAIHRGuildDetailVC.h" #import "YOUPAIHRGuildCenterSearchVC.h" @interface YOUPAIHRGuildCenterDetailHeaderView () @property(nonatomic,strong)UIImageView *youpaipavatarImgV; @property(nonatomic,strong)UIImageView *youpaipiconImageView; @property(nonatomic,strong)UILabel *youpaipnameLabel; @property(nonatomic,strong)UIButton *youpaipIDBtn; @property(nonatomic,strong)UILabel *youpaipcontentLabel; @property(nonatomic,strong)UILabel *youpaiptitleLabel; @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaipTotalBtn; // 总收益 @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaiptodayRoomBtn; // 今天房间分成 @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaiptodayGuildBtn; // 今天公会分成 @property (nonatomic, weak) YOUPAIHRGuildCenterBtn *youpaipwithdrawBtn; // 余额/提现 @property(nonatomic,strong)YOUPAIHRGuildCenterDetailModel *youpaipmodel; @property(nonatomic,strong)UIView *youpaipmoreView; @end @implementation YOUPAIHRGuildCenterDetailHeaderView -(instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self youpaifsetSubView]; } return self; } -(void)youpaifsetSubView{ UIImageView *youpaipavatarImgV = [[UIImageView alloc] init]; self.youpaipavatarImgV = youpaipavatarImgV; [self addSubview:youpaipavatarImgV]; youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill; youpaipavatarImgV.clipsToBounds = YES; [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(210); }]; youpaipavatarImgV.image = [UIImage imageNamed:@"vqu_images_chatroom_bg"]; // [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[LCSaveModel getUserModel].userinfo.avatar]]; UIView *avatarColorV = [[UIView alloc] init]; [youpaipavatarImgV addSubview:avatarColorV]; [avatarColorV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }]; avatarColorV.backgroundColor = [HexColorFromRGB(0x1C1D23) colorWithAlphaComponent:0.9f]; //头像 UIImageView *youpaipiconImageView = [UIImageView new]; self.youpaipiconImageView = youpaipiconImageView; [self addSubview:youpaipiconImageView]; [youpaipiconImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(18); make.centerX.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(84, 84)); }]; youpaipiconImageView.contentMode = UIViewContentModeScaleAspectFill; youpaipiconImageView.layer.cornerRadius = 84/2; youpaipiconImageView.layer.masksToBounds = YES; // youpaipiconImageView.image = [UIImage imageNamed:@"AppIcon"]; //公会名称 UILabel *youpaipnameLabel = [UILabel new]; self.youpaipnameLabel = youpaipnameLabel; [self addSubview:youpaipnameLabel]; [youpaipnameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(youpaipiconImageView); make.top.mas_equalTo(youpaipiconImageView.mas_bottom).offset(21.5); }]; youpaipnameLabel.font = LCBoldFont(17); youpaipnameLabel.textColor = [UIColor whiteColor]; //公会ID UIButton *youpaipIDBtn = [UIButton new]; self.youpaipIDBtn = youpaipIDBtn; [self addSubview:youpaipIDBtn]; [youpaipIDBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(0); make.top.mas_equalTo(youpaipnameLabel.mas_bottom).offset(9); }]; [youpaipIDBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; youpaipIDBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [youpaipIDBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_copy"] forState:UIControlStateNormal]; [youpaipIDBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft]; //内容 UILabel *contentLabel = [UILabel new]; self.youpaipcontentLabel = contentLabel; [self addSubview:contentLabel]; [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(14); make.right.mas_equalTo(-14); make.top.mas_equalTo(youpaipIDBtn.mas_bottom).offset(0); make.height.mas_equalTo(60); }]; contentLabel.textColor = HexColorFromRGB(0x9F9DA5); contentLabel.font = [UIFont systemFontOfSize:12]; contentLabel.numberOfLines = 3; contentLabel.textAlignment = NSTextAlignmentCenter; contentLabel.lineBreakMode = NSLineBreakByTruncatingTail; //下面收益|分成|提现 UIView *youpaipmoreView = [UIView new]; self.youpaipmoreView = youpaipmoreView; [self addSubview:youpaipmoreView]; [youpaipmoreView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(contentLabel.mas_bottom).offset(5); make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.height.mas_equalTo(70); }]; youpaipmoreView.backgroundColor = HexColorFromRGBA(0x4F4B5B, 0.4); youpaipmoreView.layer.cornerRadius = 4; youpaipmoreView.layer.masksToBounds = YES; youpaipmoreView.hidden = YES; UIView *countBtnBgV = [[UIView alloc] init]; [youpaipmoreView addSubview:countBtnBgV]; [countBtnBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(0); make.right.offset(0); make.centerY.equalTo(0); make.height.offset(40.0f); }]; //4个 NSArray *btnContents = @[ @{@"title":LCStr(word12),@"count":@"0"},//今日总收益 @{@"title":LCStr(word13),@"count":@"0"},//今日房间分成 @{@"title":LCStr(word14),@"count":@"0"},//今日公会分成 @{@"title":LCStr(word15),@"count":@"0"},//公会分成收益 ]; NSMutableArray *btns = [NSMutableArray array]; for (NSInteger i = 0; i < btnContents.count; i ++) { NSDictionary *dict = btnContents[i]; YOUPAIHRGuildCenterBtn *badgeBtn = [[YOUPAIHRGuildCenterBtn alloc] init]; badgeBtn.youpaipcount = dict[@"count"] ; badgeBtn.youpaiptitleStr = dict[@"title"]; badgeBtn.tag = 6000+i; [countBtnBgV addSubview:badgeBtn]; [badgeBtn addTarget:self action:@selector(youpaifguildyoupaifcenterBtnClick:) forControlEvents:UIControlEventTouchUpInside]; [btns addObject:badgeBtn]; if (i == 0) { self.youpaipTotalBtn = badgeBtn; }else if (i == 1){ self.youpaiptodayRoomBtn = badgeBtn; }else if (i == 2){ self.youpaiptodayGuildBtn = badgeBtn; }else{ self.youpaipwithdrawBtn = badgeBtn; } } [btns mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0]; [btns mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); }]; for (NSInteger i = 1; i < btns.count; i ++) { YOUPAIHRGuildCenterBtn *badgeBtn = btns[i]; UIView *line = [[UIView alloc] init]; line.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.22f]; [countBtnBgV addSubview:line]; [line mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(badgeBtn.mas_left); make.centerY.equalTo(badgeBtn); make.size.mas_offset(CGSizeMake(1.0f, 10.0f)); }]; } UIView *bottomView = [[UIView alloc]init]; [self addSubview:bottomView]; [bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(youpaipmoreView.mas_bottom); make.height.mas_equalTo(69); }]; //centerView UIView *centerView = [UIView new]; [bottomView addSubview:centerView]; [centerView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(0); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); make.width.mas_equalTo(250); }]; //title UILabel *titleLabel = [UILabel new]; self.youpaiptitleLabel = titleLabel; [centerView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(0); make.centerX.mas_equalTo(0); }]; titleLabel.textColor = [UIColor whiteColor]; //leftImage UIImageView *leftImage = [UIImageView new]; [centerView addSubview:leftImage]; [leftImage mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(titleLabel.mas_left).offset(-6); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(28.5, 5)); }]; leftImage.image = [UIImage imageNamed:@"vqu_images_guild_line_left"]; //rightImage UIImageView *rightImage = [UIImageView new]; [centerView addSubview:rightImage]; [rightImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(titleLabel.mas_right).offset(-2); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(28.5, 5)); }]; rightImage.image = [UIImage imageNamed:@"vqu_images_guild_line_right"]; //事件 [youpaipIDBtn addTarget:self action:@selector(youpaifIDBtnClick) forControlEvents:UIControlEventTouchUpInside]; } -(void)youpaifIDBtnClick{ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = [NSString stringWithFormat:@"%ld",self.youpaipmodel.guild_number]; [ZCHUDHelper showTitle:@"复制成功"]; } -(void)setYoupaipguild:(NSInteger)youpaipguild{ _youpaipguild = youpaipguild; if (youpaipguild == 2) { self.youpaipmoreView.hidden = NO; [self.youpaipmoreView mas_remakeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.youpaipcontentLabel.mas_bottom).offset(5); make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.height.mas_equalTo(70); }]; }else{ self.youpaipmoreView.hidden = YES; [self.youpaipmoreView mas_remakeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.youpaipcontentLabel.mas_bottom).offset(5); make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.height.mas_equalTo(0); }]; } } -(void)youpaifreloadHeaderViewWith:(YOUPAIHRGuildCenterDetailModel *)model{ self.youpaipmodel = model; [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.img] placeholderImage:nil]; [self.youpaipiconImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.img] placeholderImage:nil]; self.youpaipnameLabel.text = model.name; [self.youpaipIDBtn setTitle:[NSString stringWithFormat:@"公会ID:%ld",(long)model.guild_number] forState:UIControlStateNormal]; self.youpaipcontentLabel.text = model.des; self.youpaipTotalBtn.youpaipcount = model.toDay; self.youpaiptodayRoomBtn.youpaipcount =model.toDayRoom ; self.youpaiptodayGuildBtn.youpaipcount =model.toDayGuild; self.youpaipwithdrawBtn.youpaipcount =model.money; self.youpaiptitleLabel.text = [NSString stringWithFormat:@"公会成员(%ld)",(long)model.memberNumber]; } -(void)youpaifguildyoupaifcenterBtnClick:(UIButton*)sender{ if (sender.tag == 6003) { if (self.youpaipguild == 2) { YOUPAIHRGuildDetailVC *vc = [YOUPAIHRGuildDetailVC new]; [[LCTools getCurrentVC].navigationController pushViewController:vc animated:YES]; }else{ YOUPAIHRGuildCenterSearchVC *vc = [YOUPAIHRGuildCenterSearchVC new]; [[LCTools getCurrentVC].navigationController pushViewController:vc animated:YES]; } } } @end