You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
316 lines
13 KiB
316 lines
13 KiB
1 year ago
|
//
|
||
|
// MoreViewController.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by ecell on 2023/6/21.
|
||
|
// Copyright © 2023 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "MoreViewController.h"
|
||
|
#import "WatchHomeViewController.h"
|
||
|
#import "MyTableViewHeaderView.h"
|
||
|
#import "MyTableViewCell.h"
|
||
|
#import "DPClearCacheTool.h"
|
||
|
#import "MessageViewController.h"
|
||
|
#import "AppDelegate.h"
|
||
|
#import "UIViewExt.h"
|
||
|
|
||
|
@interface MoreViewController ()<UITableViewDelegate,UITableViewDataSource>
|
||
|
|
||
|
@property (strong, nonatomic)NSMutableArray * iconImageArr;
|
||
|
|
||
|
@property (nonatomic ,strong) UITableView *moreTableView;
|
||
|
|
||
|
@property (nonatomic ,strong) MyTableViewHeaderView *headerView;
|
||
|
|
||
|
|
||
|
@property (nonatomic ,strong) NSNumber *messageCount;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation MoreViewController
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
|
||
|
self.zx_navTitle = @"我的";
|
||
|
self.zx_navBarBackgroundColor = KKClearColor;
|
||
|
[self zx_setRightBtnWithImg:ImageName_(@"icon_exit") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
|
||
|
// [UICommon pusXibViewController:@"EditMeViewController"];
|
||
|
[self signOutClick];
|
||
|
}];
|
||
|
|
||
|
self.zx_navBarBackgroundColor = KKClearColor;
|
||
|
self.view.backgroundColor = RGB(233, 247, 255);
|
||
|
UIImageView *topImg = [UIImageView new];
|
||
|
topImg.image = ImageName_(@"comm_top_img");
|
||
|
topImg.frame = CGRectMake(0, 0, ScreenWidth, topImg.image.size.height);
|
||
|
[self.view addSubview:topImg];
|
||
|
|
||
|
self.myDataSource = [[NSMutableArray alloc] initWithObjects:@"消息中心",@"系统设置",@"关于我们",@"常见问题",@"清除缓存",@"意见反馈", nil];
|
||
|
self.iconImageArr = [[NSMutableArray alloc] initWithObjects:@"icon_message_center_my",@"icon_settings",@"icon_aboutus",@"icon_question",@"icon_cleanup",@"icon_feedback", nil];
|
||
|
|
||
|
[self.view addSubview:self.moreTableView];
|
||
|
|
||
|
|
||
|
|
||
|
WEAKSELF
|
||
|
[[NSNotificationCenter defaultCenter] addObserverForName:@"HAVE_NEW_MESSAGE" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
|
||
|
//[weakSelf showNewMsgMark];
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (UITableView *)moreTableView
|
||
|
{
|
||
|
if (!_moreTableView)
|
||
|
{
|
||
|
_moreTableView = [[UITableView alloc] init];
|
||
|
if (@available(iOS 13.0, *)) {
|
||
|
_moreTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, iPhoneX_NavHeight, ScreenWidth, ScreenHeight-iPhoneX_NavHeight-TabBarHeight) style:UITableViewStyleInsetGrouped];
|
||
|
} else {
|
||
|
// Fallback on earlier versions
|
||
|
}
|
||
|
_moreTableView.delegate = self;
|
||
|
_moreTableView.dataSource = self;
|
||
|
//_moreTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
|
_moreTableView.backgroundColor = KKClearColor;
|
||
|
_moreTableView.tableHeaderView = self.headerView;
|
||
|
// _moreTableView.tableHeaderView.height = 255;
|
||
|
_moreTableView.tableHeaderView.height = 120;
|
||
|
[_moreTableView registerClass:MyTableViewCell.class forCellReuseIdentifier:NSStringFromClass(MyTableViewCell.class)];
|
||
|
}
|
||
|
return _moreTableView;
|
||
|
}
|
||
|
|
||
|
- (MyTableViewHeaderView *)headerView
|
||
|
{
|
||
|
if (!_headerView)
|
||
|
{
|
||
|
_headerView = [[MyTableViewHeaderView alloc] init];
|
||
|
// _headerView.frame = CGRectMake(0, 0, ScreenWidth, 255);
|
||
|
_headerView.frame = CGRectMake(0, 0, ScreenWidth, 120);
|
||
|
[_headerView seCellModel];
|
||
|
}
|
||
|
return _headerView;
|
||
|
}
|
||
|
|
||
|
-(void)viewWillAppear:(BOOL)animated
|
||
|
{
|
||
|
[super viewWillAppear:YES];
|
||
|
WEAKSELF
|
||
|
[cUser getMsgUnreadCount:@"message" Success:^(id responseObject) {
|
||
|
// if ([responseObject[@"code"] intValue] == 0 && [responseObject[@"count"] intValue] > 0) {
|
||
|
//
|
||
|
// weakSelf.messageCount = responseObject[@"count"];
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// [weakSelf setUnreadCount:0];
|
||
|
// }
|
||
|
weakSelf.messageCount = responseObject[@"count"];
|
||
|
[weakSelf.moreTableView reloadData];
|
||
|
|
||
|
} failure:^{
|
||
|
}];
|
||
|
[self.headerView seCellModel];
|
||
|
}
|
||
|
|
||
|
|
||
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||
|
return self.myDataSource.count;
|
||
|
}
|
||
|
|
||
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
|
||
|
return 55;
|
||
|
}
|
||
|
|
||
|
//- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||
|
// return [UIView new];
|
||
|
//}
|
||
|
//
|
||
|
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
|
// if (section == 0) {
|
||
|
// return 10;
|
||
|
// }
|
||
|
// return 10;
|
||
|
//}
|
||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||
|
{
|
||
|
|
||
|
MyTableViewCell *cell = [MyTableViewCell cellWithTableView:tableView indexPath:indexPath];
|
||
|
cell.imageName = self.iconImageArr[indexPath.row];
|
||
|
cell.titleName = self.myDataSource[indexPath.row];
|
||
|
cell.messageCount = self.messageCount;
|
||
|
|
||
|
return cell;
|
||
|
}
|
||
|
|
||
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||
|
{
|
||
|
WEAKSELF
|
||
|
NSString *title = self.myDataSource[indexPath.row]; if ([title isEqualToString:@"消息中心"])
|
||
|
{
|
||
|
MessageViewController *vc = [MessageViewController new];
|
||
|
vc.title = @"消息中心";
|
||
|
vc.hidesBottomBarWhenPushed = YES;
|
||
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"意见反馈"])
|
||
|
{
|
||
|
NSString *string = [NSString stringWithFormat:@"mailto://support@ecellsz.com ?subject=%@意见反馈",APPName];
|
||
|
string = [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||
|
NSURL *emailURL = [NSURL URLWithString:string];
|
||
|
[[UIApplication sharedApplication] openURL:emailURL options:[NSDictionary new] completionHandler:nil];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"清除缓存"])
|
||
|
{
|
||
|
//清除缓存
|
||
|
WEAKSELF
|
||
|
LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:@"确定清除缓存吗?" style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) {
|
||
|
[DPClearCacheTool clearCaches];
|
||
|
[weakSelf.moreTableView reloadData];
|
||
|
} cancelHandler:nil destructiveHandler:nil];
|
||
|
[alertView showAnimated:YES completionHandler:nil];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"关于我们"])
|
||
|
{
|
||
|
[UICommon pusXibViewController:@"AboutViewController"];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"修改密码"])
|
||
|
{
|
||
|
[weakSelf performSegueWithIdentifier:@"goChangePasswordVC" sender:nil];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"常见问题"])
|
||
|
{
|
||
|
[UICommon pusXibViewController:@"CommProViewController"];
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||
|
if (section == 0) {
|
||
|
return 130;
|
||
|
}
|
||
|
return 0.01;
|
||
|
}
|
||
|
|
||
|
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||
|
if (section == 0)
|
||
|
{
|
||
|
// UIButton *btn = [UICommon ui_buttonSimple:CGRectMake(0, 50, SWIDTH-40, 50) font:FontBold_(18) normalColor:KKWhiteColorColor normalText:@"退出登录" click:^(id x) {
|
||
|
// [self signOutClick];
|
||
|
// }];
|
||
|
// [btn setBackgroundColor:mainColor];
|
||
|
// btn.layer.cornerRadius = 25;
|
||
|
// btn.layer.masksToBounds = YES;
|
||
|
// [view addSubview:btn];
|
||
|
|
||
|
UIButton *btn2 = [UICommon ui_buttonSimple:CGRectMake(0, 50,SWIDTH-40, 50) font:FontBold_(18) normalColor:KKWhiteColorColor normalText:@"注销用户(谨慎)" click:^(id x) {
|
||
|
[self unregister];
|
||
|
}];
|
||
|
[btn2 setBackgroundColor:mainColor];
|
||
|
btn2.layer.cornerRadius = 25;
|
||
|
// btn2.layer.borderColor = mainColor.CGColor;
|
||
|
// btn2.layer.borderWidth = 1;
|
||
|
btn2.layer.masksToBounds = YES;
|
||
|
[view addSubview:btn2];
|
||
|
|
||
|
}
|
||
|
return view;
|
||
|
}
|
||
|
|
||
|
- (void)signOutClick
|
||
|
{
|
||
|
|
||
|
UIAlertController *sheet = [myHelper getAlertWithTitle:@"是否退出当前账号?"
|
||
|
actionTitles:@[@"确定"]
|
||
|
style:UIAlertControllerStyleAlert
|
||
|
block:^(UIAlertAction *action)
|
||
|
{
|
||
|
if ([action.title isEqualToString:@"确定"]) {
|
||
|
|
||
|
AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
||
|
UITabBarController *tabBarVC = (UITabBarController*)appDelegate.window.rootViewController;
|
||
|
UINavigationController *navVC = (UINavigationController*)tabBarVC.viewControllers.firstObject;
|
||
|
|
||
|
for (UIViewController *vc in navVC.viewControllers)
|
||
|
{
|
||
|
if([vc isKindOfClass:[WatchHomeViewController class]])
|
||
|
{
|
||
|
WatchHomeViewController *tempVC = (WatchHomeViewController*)vc;
|
||
|
tempVC.closeFocusTips = NO;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
[User logoutWithSuccess:^(id responseObject)
|
||
|
{
|
||
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"outLogin"
|
||
|
object:nil];
|
||
|
[User setCurrentUser:nil];
|
||
|
//退出登录,清除每天第一次登陆的记录
|
||
|
[UserDefaults removeObjectForKey:FirstEveryDayKey];
|
||
|
|
||
|
} failure:^(id faiObject) {
|
||
|
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
}];
|
||
|
[self presentViewController:sheet animated:YES completion:nil];
|
||
|
}
|
||
|
|
||
|
|
||
|
- (void)unregister
|
||
|
{
|
||
|
UIAlertController *sheet = [myHelper getAlertWithTitle:@"警告:注销用户信息将被清空无法恢复,请确认是否注销!"
|
||
|
actionTitles:@[@"确定"]
|
||
|
style:UIAlertControllerStyleAlert
|
||
|
block:^(UIAlertAction *action)
|
||
|
{
|
||
|
if ([action.title isEqualToString:@"确定"]) {
|
||
|
|
||
|
AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
||
|
UITabBarController *tabBarVC = (UITabBarController*)appDelegate.window.rootViewController;
|
||
|
UINavigationController *navVC = (UINavigationController*)tabBarVC.viewControllers.firstObject;
|
||
|
|
||
|
for (UIViewController *vc in navVC.viewControllers)
|
||
|
{
|
||
|
if([vc isKindOfClass:[WatchHomeViewController class]])
|
||
|
{
|
||
|
WatchHomeViewController *tempVC = (WatchHomeViewController*)vc;
|
||
|
tempVC.closeFocusTips = NO;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[User unregisterWithSuccess:^(id responseObject)
|
||
|
{
|
||
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"outLogin" object:nil];
|
||
|
[User setCurrentUser:nil];
|
||
|
[UserDefaults removeObjectForKey:FirstEveryDayKey];
|
||
|
|
||
|
} failure:^(id faiObject) {
|
||
|
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
}];
|
||
|
[self presentViewController:sheet animated:YES completion:nil];
|
||
|
}
|
||
|
|
||
|
|
||
|
/*
|
||
|
#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
|