ChatSettingVC.m 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //
  2. // ChatSettingVC.m
  3. // BuguLive
  4. //
  5. // Created by Kylin on 2024/12/14.
  6. // Copyright © 2024 xfg. All rights reserved.
  7. //
  8. #import "ChatSettingVC.h"
  9. @interface ChatSettingVC ()
  10. @property (nonatomic,strong) UITextField * audioTF;
  11. @property (nonatomic,strong) UITextField * videooTF;
  12. @property (nonatomic,assign) int sysvideo_price;
  13. @property (nonatomic,assign) int sysAudio_price;
  14. @property (nonatomic,assign) int uservideo_price;
  15. @property (nonatomic,assign) int userAudio_price;
  16. @end
  17. @implementation ChatSettingVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"];
  21. UIImageView * navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationHeight)];
  22. navView.image = [UIImage imageNamed:@"mine_navbg"];
  23. navView.userInteractionEnabled = YES;
  24. [self.view addSubview:navView];
  25. UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  26. [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
  27. backBtn.frame = CGRectMake(10, StatusBarHeight, 44, 44);
  28. [backBtn addTarget:self action:@selector(backLastVC) forControlEvents:UIControlEventTouchUpInside];
  29. [navView addSubview:backBtn];
  30. UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
  31. titleLabel.centerX = SCREEN_WIDTH/2;
  32. titleLabel.centerY = backBtn.centerY;
  33. titleLabel.text = ASLocalizedString(@"隐私特权设置");
  34. titleLabel.textColor = UIColor.blackColor;
  35. titleLabel.font = [UIFont boldSystemFontOfSize:18];
  36. titleLabel.textAlignment = NSTextAlignmentCenter;
  37. [navView addSubview:titleLabel];
  38. [self setupBackBtnWithBlock:nil];
  39. UIView * baseView = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationHeight, kScreenW,113)];
  40. baseView.layer.cornerRadius = 10;
  41. baseView.layer.masksToBounds = YES;
  42. baseView.backgroundColor = UIColor.whiteColor;
  43. [self.view addSubview:baseView];
  44. UILabel * audioTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 100, 15)];
  45. audioTitleLabel.text = ASLocalizedString(@"语音聊天");
  46. audioTitleLabel.font = [UIFont systemFontOfSize:14];
  47. audioTitleLabel.textColor = UIColor.blackColor;
  48. [baseView addSubview:audioTitleLabel];
  49. _audioTF = [[UITextField alloc] initWithFrame:CGRectMake(audioTitleLabel.right, 0, baseView.width - audioTitleLabel.right - 15, 44)];
  50. self.audioTF.centerY = audioTitleLabel.centerY;
  51. self.audioTF.font = [UIFont systemFontOfSize:14];
  52. self.audioTF.keyboardType = UIKeyboardTypeNumberPad;
  53. [baseView addSubview:self.audioTF];
  54. UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(15, 43, baseView.width - 30, 1)];
  55. lineView.backgroundColor = [UIColor colorWithHex:0xEEEEEE];
  56. [baseView addSubview:lineView];
  57. UILabel * videoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 69, 100, 15)];
  58. videoTitleLabel.text = ASLocalizedString(@"视频聊天");
  59. videoTitleLabel.font = [UIFont systemFontOfSize:14];
  60. videoTitleLabel.textColor = UIColor.blackColor;
  61. [baseView addSubview:videoTitleLabel];
  62. _videooTF = [[UITextField alloc] initWithFrame:CGRectMake(videoTitleLabel.right, 0, baseView.width - videoTitleLabel.right - 15, 44)];
  63. self.videooTF.centerY = videoTitleLabel.centerY;
  64. self.videooTF.font = [UIFont systemFontOfSize:14];
  65. self.videooTF.keyboardType = UIKeyboardTypeNumberPad;
  66. [baseView addSubview:self.videooTF];
  67. UIView * lineView1 = [[UIView alloc] initWithFrame:CGRectMake(15, 97, baseView.width - 30, 1)];
  68. lineView1.backgroundColor = [UIColor colorWithHex:0xEEEEEE];
  69. [baseView addSubview:lineView1];
  70. UIButton * logoutBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  71. [logoutBtn setTitle:ASLocalizedString(@"保存") forState:UIControlStateNormal];
  72. [logoutBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  73. [logoutBtn addTarget:self action:@selector(loginOutAction) forControlEvents:UIControlEventTouchUpInside];
  74. logoutBtn.frame = CGRectMake(62, baseView.bottom + 188, SCREEN_WIDTH - 124, 45);
  75. [logoutBtn setBackgroundImage:[UIImage imageNamed:@"widthBtnBg"] forState:UIControlStateNormal];
  76. [self.view addSubview:logoutBtn];
  77. [self requestSetConfig];
  78. }
  79. - (void)loginOutAction {
  80. if (self.audioTF.text.intValue < self.sysAudio_price) {
  81. [SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),self.sysAudio_price,ASLocalizedString(@"钻/分")]];
  82. return;
  83. }
  84. if (self.videooTF.text.intValue < self.sysvideo_price) {
  85. [SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),self.sysvideo_price,ASLocalizedString(@"钻/分")]];
  86. return;
  87. }
  88. NSMutableDictionary *parmDict = [[NSMutableDictionary alloc] init];
  89. [parmDict setObject:@"user" forKey:@"ctl"];
  90. [parmDict setObject:@"chat_set" forKey:@"act"];
  91. [parmDict setObject:self.audioTF.text forKey:@"voice_price"];
  92. [parmDict setObject:self.videooTF.text forKey:@"video_price"];
  93. [parmDict setObject:@"1" forKey:@"i_type"];
  94. [parmDict setObject:[BogoNetwork shareInstance].token forKey:@"token"];
  95. WeakSelf
  96. [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  97. if ([[responseJson valueForKeyPath:@"status"]integerValue] == 1) {
  98. [SVProgressHUD showInfoWithStatus:ASLocalizedString(@"成功")];
  99. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  100. [weakSelf backLastVC];
  101. });
  102. }
  103. } FailureBlock:^(NSError *error) {
  104. NSLog(@" = = = = = = = == %@",error);
  105. }];
  106. }
  107. - (void)requestSetConfig {
  108. NSMutableDictionary *parmDict = [[NSMutableDictionary alloc] init];
  109. [parmDict setObject:@"user" forKey:@"ctl"];
  110. [parmDict setObject:@"chat_set_info" forKey:@"act"];
  111. [parmDict setObject:@"1" forKey:@"i_type"];
  112. [parmDict setObject:[BogoNetwork shareInstance].token forKey:@"token"];
  113. WeakSelf
  114. [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  115. if ([[responseJson valueForKeyPath:@"status"]integerValue] == 1) {
  116. weakSelf.sysvideo_price = [responseJson[@"data"][@"sys"][@"video_price"] intValue];
  117. weakSelf.sysAudio_price = [responseJson[@"data"][@"sys"][@"voice_price"] intValue];
  118. weakSelf.uservideo_price = [responseJson[@"data"][@"user"][@"video_price"] intValue];
  119. weakSelf.userAudio_price = [responseJson[@"data"][@"user"][@"voice_price"] intValue];
  120. if (weakSelf.uservideo_price == 0) {
  121. weakSelf.videooTF.placeholder = [NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),weakSelf.sysvideo_price,ASLocalizedString(@"钻/分")];
  122. } else {
  123. weakSelf.videooTF.placeholder = [NSString stringWithFormat:@"%d%@",weakSelf.uservideo_price,ASLocalizedString(@"钻/分")];
  124. }
  125. if (weakSelf.userAudio_price == 0) {
  126. weakSelf.audioTF.placeholder = [NSString stringWithFormat:@"%@%d%@",ASLocalizedString(@"不低于"),weakSelf.sysAudio_price,ASLocalizedString(@"钻/分")];
  127. } else {
  128. weakSelf.audioTF.placeholder = [NSString stringWithFormat:@"%d%@",weakSelf.userAudio_price,ASLocalizedString(@"钻/分")];
  129. }
  130. }
  131. } FailureBlock:^(NSError *error) {
  132. NSLog(@" = = = = = = = == %@",error);
  133. }];
  134. }
  135. - (void)backLastVC {
  136. [self.navigationController popViewControllerAnimated:YES];
  137. }
  138. - (void)setupBackBtnWithBlock:(BackBlock)backBlock
  139. {
  140. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(onReturnBtnPress) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  141. }
  142. @end