// // ChatSettingVC.m // BuguLive // // Created by Kylin on 2024/12/14. // Copyright © 2024 xfg. All rights reserved. // #import "ChatSettingVC.h" @interface ChatSettingVC () @property (nonatomic,strong) UITextField * audioTF; @property (nonatomic,strong) UITextField * videooTF; @property (nonatomic,assign) int sysvideo_price; @property (nonatomic,assign) int sysAudio_price; @property (nonatomic,assign) int uservideo_price; @property (nonatomic,assign) int userAudio_price; @end @implementation ChatSettingVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"]; UIImageView * navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationHeight)]; navView.image = [UIImage imageNamed:@"mine_navbg"]; navView.userInteractionEnabled = YES; [self.view addSubview:navView]; UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal]; backBtn.frame = CGRectMake(10, StatusBarHeight, 44, 44); [backBtn addTarget:self action:@selector(backLastVC) forControlEvents:UIControlEventTouchUpInside]; [navView addSubview:backBtn]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)]; titleLabel.centerX = SCREEN_WIDTH/2; titleLabel.centerY = backBtn.centerY; titleLabel.text = ASLocalizedString(@"隐私特权设置"); titleLabel.textColor = UIColor.blackColor; titleLabel.font = [UIFont boldSystemFontOfSize:18]; titleLabel.textAlignment = NSTextAlignmentCenter; [navView addSubview:titleLabel]; [self setupBackBtnWithBlock:nil]; UIView * baseView = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationHeight, kScreenW,113)]; baseView.layer.cornerRadius = 10; baseView.layer.masksToBounds = YES; baseView.backgroundColor = UIColor.whiteColor; [self.view addSubview:baseView]; UILabel * audioTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 100, 15)]; audioTitleLabel.text = ASLocalizedString(@"语音聊天"); audioTitleLabel.font = [UIFont systemFontOfSize:14]; audioTitleLabel.textColor = UIColor.blackColor; [baseView addSubview:audioTitleLabel]; _audioTF = [[UITextField alloc] initWithFrame:CGRectMake(audioTitleLabel.right, 0, baseView.width - audioTitleLabel.right - 15, 44)]; self.audioTF.centerY = audioTitleLabel.centerY; self.audioTF.font = [UIFont systemFontOfSize:14]; self.audioTF.keyboardType = UIKeyboardTypeNumberPad; [baseView addSubview:self.audioTF]; UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(15, 43, baseView.width - 30, 1)]; lineView.backgroundColor = [UIColor colorWithHex:0xEEEEEE]; [baseView addSubview:lineView]; UILabel * videoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 69, 100, 15)]; videoTitleLabel.text = ASLocalizedString(@"视频聊天"); videoTitleLabel.font = [UIFont systemFontOfSize:14]; videoTitleLabel.textColor = UIColor.blackColor; [baseView addSubview:videoTitleLabel]; _videooTF = [[UITextField alloc] initWithFrame:CGRectMake(videoTitleLabel.right, 0, baseView.width - videoTitleLabel.right - 15, 44)]; self.videooTF.centerY = videoTitleLabel.centerY; self.videooTF.font = [UIFont systemFontOfSize:14]; self.videooTF.keyboardType = UIKeyboardTypeNumberPad; [baseView addSubview:self.videooTF]; UIView * lineView1 = [[UIView alloc] initWithFrame:CGRectMake(15, 97, baseView.width - 30, 1)]; lineView1.backgroundColor = [UIColor colorWithHex:0xEEEEEE]; [baseView addSubview:lineView1]; UIButton * logoutBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [logoutBtn setTitle:ASLocalizedString(@"保存") forState:UIControlStateNormal]; [logoutBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; [logoutBtn addTarget:self action:@selector(loginOutAction) forControlEvents:UIControlEventTouchUpInside]; logoutBtn.frame = CGRectMake(62, baseView.bottom + 188, SCREEN_WIDTH - 124, 45); [logoutBtn setBackgroundImage:[UIImage imageNamed:@"widthBtnBg"] forState:UIControlStateNormal]; [self.view addSubview:logoutBtn]; [self requestSetConfig]; } - (void)loginOutAction { if (self.audioTF.text.intValue < self.sysAudio_price) { [SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),self.sysAudio_price,ASLocalizedString(@"钻/分")]]; return; } if (self.videooTF.text.intValue < self.sysvideo_price) { [SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),self.sysvideo_price,ASLocalizedString(@"钻/分")]]; return; } NSMutableDictionary *parmDict = [[NSMutableDictionary alloc] init]; [parmDict setObject:@"user" forKey:@"ctl"]; [parmDict setObject:@"chat_set" forKey:@"act"]; [parmDict setObject:self.audioTF.text forKey:@"voice_price"]; [parmDict setObject:self.videooTF.text forKey:@"video_price"]; [parmDict setObject:@"1" forKey:@"i_type"]; [parmDict setObject:[BogoNetwork shareInstance].token forKey:@"token"]; WeakSelf [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) { if ([[responseJson valueForKeyPath:@"status"]integerValue] == 1) { [SVProgressHUD showInfoWithStatus:ASLocalizedString(@"成功")]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf backLastVC]; }); } } FailureBlock:^(NSError *error) { NSLog(@" = = = = = = = == %@",error); }]; } - (void)requestSetConfig { NSMutableDictionary *parmDict = [[NSMutableDictionary alloc] init]; [parmDict setObject:@"user" forKey:@"ctl"]; [parmDict setObject:@"chat_set_info" forKey:@"act"]; [parmDict setObject:@"1" forKey:@"i_type"]; [parmDict setObject:[BogoNetwork shareInstance].token forKey:@"token"]; WeakSelf [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) { if ([[responseJson valueForKeyPath:@"status"]integerValue] == 1) { weakSelf.sysvideo_price = [responseJson[@"data"][@"sys"][@"video_price"] intValue]; weakSelf.sysAudio_price = [responseJson[@"data"][@"sys"][@"voice_price"] intValue]; weakSelf.uservideo_price = [responseJson[@"data"][@"user"][@"video_price"] intValue]; weakSelf.userAudio_price = [responseJson[@"data"][@"user"][@"voice_price"] intValue]; if (weakSelf.uservideo_price == 0) { weakSelf.videooTF.placeholder = [NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),weakSelf.sysvideo_price,ASLocalizedString(@"钻/分")]; } else { weakSelf.videooTF.placeholder = [NSString stringWithFormat:@"%d%@",weakSelf.uservideo_price,ASLocalizedString(@"钻/分")]; } if (weakSelf.userAudio_price == 0) { weakSelf.audioTF.placeholder = [NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),weakSelf.sysAudio_price,ASLocalizedString(@"钻/分")]; } else { weakSelf.audioTF.placeholder = [NSString stringWithFormat:@"%d%@",weakSelf.userAudio_price,ASLocalizedString(@"钻/分")]; } } } FailureBlock:^(NSError *error) { NSLog(@" = = = = = = = == %@",error); }]; } - (void)backLastVC { [self.navigationController popViewControllerAnimated:YES]; } - (void)setupBackBtnWithBlock:(BackBlock)backBlock { self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(onReturnBtnPress) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"]; } @end