Files
featherVoice/QXLive/Mine(音域)/Controller/歌手认证/QXRoomSingerAuthViewController.m

154 lines
6.9 KiB
Mathematica
Raw Normal View History

2025-11-21 16:17:05 +08:00
//
// QXRoomSingerAuthViewController.m
// QXLive
//
// Created by on 2025/11/12.
//
#import "QXRoomSingerAuthViewController.h"
#import "QXAudioRecorderView.h"
2025-12-04 14:11:00 +08:00
#import "QXMineNetwork.h"
2025-11-21 16:17:05 +08:00
@interface QXRoomSingerAuthViewController ()<QXAudioRecorderViewDelegate>
@property (nonatomic,strong)UIView *contentView;
@property (nonatomic,strong)UIImageView *contentImageView;
@property (nonatomic,strong)UIImageView *myAuthImageView;
@property (nonatomic,strong)UIImageView *authStatusImageView;
@property (nonatomic,strong)UILabel *authStatusLabel;
@property (nonatomic,strong)QXAudioRecorderView *audioRecorderView;
@end
@implementation QXRoomSingerAuthViewController
- (void)viewDidLoad {
self.isNoChangeBgImage = YES;
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:RGB16(0xffffff)};
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:RGB16(0x000000)};
}
-(void)setNavgationItems{
[super setNavgationItems];
self.navigationTintColor = RGB16(0xffffff);
self.navigationItem.title = @"歌手认证";
2025-12-04 14:11:00 +08:00
UIButton*recordBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
[recordBtn setImage:[UIImage imageNamed:@"nobility_help_icon"] forState:(UIControlStateNormal)];
recordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
[recordBtn addTarget:self action:@selector(helpAction) forControlEvents:(UIControlEventTouchUpInside)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:recordBtn];
2025-11-21 16:17:05 +08:00
}
- (void)initSubViews{
[self updateBgImage:@"singer_auth_bg"];
self.contentView = [[UIView alloc] initWithFrame:CGRectMake(16, ScaleWidth(300), SCREEN_WIDTH-32, ScaleWidth(140))];
[self.view addSubview:self.contentView];
self.contentImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"singer_auth_center_bg"]];
self.contentImageView.contentMode = UIViewContentModeScaleToFill;
self.contentImageView.frame = self.contentView.bounds;
[self.contentView addSubview:self.contentImageView];
self.myAuthImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"singer_auth_title_image"]];
self.myAuthImageView.frame = CGRectMake((self.contentView.width-ScaleWidth(69))/2, ScaleWidth(10), ScaleWidth(69), ScaleWidth(24));
[self.contentView addSubview:self.myAuthImageView];
self.authStatusImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"singer_auth_status_no"]];
self.authStatusImageView.frame = CGRectMake((self.contentView.width-ScaleWidth(52))/2, self.myAuthImageView.bottom+ScaleWidth(22), ScaleWidth(52), ScaleWidth(52));
[self.contentView addSubview:self.authStatusImageView];
self.authStatusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.authStatusImageView.bottom+4, self.contentView.width, 17)];
self.authStatusLabel.text = @"暂未认证";
self.authStatusLabel.textColor = RGB16A(0x000000, 0.45);
self.authStatusLabel.font = [UIFont systemFontOfSize:12];
self.authStatusLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.authStatusLabel];
self.audioRecorderView = [[QXAudioRecorderView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-kSafeAreaBottom-246, SCREEN_WIDTH, 246+kSafeAreaBottom) maxDuration:300];
self.audioRecorderView.delegate = self;
self.audioRecorderView.hidden = YES;
[self.view addSubview:self.audioRecorderView];
2025-12-04 14:11:00 +08:00
[self conifgViews];
}
-(void)conifgViews{
2025-11-21 16:17:05 +08:00
if ([self.singer_status isEqualToString:@"-1"] || [self.singer_status isEqualToString:@"2"]) {
self.audioRecorderView.hidden = NO;
2025-12-04 14:11:00 +08:00
}else{
self.audioRecorderView.hidden = YES;
2025-11-21 16:17:05 +08:00
}
if ([self.singer_status isEqualToString:@"-1"]) {
self.authStatusLabel.text = @"暂未认证";
self.authStatusLabel.textColor = RGB16A(0x000000, 0.45);
}else if ([self.singer_status isEqualToString:@"0"]) {
self.authStatusLabel.text = @"待审核";
self.authStatusLabel.textColor = RGB16(0xFF8832);
}else if ([self.singer_status isEqualToString:@"1"]) {
self.authStatusLabel.text = @"已认证";
self.authStatusLabel.textColor = QXConfig.themeColor;
}else if ([self.singer_status isEqualToString:@"2"]) {
self.authStatusLabel.text = @"已拒绝";
self.authStatusLabel.textColor = RGB16(0xFF2424);
}
}
2025-12-04 14:11:00 +08:00
-(void)helpAction{
NSString *urlString = [NSString stringWithFormat:@"%@api/Page/page_show?id=%@",ServerUrl,@"33"];
QXBaseWebViewController *vc = [[QXBaseWebViewController alloc] init];
vc.urlStr = urlString;
[self.navigationController pushViewController:vc animated:YES];
}
2025-11-21 16:17:05 +08:00
#pragma mark - AudioRecorderViewDelegate
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didChangeState:(AudioRecorderState)state{
NSLog(@"录音状态改变: %ld", (long)state);
}
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didFinishRecordingWithMP3File:(NSURL *)mp3FileURL duration:(NSTimeInterval)duration{
NSLog(@"录音完成MP3文件: %@, 总时长: %.1f秒", mp3FileURL, duration);
//
NSData *audioData = [NSData dataWithContentsOfURL:mp3FileURL];
NSLog(@"MP3文件大小: %.2f KB", audioData.length / 1024.0);
}
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didFailWithError:(NSError *)error{
NSLog(@"录音失败: %@", error);
}
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didUpdateProgress:(NSTimeInterval)progress totalDuration:(NSTimeInterval)totalDuration{
//
}
2025-12-04 14:11:00 +08:00
-(void)didClickAuthWithFileUrl:(NSURL *)audioFileUrl{
NSData *data = [NSData dataWithContentsOfURL:audioFileUrl];
@weakify(self)
showLoadingInView(self.view);
[[QXCOSUploadManager shareManager] audioUploadFile:data withObjectKey:audioFileUrl.lastPathComponent complete:^(NSString * _Nonnull fileUrl, QXCOSUploadImageState state) {
@strongify(self);
dispatch_async(dispatch_get_main_queue(), ^{
hideLoadingInView(self.view);
if ([fileUrl isExist]) {
[QXMineNetwork singerAuthWithSong:fileUrl successBlock:^(NSDictionary * _Nonnull dict) {
showToast(@"上传成功");
self.singer_status = @"0";
[self conifgViews];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(@"上传失败");
}];
}else{
showToast(@"上传失败");
}
});
}];
}
2025-11-21 16:17:05 +08:00
@end