275 lines
11 KiB
Objective-C
275 lines
11 KiB
Objective-C
//
|
|
// QXRoomAuctionResultView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/6/30.
|
|
//
|
|
|
|
#import "QXRoomAuctionResultView.h"
|
|
@interface QXRoomAuctionResultView()
|
|
@property (nonatomic,assign)BOOL isSuccess;
|
|
@property (nonatomic,assign)BOOL isRealLove;
|
|
@property (nonatomic,strong)QXRoomAuctionFailView *failView;
|
|
@property (nonatomic,strong)QXRoomAuctionSuccessView *successView;
|
|
@end
|
|
|
|
@implementation QXRoomAuctionResultView
|
|
|
|
|
|
-(instancetype)initWithStyle:(BOOL)isSuccess isRealLove:(BOOL)isRealLove{
|
|
self = [super init];
|
|
if (self) {
|
|
self.isSuccess = isSuccess;
|
|
self.isRealLove = isRealLove;
|
|
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.4];
|
|
MJWeakSelf
|
|
if (self.isSuccess) {
|
|
self.successView = [[QXRoomAuctionSuccessView alloc] initWithIsRealLove:self.isRealLove];
|
|
self.successView.alpha = 0;
|
|
self.successView.closeActionBlock = ^{
|
|
[weakSelf hide];
|
|
};
|
|
[self addSubview:self.successView];
|
|
}else{
|
|
self.failView = [[QXRoomAuctionFailView alloc] init];
|
|
self.failView.closeActionBlock = ^{
|
|
[weakSelf hide];
|
|
};
|
|
[self addSubview:self.failView];
|
|
}
|
|
}
|
|
-(void)setResultWithUser:(QXRoomAuctionUser *)user getUser:(QXRoomAuctionUser *)getUser{
|
|
[self.successView.leftHeaderView sd_setImageWithURL:[NSURL URLWithString:user.avatar]];
|
|
self.successView.leftNameLabel.text = user.nickname;
|
|
[self.successView.rightHeaderView sd_setImageWithURL:[NSURL URLWithString:getUser.avatar]];
|
|
self.successView.rightNameLabel.text = getUser.nickname;
|
|
self.successView.resultLabel.text = [NSString stringWithFormat:@"%@签约成功",user.relation_name];
|
|
}
|
|
|
|
-(void)showInView:(UIView *)view{
|
|
[view addSubview:self];
|
|
if (self.isSuccess) {
|
|
// self.successView.resultLabel.text = @"";
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.successView.alpha = 1;
|
|
} completion:^(BOOL finished) {
|
|
[self.successView startTimer];
|
|
}];
|
|
}else{
|
|
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
self.failView.y = (SCREEN_HEIGHT-ScaleWidth(238))/2.0;
|
|
} completion:^(BOOL finished) {
|
|
[self.failView startTimer];
|
|
}];
|
|
}
|
|
}
|
|
|
|
-(void)hide{
|
|
if (self.isSuccess) {
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.successView.alpha = 0;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}else{
|
|
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
self.failView.y = SCREEN_HEIGHT;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation QXRoomAuctionFailView
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
CGFloat height = ScaleWidth(238);
|
|
self.frame = CGRectMake(15, -height, SCREEN_WIDTH-30, height);
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)initSubviews{
|
|
self.bgImageView = [[UIImageView alloc] initWithFrame:self.bounds];
|
|
self.bgImageView.image = [UIImage imageNamed:@"room_auction_result_bg"];
|
|
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
|
[self addSubview:self.bgImageView];
|
|
|
|
|
|
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 12, self.width-32, 24)];
|
|
self.titleLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
self.titleLabel.textColor = RGB16(0x333333);
|
|
self.titleLabel.text = @"竞拍结束";
|
|
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self addSubview:self.titleLabel];
|
|
|
|
|
|
self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.titleLabel.bottom+32, self.width-32, 24)];
|
|
self.messageLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
self.messageLabel.textColor = RGB16(0x333333);
|
|
self.messageLabel.text = @"本次竞拍已结束,期待您的下次参与";
|
|
self.messageLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self addSubview:self.messageLabel];
|
|
|
|
self.closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(80, self.height-24-42, self.width-160, 42)];
|
|
[self.closeBtn addRoundedCornersWithRadius:21];
|
|
self.closeBtn.backgroundColor = QXConfig.themeColor;
|
|
[self.closeBtn setTitle:QXText(@"知道了") forState:(UIControlStateNormal)];
|
|
[self.closeBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
self.closeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.closeBtn];
|
|
}
|
|
-(void)startTimer{
|
|
__block int timeCount = 3;
|
|
MJWeakSelf
|
|
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
|
|
timeCount--;
|
|
if (timeCount<=0) {
|
|
[weakSelf closeAction];
|
|
}else{
|
|
[self->_closeBtn setTitle:[NSString stringWithFormat:@"%@(%d)",QXText(@"知道了"),timeCount] forState:(UIControlStateNormal)];
|
|
}
|
|
}];
|
|
}
|
|
-(void)closeAction{
|
|
[self->_timer invalidate];
|
|
self->_timer = nil;
|
|
if (self.closeActionBlock) {
|
|
self.closeActionBlock();
|
|
}
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation QXRoomAuctionSuccessView
|
|
|
|
//- (instancetype)init
|
|
//{
|
|
// self = [super init];
|
|
// if (self) {
|
|
// self.frame = CGRectMake(0, ScaleWidth(219), 372, 306);
|
|
// [self initSubviews];
|
|
// }
|
|
// return self;
|
|
//}
|
|
|
|
- (instancetype)initWithIsRealLove:(BOOL)isRealLove
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
_isRealLove = isRealLove;
|
|
if (isRealLove) {
|
|
self.frame = CGRectMake(0, ScaleWidth(219), 372, 306);
|
|
}else{
|
|
self.frame = CGRectMake(0, ScaleWidth(219), SCREEN_WIDTH, 402);
|
|
}
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_auction_result_suc"]];
|
|
self.bgImageView.frame = self.bounds;
|
|
[self addSubview:self.bgImageView];
|
|
|
|
self.leftHeaderView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 90, 57, 57)];
|
|
self.leftHeaderView.contentMode = UIViewContentModeScaleAspectFill;
|
|
self.leftHeaderView.clipsToBounds = YES;
|
|
[self.leftHeaderView addRoundedCornersWithRadius:23.5];
|
|
[self addSubview:self.leftHeaderView];
|
|
|
|
self.leftNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.leftHeaderView.left, self.leftHeaderView.bottom+1, self.leftHeaderView.width, 16)];
|
|
self.leftNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
|
|
self.leftNameLabel.textColor = RGB16(0xFFE8B0);
|
|
self.leftNameLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self addSubview:self.leftNameLabel];
|
|
|
|
self.rightHeaderView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width-100-57, self.leftHeaderView.top, 57, 57)];
|
|
self.rightHeaderView.contentMode = UIViewContentModeScaleAspectFill;
|
|
self.rightHeaderView.clipsToBounds = YES;
|
|
[self.rightHeaderView addRoundedCornersWithRadius:23.5];
|
|
[self addSubview:self.rightHeaderView];
|
|
|
|
self.rightNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.rightHeaderView.left, self.rightHeaderView.bottom+1, self.rightHeaderView.width, 16)];
|
|
self.rightNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
|
|
self.rightNameLabel.textColor = RGB16(0xFFE8B0);
|
|
self.rightNameLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self addSubview:self.rightNameLabel];
|
|
|
|
self.resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.rightNameLabel.bottom+18, self.width, 17)];
|
|
self.resultLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:14];
|
|
self.resultLabel.textColor = UIColor.whiteColor;
|
|
// self.resultLabel.transform = CGAffineTransformMakeRotation(-6 * M_PI/180.0);
|
|
self.resultLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self addSubview:self.resultLabel];
|
|
if (self.isRealLove) {
|
|
self.bgImageView.frame = self.bounds;
|
|
self.bgImageView.image = [UIImage imageNamed:@"room_auction_result_suc_real"];
|
|
self.leftHeaderView.frame = CGRectMake(100, 90, 57, 57);
|
|
self.rightHeaderView.frame = CGRectMake(self.width-100-57, self.leftHeaderView.top, 57, 57);
|
|
self.rightNameLabel.frame = CGRectMake(self.rightHeaderView.left, self.rightHeaderView.bottom+1, self.rightHeaderView.width, 16);
|
|
self.leftNameLabel.frame = CGRectMake(self.leftHeaderView.left, self.leftHeaderView.bottom+1, self.leftHeaderView.width, 16);
|
|
self.rightNameLabel.textColor = RGB16(0xFFE8B0);
|
|
self.leftNameLabel.textColor = RGB16(0xFFE8B0);
|
|
self.rightNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
|
|
self.leftNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
|
|
self.rightNameLabel.textColor = RGB16(0xFFE8B0);
|
|
self.resultLabel.frame = CGRectMake(0, self.rightNameLabel.bottom+18, self.width, 17);
|
|
self.resultLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:14];
|
|
self.resultLabel.textColor = UIColor.whiteColor;
|
|
[self.rightHeaderView addRoundedCornersWithRadius:23.5];
|
|
[self.leftHeaderView addRoundedCornersWithRadius:23.5];
|
|
}else{
|
|
self.bgImageView.image = [UIImage imageNamed:@"room_auction_result_suc"];
|
|
self.bgImageView.frame = CGRectMake((self.width-302)/2, 0, 302, self.height);
|
|
self.leftHeaderView.frame = CGRectMake(self.width/2-68, self.height-73-68, 68, 68);
|
|
self.rightHeaderView.frame = CGRectMake(self.leftHeaderView.right, self.leftHeaderView.top, 68,68);
|
|
self.rightNameLabel.frame = CGRectMake(self.rightHeaderView.left, self.rightHeaderView.bottom+1, self.rightHeaderView.width, 21);
|
|
self.leftNameLabel.frame = CGRectMake(self.leftHeaderView.left, self.leftHeaderView.bottom+1, self.leftHeaderView.width, 21);
|
|
self.rightNameLabel.textColor = RGB16(0xFE435B);
|
|
self.leftNameLabel.textColor = RGB16(0xFE435B);
|
|
self.rightNameLabel.font = [UIFont systemFontOfSize:14];
|
|
self.leftNameLabel.font = [UIFont systemFontOfSize:14];
|
|
self.resultLabel.frame = CGRectMake(0, 19, self.width, 42);
|
|
self.resultLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:32];
|
|
self.resultLabel.textColor = RGB16(0xFFA4C8);
|
|
[self.rightHeaderView addRoundedCornersWithRadius:34];
|
|
[self.leftHeaderView addRoundedCornersWithRadius:34];
|
|
}
|
|
}
|
|
-(void)startTimer{
|
|
__block int timeCount = 3;
|
|
MJWeakSelf
|
|
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
|
|
timeCount--;
|
|
if (timeCount<=0) {
|
|
[weakSelf closeAction];
|
|
}
|
|
}];
|
|
}
|
|
-(void)closeAction{
|
|
[self->_timer invalidate];
|
|
self->_timer = nil;
|
|
if (self.closeActionBlock) {
|
|
self.closeActionBlock();
|
|
}
|
|
}
|
|
@end
|