| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- //
- // SetupViewController.m
- // jitao
- //
- // Created by 罗云飞 on 2017/12/7.
- // Copyright © 2017年 罗云飞. All rights reserved.
- //
- #import "SetupViewController.h"
- #import "CategoryCell.h"
- #import "ZFileManagerHelper.h"
- #import "FeedbackViewController.h"//意见反馈
- #import "AboutViewController.h"//关于我们
- #import "ServiceagreementViewController.h"//服务协议
- #import "UserHelper.h"
- #import "HuanXinHelper.h"
- #import "AgreementViewController.h"
- #import "NewModifyPasswordViewController.h"
- #import "NewKeFuViewController.h"
- #import "SetUpCell.h"
- @interface SetupViewController ()<UITableViewDelegate,UITableViewDataSource>{
- UITableView *newtableView;
- NSMutableArray *dataArray;
- NSString *cacheSize;
- }
- @end
- @implementation SetupViewController
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- cacheSize = [ZFileManagerHelper getCacheSize];
- [newtableView reloadData];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavTitle:@"设置"];
- [self dataInitialization];
- [self loadsView];
- // Do any additional setup after loading the view.
- }
- #pragma mark - 数据初始化
- - (void)dataInitialization{
- cacheSize = @"0.00K";
- dataArray = NewMutableArrayInit;
- for (int i=0; i<4; i++) {
- NSDictionary *dataDic = [NSDictionary dictionary];
- switch (i) {
- case 0:
- dataDic = @{@"nameKey":@"修改密码",@"imageKey":@"图层 234",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- case 1:
- dataDic = @{@"nameKey":@"清除缓存",@"imageKey":@"图层 235",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- case 2:
- dataDic = @{@"nameKey":@"意见反馈",@"imageKey":@"图层 236",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- case 3:
- dataDic = @{@"nameKey":@"退出登录",@"imageKey":@"图层 239",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- default:
- break;
- }
- }
- }
- #pragma mark ----加载界面
- - (void)loadsView{
- [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, ViewStartY, SCREEN_WIDTH, SCREEN_HEIGHT-ViewStartY) backgroundColor:NewNavigationColor style:UITableViewStyleGrouped delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
- newtableView.separatorStyle = YES;
- }
- #pragma mark-------------------------UITableView------------------------------------
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- //返回每段行数
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return dataArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *Cell = @"Cell";
- SetUpCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
- if (cell == nil) {
- cell = [[SetUpCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- // [cell assignment:dataArray[indexPath.row]];
- cell.title.text = dataArray[indexPath.row][@"nameKey"];
- [cell.imageview setImage:NewImageNamed(dataArray[indexPath.row][@"imageKey"])];
- // if (indexPath.row == 0) {
- // UILabel *haha = [[UILabel alloc] init];
- // haha.text = cacheSize;
- // [haha setSingleLineAutoResizeWithMaxWidth:0];
- // [cell.contentView addSubview:haha];
- // haha.sd_layout
- // .rightSpaceToView(cell.contentView, 10)
- // .centerYEqualToView(cell.contentView)
- // .heightIs(cell.height);
- // }
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return fitScreenHeight(44);
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"清除缓存"]) {
- [self Scavengingcaching];
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"意见反馈"]) {
- NewKeFuViewController *vc = [[NewKeFuViewController alloc] init];
- NewPushViewController(vc);
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"服务协议"]) {
- // AboutViewController *vc = [[AboutViewController alloc] init];
- // NewPushViewController(vc);
- NewInitWithName(AgreementViewController, vc);
- vc.str = @"服务协议";
- NewPushViewController(vc);
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"关于我们"]){
- ServiceagreementViewController *vc = [[ServiceagreementViewController alloc] init];
-
- NewPushViewController(vc);
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"修改密码"]){
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- NewModifyPasswordViewController *vc = [[NewModifyPasswordViewController alloc] init];
-
- NewPushViewController(vc);
- }else{
- NSLog(@"%@",@"未登录");
- NewLoginViewController *vc = [[NewLoginViewController alloc] init];
- [vc setLoginSuccess:^(NSString *string) {
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"退出登录"]){
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- [self touchExitLogin];//退出登录
- }else{
- NSLog(@"%@",@"未登录");
- [self.view makeToast:@"当前账号未登录!" duration:1.0 position:CSToastPositionCenter];
- }
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (void)submitclick:(UIButton *)btn{
- if ([UserHelper isLogin]) {
- NSLog(@"%@",@"已登录");
- [self touchExitLogin];//退出登录
- }else{
- NSLog(@"%@",@"未登录");
- [self.view makeToast:@"当前账号未登录!" duration:1.0 position:CSToastPositionCenter];
- }
- }
- #pragma mark - 点击退出登录
- - (void)touchExitLogin
- {
- UIAlertController *alertController2 = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"是否退出登录?" preferredStyle:(UIAlertControllerStyleAlert)];
-
- UIAlertAction *okAction2 = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {
- //退出登录
- [self exitLoginNetworkRequest];
-
- }];
-
- UIAlertAction *cancelAction2 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction *action) {
- //NSLog(@"取消");
- }];
-
- [alertController2 addAction:okAction2];
- [alertController2 addAction:cancelAction2];
-
- [self presentViewController:alertController2 animated:YES completion:nil];
- }
- #pragma mark - 退出登录网络请求
- - (void)exitLoginNetworkRequest
- {
- [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
- [MBProgressHUD hideHUDForView:self.view];
- //退出云信账号、解绑阿里云推送账号、删除用户单例类以及本地缓存保存的数据
- [UserHelper exitLogin];
- //退出环信账号
- [[HuanXinHelper sharedInstance] exitlogon];
- _tuichudenglu(@"退出登录");
- NewPopViewController;
- // NSMutableDictionary *parameters = NewMutableDictionaryInit;
- // [NetworkRequestManager requestGetWithInterfacePrefix:JT_logout parameters:parameters onSuccess:^(id requestData) {
- // [MBProgressHUD hideHUDForView:self.view];
- // //退出云信账号、解绑阿里云推送账号、删除用户单例类以及本地缓存保存的数据
- // [UserHelper exitLogin];
- // //退出环信账号
- // [[HuanXinHelper sharedInstance] exitlogon];
- // NewPopViewController;
- // } onFailure:^{
- // [MBProgressHUD hideHUDForView:self.view];
- //
- // }];
-
- }
- - (void)Scavengingcaching{
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"是否清除缓存?" preferredStyle:(UIAlertControllerStyleAlert)];
-
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {
- //NSLog(@"确定");
- BOOL cleanResult = [ZFileManagerHelper cleanCache];
- if (cleanResult) {
- [self.view makeToast:@"缓存清除成功!"];
- cacheSize = @"0.00K";
- [newtableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
- }
- }];
-
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction *action) {
- //NSLog(@"取消");
- }];
- [alertController addAction:okAction];
- [alertController addAction:cancelAction];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #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
|