146 lines
6.1 KiB
Objective-C
146 lines
6.1 KiB
Objective-C
//
|
||
// QXNobilityHeaderView.m
|
||
// QXLive
|
||
//
|
||
// Created by 启星 on 2025/11/7.
|
||
//
|
||
|
||
#import "QXNobilityHeaderView.h"
|
||
#import "QXSeatHeaderView.h"
|
||
@interface QXNobilityHeaderView()
|
||
@property (nonatomic,strong)QXSeatHeaderView *userAvatarView;
|
||
@property (nonatomic,strong)UILabel *userNameLabel;
|
||
|
||
|
||
/// 当前爵位
|
||
@property (nonatomic,strong)UIView *currentNobilityBgView;
|
||
@property (nonatomic,strong)UIImageView *currentNobilityBgImageView;
|
||
|
||
/// 有爵位
|
||
@property (nonatomic,strong)UILabel *currentNobilityLabel;
|
||
@property (nonatomic,strong)UIButton *buyBtn;
|
||
/// 无爵位
|
||
@property (nonatomic,strong)UIButton *openBtn;
|
||
|
||
@property (nonatomic,strong)UILabel *currentNobilityTimeLabel;
|
||
|
||
@property (nonatomic,strong)UIImageView *currenNobilityImageView;
|
||
|
||
@property (nonatomic,strong)UIImageView *compareImageView;
|
||
@end
|
||
@implementation QXNobilityHeaderView
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame
|
||
{
|
||
self = [super initWithFrame:frame];
|
||
if (self) {
|
||
[self initSubviews];
|
||
self.height = self.compareImageView.bottom+12;
|
||
}
|
||
return self;
|
||
}
|
||
-(void)initSubviews{
|
||
self.userAvatarView = [[QXSeatHeaderView alloc] initWithFrame:CGRectMake(16, 0, 40, 40)];
|
||
[self.userAvatarView setHeadIcon:QXGlobal.shareGlobal.loginModel.avatar dress:@""];
|
||
[self addSubview:self.userAvatarView];
|
||
|
||
self.userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.userAvatarView.right+10, self.userAvatarView.top, 300, 40)];
|
||
self.userNameLabel.text = [NSString stringWithFormat:@"%@的爵位",QXGlobal.shareGlobal.loginModel.nickname];
|
||
self.userNameLabel.textColor = RGB16(0xF5E9D1);
|
||
self.userNameLabel.font = [UIFont systemFontOfSize:12];
|
||
[self addSubview:self.userNameLabel];
|
||
|
||
self.currentNobilityBgView = [[UIView alloc] initWithFrame:CGRectMake(16, self.userAvatarView.bottom+10, SCREEN_WIDTH-16*2, ScaleWidth(91))];
|
||
[self addSubview:self.currentNobilityBgView];
|
||
|
||
self.currentNobilityBgImageView = [[UIImageView alloc] initWithFrame:self.currentNobilityBgView.bounds];
|
||
self.currentNobilityBgImageView.image = [UIImage imageNamed:@"nobility_current_bg"];
|
||
[self.currentNobilityBgView addSubview:self.currentNobilityBgImageView];
|
||
|
||
self.currentNobilityLabel = [[UILabel alloc] init];
|
||
self.currentNobilityLabel.textColor = RGB16(0xA292FF);
|
||
self.currentNobilityLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:34];
|
||
[self.currentNobilityBgView addSubview:self.currentNobilityLabel];
|
||
[self.currentNobilityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(13);
|
||
make.top.mas_equalTo(6);
|
||
}];
|
||
|
||
self.buyBtn = [[UIButton alloc] init];
|
||
[self.buyBtn setImage:[UIImage imageNamed:@"nobility_buy"] forState:(UIControlStateNormal)];
|
||
[self.buyBtn addTarget:self action:@selector(buyAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||
[self.currentNobilityBgView addSubview:self.buyBtn];
|
||
[self.buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.currentNobilityLabel.mas_right).offset(12);
|
||
make.width.mas_equalTo(ScaleWidth(60));
|
||
make.height.mas_equalTo(ScaleWidth(22));
|
||
make.centerY.equalTo(self.currentNobilityLabel);
|
||
}];
|
||
|
||
self.currentNobilityTimeLabel = [[UILabel alloc] init];
|
||
self.currentNobilityTimeLabel.textColor = RGB16(0xF5E9D1);
|
||
self.currentNobilityTimeLabel.font = [UIFont systemFontOfSize:12];
|
||
[self.currentNobilityBgView addSubview:self.currentNobilityTimeLabel];
|
||
[self.currentNobilityTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.currentNobilityLabel);
|
||
make.bottom.equalTo(self.currentNobilityBgView).offset(-12);
|
||
}];
|
||
|
||
self.openBtn = [[UIButton alloc] init];
|
||
[self.openBtn setImage:[UIImage imageNamed:@"nobility_open"] forState:(UIControlStateNormal)];
|
||
[self.openBtn addTarget:self action:@selector(openAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||
[self.currentNobilityBgView addSubview:self.openBtn];
|
||
[self.openBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.currentNobilityBgView).offset(12);
|
||
make.width.mas_equalTo(ScaleWidth(113));
|
||
make.height.mas_equalTo(ScaleWidth(36));
|
||
make.top.mas_equalTo(17);
|
||
}];
|
||
self.currenNobilityImageView = [[UIImageView alloc] init];
|
||
[self addSubview:self.currenNobilityImageView];
|
||
[self.currenNobilityImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.mas_equalTo(-28);
|
||
make.height.width.mas_equalTo(ScaleWidth(104));
|
||
make.bottom.mas_equalTo(-34);
|
||
}];
|
||
|
||
self.compareImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nobility_compare_top"]];
|
||
self.compareImageView.frame = CGRectMake(41, self.currentNobilityBgView.bottom+13, SCREEN_WIDTH-41*2, ScaleWidth(54));
|
||
self.compareImageView.contentMode = UIViewContentModeScaleToFill;
|
||
[self addSubview:self.compareImageView];
|
||
|
||
// self.currentNobilityLabel.text = @"骑士";
|
||
// self.currentNobilityTimeLabel.text = @"有效期剩余:15天22小时";
|
||
[self setHaveNobility:NO];
|
||
}
|
||
|
||
-(void)setModel:(QXNobilityModel *)model{
|
||
_model = model;
|
||
[self.userAvatarView setHeadIcon:model.user_info.avatar dress:@""];
|
||
self.userNameLabel.text = [NSString stringWithFormat:@"%@的爵位",model.user_info.nickname];
|
||
if (model.nobility_info.status.intValue == 0) {
|
||
[self setHaveNobility:NO];
|
||
}else{
|
||
[self setHaveNobility:YES];
|
||
}
|
||
}
|
||
-(void)setHaveNobility:(BOOL)have{
|
||
self.openBtn.hidden = have;
|
||
self.buyBtn.hidden = !have;
|
||
self.currentNobilityLabel.hidden = !have;
|
||
self.currentNobilityLabel.text = self.model.nobility_info.name;
|
||
self.currentNobilityTimeLabel.text = have?[NSString stringWithFormat:@"截止时间:%@",self.model.nobility_info.end_time]:@"您尚未开通任何爵位";
|
||
}
|
||
|
||
-(void)openAction{
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(didOpenNobility)]) {
|
||
[self.delegate didOpenNobility];
|
||
}
|
||
}
|
||
-(void)buyAction{
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(didRenewNobility)]) {
|
||
[self.delegate didRenewNobility];
|
||
}
|
||
}
|
||
@end
|