| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- //
- // BogoSetViewController.m
- // BuguLive
- //
- // Created by 宋晨光 on 2021/9/26.
- // Copyright © 2021 xfg. All rights reserved.
- //
- #import "BogoSetViewController.h"
- #import "SetTableViewCell.h"
- #import "AccountSecurityViewController.h"
- #import "FollowerViewController.h"
- #import "LoginViewController.h"
- #import "LoginOutModel.h"
- #import "PushManageViewController.h"
- #import "RecommendedPersonViewController.h"
- #import "BogoLanguageAlertView.h"
- #import "BogoSetPriviteNobleViewController.h"
- #import "BogoSetAccountViewController.h"
- #import "ChatSettingVC.h"
- @interface BogoSetViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property(nonatomic, strong) UITableView *tableView;
- @property(nonatomic, strong) NSMutableArray *listArr;
- @property(nonatomic, strong) BogoLanguageAlertView *languageView;
- @end
- @implementation BogoSetViewController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- self.navigationController.navigationBar.hidden = YES;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.navigationItem.title = ASLocalizedString(@"系统设置");
-
- 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];
-
-
-
- [self setModel];
-
- [self.view addSubview:self.tableView];
-
-
- 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, self.tableView.bottom + 50, SCREEN_WIDTH - 124, 45);
- [logoutBtn setBackgroundImage:[UIImage imageNamed:@"widthBtnBg"] forState:UIControlStateNormal];
- [self.view addSubview:logoutBtn];
- }
-
- -(void)setModel{
- if ([[GlobalVariables sharedInstance].appModel.open_noble isEqualToString:@"1"]) {
- _listArr = [NSMutableArray arrayWithObjects:@[ASLocalizedString(@"账号与安全")],@[ASLocalizedString(@"黑名单管理"),ASLocalizedString(@"隐私特权设置"),ASLocalizedString(@"消息推送设置"),ASLocalizedString(@"聊天设置"),ASLocalizedString(@"切换语言")],@[ASLocalizedString(@"帮助与反馈"),ASLocalizedString(@"清理缓存"),ASLocalizedString(@"检查更新"),ASLocalizedString(@"关于我们")], nil];
-
- if (kIsCheckingVersion()) {
- [_listArr removeAllObjects];
-
- _listArr = [NSMutableArray arrayWithObjects:@[ASLocalizedString(@"账号与安全")],@[ASLocalizedString(@"黑名单管理"),ASLocalizedString(@"隐私特权设置"),ASLocalizedString(@"消息推送设置"),ASLocalizedString(@"聊天设置"),ASLocalizedString(@"切换语言")],@[ASLocalizedString(@"帮助与反馈"),ASLocalizedString(@"清理缓存"),ASLocalizedString(@"关于我们")], nil];
- }
-
- }else{
- _listArr = [NSMutableArray arrayWithObjects:@[ASLocalizedString(@"账号与安全")],@[ASLocalizedString(@"黑名单管理"),ASLocalizedString(@"消息推送设置"),ASLocalizedString(@"聊天设置"),ASLocalizedString(@"切换语言")],@[ASLocalizedString(@"帮助与反馈"),ASLocalizedString(@"清理缓存"),ASLocalizedString(@"检查更新"),ASLocalizedString(@"关于我们")], nil];
-
- if (kIsCheckingVersion()) {
- [_listArr removeAllObjects];
-
- _listArr = [NSMutableArray arrayWithObjects:@[ASLocalizedString(@"账号与安全")],@[ASLocalizedString(@"黑名单管理"),ASLocalizedString(@"消息推送设置"),ASLocalizedString(@"聊天设置"),ASLocalizedString(@"切换语言")],@[ASLocalizedString(@"帮助与反馈"),ASLocalizedString(@"清理缓存"),ASLocalizedString(@"关于我们")], nil];
- }
- }
- }
- - (void)setupBackBtnWithBlock:(BackBlock)backBlock
- {
-
- self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(onReturnBtnPress) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
- }
- #pragma mark - UITableView Datasource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 3;
- }
- #pragma mark -- 返回区头的高度
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return section == 0 ? 0 : 5;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 5)];
- headView.backgroundColor = kAppSpaceColor2;
- return headView;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- if([[[NSBundle mainBundle]bundleIdentifier] isEqualToString:@"com.zebo.zebolive"])
- {
- SetTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
-
- if([cell.setText.text isEqualToString:ASLocalizedString(@"切换语言")])
- {
- return kRealValue(0.01);
- }
- else
- {
-
- }
- }
-
- return kRealValue(44);
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- switch (section)
- {
- case 0:
- {
- return 1;
- }
- break;
- case 1:
- {
- if ([[GlobalVariables sharedInstance].appModel.open_noble isEqualToString:@"1"]) {
- return 5;
- }
- else
- return 4;
- }
- break;
- case 2:
- {
- if (kIsCheckingVersion()) {
- return 3;
- }
- return 4;
- }
- break;
- case 3:
- {
- return 1;
- }
- break;
-
- default:
- break;
- }
- return 0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- SetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SetTableViewCell" forIndexPath:indexPath];
-
- [cell configurationCellWithSection:indexPath.section row:indexPath.row distribution_module:self.BuguLive.appModel.distribution_module];
-
- if (indexPath.section == 3) {
- cell.setText.textColor = [UIColor colorWithHexString:@"#9152F8"];
- }
-
-
- cell.line.hidden = YES;
- if (indexPath.section == 0 || (indexPath.section == 1 && indexPath.row == 3) || (indexPath.section == 2 && indexPath.row == 2) || indexPath.section == 3) {
- cell.line.hidden = YES;
- }
- cell.loginBack.textColor = [UIColor colorWithHexString:@"#9152F8"];
-
- if([[[NSBundle mainBundle]bundleIdentifier] isEqualToString:@"com.zebo.zebolive"])
- {
- if([cell.setText.text isEqualToString:ASLocalizedString(@"切换语言")])
- {
- cell.hidden = YES;
- }
- else
- {
- cell.hidden = NO;
- }
- }
-
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSArray *sectionArr = self.listArr[indexPath.section];
- NSString *contentStr = sectionArr[indexPath.row];
-
- if ([contentStr isEqualToString:ASLocalizedString(@"账号与安全")]) {
- //账户安全点击事件
- BogoSetAccountViewController *acVC = [[BogoSetAccountViewController alloc]init];
- // acVC.userid = self.userID;
- [self.navigationController pushViewController:acVC animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"黑名单管理")]) {
- // 黑名单点击事件
- FollowerViewController *followVC = [[FollowerViewController alloc]init];
- followVC.type = @"3";
- followVC.user_id = self.userID;
- [self.navigationController pushViewController:followVC animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"隐私特权设置")]) {
- BogoSetPriviteNobleViewController *vc = [BogoSetPriviteNobleViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"消息推送设置")]) {
- // 推送管理点击事件
- PushManageViewController *pushManageVC = [[PushManageViewController alloc]init];
- pushManageVC.userId = self.userID;
- [self.navigationController pushViewController:pushManageVC animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"聊天设置")]) {
- //点击事件
- ChatSettingVC *pushManageVC = [[ChatSettingVC alloc]init];
- [self.navigationController pushViewController:pushManageVC animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"切换语言")]) {
- [self gotoLanguage];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"帮助与反馈")]) {
- // 帮助与反馈点击事件
- BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:self.BuguLive.appModel.h5_url.url_help_feedback isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES isShowCloseBtn:NO];
- tmpController.navTitleStr = ASLocalizedString(@"帮助与反馈");
- [self.navigationController pushViewController:tmpController animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"清理缓存")]) {
- // 帮助与反馈点击事件
- // SetTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- [[[SDWebImageManager sharedManager] imageCache] clearWithCacheType:SDImageCacheTypeAll completion:^{
- [self.tableView reloadSection:2 withRowAnimation:UITableViewRowAnimationFade];
- }];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"检查更新")]) {
- [self checkUpdate];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"关于我们")]) {
- // 关于我们
- BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:self.BuguLive.appModel.h5_url.url_about_we isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES isShowCloseBtn:NO];
- tmpController.navTitleStr = ASLocalizedString(@"关于我们");
- [self.navigationController pushViewController:tmpController animated:YES];
- return;
- }
- if ([contentStr isEqualToString:ASLocalizedString(@"退出登录")]) {
- [self loginOutAction];
- return;
- }
- }
- - (void)gotoLanguage {
-
-
- [self.languageView show:[AppDelegate sharedAppDelegate].topViewController.view.superview.superview];
-
- }
- -(void)checkUpdate{
- if (self.BuguLive.appModel.version.has_upgrade == 1)
- {
- self.BuguLive.ios_down_url = self.BuguLive.appModel.version.ios_down_url;
-
- // 强制升级:forced_upgrade ; 0:非强制升级,可取消; 1:强制升级
- if (self.BuguLive.appModel.version.forced_upgrade == 1)
- {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.BuguLive.ios_down_url]];
- }
- else
- {
- FWWeakify(self)
- [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"发现新版本,需要升级吗?")destructiveAction:^{
-
- FWStrongify(self)
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.BuguLive.ios_down_url]];
-
- } cancelAction:^{
-
- }];
- }
- }
- else
- {
- [FanweMessage alert:ASLocalizedString(@"当前已是最新版本!")];
- }
-
- if (!self.BuguLive.appModel.short_name || [self.BuguLive.appModel.short_name isEqualToString:@""])
- {
- self.BuguLive.appModel.short_name = ShortNameStr;
- }
- }
- -(void)loginOutAction{
- // 退出登录
-
- NSString * preferredLang = [[NSUserDefaults standardUserDefaults] objectForKey:KAppLanguage];
-
- [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]];
-
- //因为上面的方法会全部清除本APP的所有本地存储,所以这里预言再设置一遍
- [[LocalizationSystem sharedLocalSystem] setLanguage:preferredLang];
- NSLog(@" 5当前语言 = %@",preferredLang);
-
- [self setNetworing];
- }
- - (void)backLastVC {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark -- 退出登录
- - (void)setNetworing
- {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"login" forKey:@"ctl"];
- [parmDict setObject:@"loginout" forKey:@"act"];
- if (self.userID.length > 0)
- {
- [parmDict setObject:self.userID forKey:@"to_user_id"];
- }
-
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
- if ([responseJson toInt:@"status"] == 1)
- {
- FWStrongify(self)
- [self.tableView reloadData];
- // [self.navigationController popViewControllerAnimated:YES];
- [self.navigationController popViewControllerAnimated:NO];
- [[IMAPlatform sharedInstance] logout:^{
- [[AppDelegate sharedAppDelegate] enterLoginUI];
- } fail:^(int code, NSString *msg) {
- [[AppDelegate sharedAppDelegate] enterLoginUI];
- }];
-
- [AppViewModel loadInit];
- }else
- {
- [FanweMessage alertHUD:[responseJson toString:@"error"]];
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
- }
- -(BogoLanguageAlertView *)languageView{
- if (!_languageView) {
- _languageView = [[BogoLanguageAlertView alloc]initWithFrame:CGRectMake(kRealValue(20), 0, kScreenW - kRealValue(20 * 2), kRealValue(400))];
- }
- return _languageView;
- }
- -(UITableView *)tableView{
- if (!_tableView) {
-
- float height = 0;
- if ([[GlobalVariables sharedInstance].appModel.open_noble isEqualToString:@"1"]) {
- height = 44 * 10 + 20;
- if (kIsCheckingVersion()) {
- height = 44 * 9 + 20;
- }
- }else{
- height = 44 * 9 + 20;
- if (kIsCheckingVersion()) {
- height = 44 * 8 + 20;
- }
- }
-
- if (height > kScreenH - NavigationHeight - 100) {
- height = kScreenH - NavigationHeight - 100;
- }
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, NavigationHeight, kScreenW, height) style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.backgroundColor = UIColor.clearColor;
-
- [_tableView registerNib:[UINib nibWithNibName:@"SetTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"SetTableViewCell"];
-
-
- _tableView.tableFooterView = [UIView new];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
- }
- return _tableView;
- }
- @end
|