Files
featherVoice/QXLive/Mine(音域)/Controller/设置/QXSettingViewController.m
2025-08-08 10:49:36 +08:00

206 lines
7.8 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// QXSettingViewController.m
// QXLive
//
// Created by 启星 on 2025/5/9.
//
#import "QXSettingViewController.h"
#import "QXSettingCell.h"
#import "QXMineNetwork.h"
#import "QXAlertView.h"
#import "QXTimer.h"
static NSInteger maxClickCount = 6;
@interface QXSettingViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSDictionary *cellTypeDict;
@property (nonatomic,strong)NSDictionary *valueDict;
@property (nonatomic,strong)NSDictionary *controllerDict;
@property (nonatomic,strong)QXAlertView *alertView;
@property (nonatomic,strong)QXTimer *timer;
@property (nonatomic,assign)NSInteger clickCount;
@end
@implementation QXSettingViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)setNavgationItems{
[super setNavgationItems];
self.navigationItem.title = QXText(@"设置");
}
-(void)initSubViews{
NSArray *section1 = @[
// QXText(@"消息通知"),
QXText(@"未成年人模式"),
QXText(@"黑名单"),
QXText(@"设置密码"),
QXText(@"手机绑定"),
QXText(@"关于我们"),
QXText(@"版本号")
];
NSArray *section2 = @[
QXText(@"切换账号"),
QXText(@"实名认证"),
QXText(@"账号注销"),
QXText(@"退出登录"),
];
self.cellTypeDict = @{
// QXText(@"消息通知"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"未成年人模式"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"黑名单"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"设置密码"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"手机绑定"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"版本号"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyDetail],
QXText(@"切换账号"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"实名认证"):[NSNumber numberWithInteger:QXSettingCellTypeNormal],
QXText(@"账号注销"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow],
QXText(@"退出登录"):[NSNumber numberWithInteger:QXSettingCellTypeOnlyArrow]
};
self.controllerDict = @{
QXText(@"消息通知"):@"QXNoticeSwitchViewController",
QXText(@"未成年人模式"):@"QXChirldModeViewController",
QXText(@"黑名单"):@"QXBlackListlViewController",
QXText(@"设置密码"):@"QXSetPwdViewController",
QXText(@"手机绑定"):@"QXBindMobileViewController",
QXText(@"版本号"):@"",
QXText(@"切换账号"):@"QXChangeAccountViewController",
QXText(@"实名认证"):[QXGlobal shareGlobal].isRealName?@"QXRealNameFinishedViewController":@"QXRealNameViewController",
QXText(@"账号注销"):@"",
QXText(@"退出登录"):@"",
QXText(@"关于我们"):@"QXAboutViewController"
};
NSString*appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
self.valueDict = @{
// QXText(@"消息通知"):@"",
QXText(@"未成年人模式"):@"",
QXText(@"黑名单"):@"",
QXText(@"设置密码"):@"",
QXText(@"手机绑定"):@"",
QXText(@"版本号"):appVersion,
QXText(@"切换账号"):@"",
QXText(@"实名认证"):@"",
QXText(@"账号注销"):@"",
QXText(@"退出登录"):@""
};
[self.dataArray addObject:section1];
[self.dataArray addObject:section2];
[self.view addSubview:self.tableView];
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSArray *arr = self.dataArray[section];
return arr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXSettingCell *cell = [QXSettingCell cellWithTableView:tableView];
NSArray *arr = self.dataArray[indexPath.section];
NSString *text = arr[indexPath.row];
NSString *value = self.valueDict[text];
cell.titleLabel.text = text;
cell.detailLabel.text = value;
cell.cellType = [self.cellTypeDict[text] integerValue];
cell.needLine = (indexPath.row>=0) && (indexPath.row < arr.count-1);
return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return [UIView new];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 12;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return [UIView new];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSArray *arr = self.dataArray[indexPath.section];
NSString *text = arr[indexPath.row];
if ([text isEqualToString:QXText(@"版本号")]) {
self.clickCount++;
if (self.clickCount>=maxClickCount) {
showToast(@"已获取充值权限");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kIsOpenRecharge];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}else{
self.clickCount = 0;
}
if ([text isEqualToString:QXText(@"账号注销")]) {
[[QXGlobal shareGlobal] showView:self.alertView controller:self popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
}];
return;
}
if ([text isEqualToString:QXText(@"退出登录")]) {
if (self.logOutBlock) {
self.logOutBlock(NO);
}
[self.navigationController popViewControllerAnimated:YES];
return;
}
NSString *controller = self.controllerDict[text];
if (controller.length == 0) {
return;
}
UIViewController *vc = [[NSClassFromString(controller) alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) style:(UITableViewStyleGrouped)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.rowHeight = 42;
}
return _tableView;
}
-(QXAlertView *)alertView{
if (!_alertView) {
_alertView = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(230))];
_alertView.title = @"您确定要注销账号吗?";
_alertView.message = @"注销后您当前的账户金币及钻石将无法找回\n30天内本账号将无法登录请谨慎操作";
MJWeakSelf
_alertView.commitBlock = ^{
[weakSelf.navigationController popViewControllerAnimated:YES];
if (weakSelf.logOutBlock) {
weakSelf.logOutBlock(YES);
}
};
}
return _alertView;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end