// // SettingViewController.m // IBOSS // // Created by apple on 2017/5/4. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved. // // 功能描述:设置控制器 // #import "SettingViewController.h" #import "PWModifyViewController.h" #import "Reachability.h" #import "Util.h" @interface SettingViewController (){ /** 缓存文本 */ UILabel *lbSize; } /** ASIDownManager请求对象 */ @property (nonatomic,strong) ASIDownManager *downManager; /** 原密码 */ @property (nonatomic,strong) NSString *originalPassword; /** 新密码 */ @property (nonatomic,strong) NSString *newsPassword; /** 确认密码 */ @property (nonatomic,strong) NSString *confirmPassword; @end @implementation SettingViewController #pragma mark - 公共函数 /** viewDidLoad */ - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"iBOSS"; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)]; //设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。 tapGestureRecognizer.cancelsTouchesInView = NO; //将触摸事件添加到当前view [self.view addGestureRecognizer:tapGestureRecognizer]; _staffList=[[NSMutableArray alloc]init]; [self initUI]; [self loadStaffData]; } /** didReceiveMemoryWarning */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } /** viewWillAppear @param animated <#animated description#> */ - (void)viewWillAppear:(BOOL)animated{ // 修改密码消失 if(!_clickFlag){ [self cancelPW]; } [self updateCacheSize:lbSize]; } #pragma mark - 回调函数 /** 密码修改成功回调成功 @param sender <#sender description#> */ - (void)OnPasswordLoadFinish:(ASIDownManager *)sender{ // 取消进度条 [self stopLoading]; // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if (iStatus == 0) { _clickFlag = true; [self showAlertViewText:@"密码修改成功"]; [_passwordModify removeFromSuperview]; return; } else{ _clickFlag = false; [self showAlertViewText:message]; return; } } /** 回调失败 @param sender <#sender description#> */ - (void)OnPasswordLoadFail:(ASIDownManager *)sender{ [self stopLoading]; _clickFlag = false; [self showAlertViewText:@"密码修改失败"]; return; } /** 切换用户回调成功 @param sender <#sender description#> */ - (void)onLoadFinish:(ASIDownManager *)sender { [self stopLoading]; // 服务器返回数据转换model RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if (iStatus == 0) { //个人数据统统滴清除 kkUserPwdOrinal = @""; kkUserPwd = @""; kkUserCode = @""; kkAccountCode = @""; [[UserInfoManager Share]ClearUserData ]; //退回登录界面 [Appdelegate changeViewDidLogout]; } else if(iStatus == ActionResultStatusAuthError ||iStatus == ActionResultStatusNoLogin ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){ [self showReLoginDialog:message]; } else { [self showAlertViewText:message]; // 退回登录界面 [Appdelegate changeViewDidLogout]; } } /** 切换用户回调失败 @param sender <#sender description#> */ - (void)onLoadFail:(ASIDownManager *)sender { [self stopLoading]; [self showAlertViewText:@"切换用户失败"]; } #pragma mark - 私有函数 /** 初始化ui */ - (void)initUI{ _clickFlag = true; [self.view setBackgroundColor:[UIColor whiteColor]]; UIImage *pic = [UIImage imageNamed:@"banner_setting"]; UIImageView *bannerView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.width*pic.size.height/pic.size.width)]; [bannerView setImage:pic]; [self.view addSubview:bannerView]; UIView *separatorView = [[UIView alloc]init]; [separatorView setBackgroundColor:LineBackgroundColor]; separatorView.frame=CGRectMake(0, CGRectGetMaxY(bannerView.frame), self.view.frame.size.width, 10); [self.view addSubview: separatorView]; CGFloat titleHeight = 50; CGFloat lblx = 20; CGFloat fontsize = 14; CGFloat valuey = 13; CGFloat valueheight = 25; CGFloat heightLine =1; CGFloat height = 350; //头布局 UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(separatorView.frame), Screen_Width, height)]; UIButton *btnHead = [UIButton buttonWithType:UIButtonTypeCustom]; btnHead.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [self.view addSubview: headView]; //名称 ————————— UIView *vname = [UIView new]; vname.frame=CGRectMake(0, 0, Screen_Width, titleHeight); [headView addSubview:vname]; UILabel *lbtotal = [UILabel new]; lbtotal.frame=CGRectMake(lblx, valuey, Screen_Width - 3*lblx, valueheight); lbtotal.font = [UIFont boldSystemFontOfSize:fontsize]; NSString *str = [NSString stringWithFormat:@"用户名:%@(%@)",kkUserName,kkUserCode]; lbtotal.text = str; [vname addSubview:lbtotal]; bannerView = [[UIImageView alloc] initWithFrame:CGRectMake(Screen_Width - lblx - 18,valuey+4,18,12.5)]; [bannerView setImage:[UIImage imageNamed:@"setting_right"]]; [vname addSubview:bannerView]; //分割线 UIView *viewBackgroud = [UIView new]; viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vname.frame), Screen_Width, heightLine); viewBackgroud.backgroundColor = LineBackgroundColor; [headView addSubview:viewBackgroud]; height=CGRectGetMaxY(viewBackgroud.frame); //名称 ————————— if([kkRights rangeOfString:FUNCTION_SALEMAN_BACKAMOUT_IPHONE].location!=NSNotFound){ UIView *vAmount = [UIView new]; vAmount.frame=CGRectMake(0, height, Screen_Width, titleHeight+20); [headView addSubview:vAmount]; UILabel *lblOldAmountTitle = [UILabel new]; lblOldAmountTitle.frame=CGRectMake(lblx, valuey,170, valueheight); lblOldAmountTitle.font = [UIFont boldSystemFontOfSize:fontsize]; lblOldAmountTitle.textColor=[UIColor redColor]; lblOldAmountTitle.text = @"昨日老客户回款累计(元)"; [vAmount addSubview:lblOldAmountTitle]; UILabel *lblOldAmount = [UILabel new]; lblOldAmount.frame=CGRectMake(lblx,CGRectGetMaxY(lblOldAmountTitle.frame),170, valueheight); lblOldAmount.textColor=[UIColor redColor]; lblOldAmount.font = [UIFont boldSystemFontOfSize:fontsize]; lblOldAmount.textAlignment=NSTextAlignmentCenter; lblOldAmount.text = kkOldAmountValue; [vAmount addSubview:lblOldAmount]; UILabel *lblNewAmountTitle = [UILabel new]; lblNewAmountTitle.frame=CGRectMake(Screen_Width/2, valuey,170, valueheight); lblNewAmountTitle.font = [UIFont boldSystemFontOfSize:fontsize]; lblNewAmountTitle.textColor=[UIColor redColor]; lblNewAmountTitle.text = @"昨日新客户回款累计(元)"; [vAmount addSubview:lblNewAmountTitle]; UILabel *lblNewAmount = [UILabel new]; lblNewAmount.frame=CGRectMake(Screen_Width/2,CGRectGetMaxY(lblNewAmountTitle.frame),170, valueheight); lblNewAmount.textColor=[UIColor redColor]; lblNewAmount.font = [UIFont boldSystemFontOfSize:fontsize]; lblNewAmount.text = kkNewAmountValue; lblNewAmount.textAlignment=NSTextAlignmentCenter; [vAmount addSubview:lblNewAmount]; //分割线 viewBackgroud = [UIView new]; viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vAmount.frame), Screen_Width, heightLine); viewBackgroud.backgroundColor = LineBackgroundColor; [headView addSubview:viewBackgroud]; height=CGRectGetMaxY(viewBackgroud.frame); } float margin = 5; //切换用户 ————————— UIView *vchangeUser = [UIView new]; vchangeUser.frame=CGRectMake(0, height, Screen_Width, titleHeight); [headView addSubview:vchangeUser]; UIImageView *imgview = [UIImageView new]; imgview.frame=CGRectMake(lblx, valuey+margin, 14, 19); [imgview setImage:[UIImage imageNamed:@"setting_change_user"]]; [vchangeUser addSubview:imgview]; UIButton *btnChangeUser = [UIButton buttonWithType:UIButtonTypeCustom]; btnChangeUser.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+2*margin, valuey, Screen_Width - CGRectGetMaxX(imgview.frame), valueheight); btnChangeUser.titleLabel.font = [UIFont systemFontOfSize:fontsize]; btnChangeUser.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [btnChangeUser setTitle:@"切换用户" forState:UIControlStateNormal]; [btnChangeUser setTitleColor:NavTitleColor forState:UIControlStateNormal]; [btnChangeUser addTarget:self action:@selector(changeUser) forControlEvents:UIControlEventTouchUpInside]; [vchangeUser addSubview:btnChangeUser]; CGRect cg = CGRectMake(Screen_Width - lblx - 9,valuey+4,9,15 ); bannerView = [[UIImageView alloc] initWithFrame:cg]; [bannerView setImage:[UIImage imageNamed:@"setting_right_arrow"]]; [vchangeUser addSubview:bannerView]; viewBackgroud = [UIView new]; viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vchangeUser.frame), Screen_Width, heightLine); viewBackgroud.backgroundColor = LineBackgroundColor; [headView addSubview:viewBackgroud]; // 修改密码 UIView *vchangePw = [UIView new]; vchangePw.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight); [headView addSubview:vchangePw]; imgview = [UIImageView new]; imgview.frame=CGRectMake(lblx, valuey+margin, 14, 16); [imgview setImage:[UIImage imageNamed:@"setting_change_pw"]]; [vchangePw addSubview:imgview]; UIButton *btnChangePw = [UIButton buttonWithType:UIButtonTypeCustom]; btnChangePw.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+2*margin, valuey, Screen_Width - CGRectGetMaxX(imgview.frame), valueheight); btnChangePw.titleLabel.font = [UIFont systemFontOfSize:fontsize]; btnChangePw.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [btnChangePw setTitle:@"修改密码" forState:UIControlStateNormal]; [btnChangePw setTitleColor:NavTitleColor forState:UIControlStateNormal]; [btnChangePw addTarget:self action:@selector(changePw) forControlEvents:UIControlEventTouchUpInside]; [vchangePw addSubview:btnChangePw]; bannerView = [[UIImageView alloc] initWithFrame:cg]; [bannerView setImage:[UIImage imageNamed:@"setting_right_arrow"]]; [vchangePw addSubview:bannerView]; viewBackgroud = [UIView new]; viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vchangePw.frame), Screen_Width,heightLine); viewBackgroud.backgroundColor = LineBackgroundColor; [headView addSubview:viewBackgroud]; //清除缓存 UIView *vClear = [UIView new]; vClear.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight); [headView addSubview:vClear]; imgview = [UIImageView new]; imgview.frame=CGRectMake(lblx-3, valuey+2, 19, 19); [imgview setImage:[UIImage imageNamed:@"icon_clear"]]; [vClear addSubview:imgview]; UIButton *btnClear = [UIButton buttonWithType:UIButtonTypeCustom]; btnClear.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+2*margin-2, valuey, Screen_Width - CGRectGetMaxX(imgview.frame), valueheight); btnClear.titleLabel.font = [UIFont systemFontOfSize:fontsize]; btnClear.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [btnClear setTitle:@"清除缓存" forState:UIControlStateNormal]; [btnClear setTitleColor:NavTitleColor forState:UIControlStateNormal]; [btnClear addTarget:self action:@selector(clearData) forControlEvents:UIControlEventTouchUpInside]; [vClear addSubview:btnClear]; bannerView = [[UIImageView alloc] initWithFrame:cg]; [bannerView setImage:[UIImage imageNamed:@"setting_right_arrow"]]; [vClear addSubview:bannerView]; lbSize = [[UILabel alloc] init]; [self updateCacheSize:lbSize]; lbSize.font = [UIFont systemFontOfSize:13]; lbSize.textColor = [UIColor grayColor]; [lbSize sizeToFit]; lbSize.frame = CGRectMake(CGRectGetMaxX(bannerView.frame)- CGRectGetWidth(bannerView.frame)-CGRectGetWidth(lbSize.frame)-10, valuey+4, CGRectGetWidth(lbSize.frame), CGRectGetHeight(lbSize.frame)); [vClear addSubview:lbSize]; viewBackgroud = [UIView new]; viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vClear.frame), Screen_Width,heightLine); viewBackgroud.backgroundColor = LineBackgroundColor; [headView addSubview:viewBackgroud]; // UIView *vPerformanceRank = [UIView new]; // vPerformanceRank.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight); // [headView addSubview:vPerformanceRank]; // // imgview = [UIImageView new]; // imgview.frame=CGRectMake(lblx, valuey + margin, 15, 16); // [imgview setImage:[UIImage imageNamed:@"performancerank"]]; // [vPerformanceRank addSubview:imgview]; // // UIButton *btnPerformanceRank= [UIButton buttonWithType:UIButtonTypeCustom]; // btnPerformanceRank.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+2*margin, valuey, Screen_Width - CGRectGetMaxX(imgview.frame), valueheight); // btnPerformanceRank.titleLabel.font = [UIFont systemFontOfSize:fontsize]; // btnPerformanceRank.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; // [btnPerformanceRank setTitle:@"业绩排行" forState:UIControlStateNormal]; // [btnPerformanceRank setTitleColor:NavTitleColor forState:UIControlStateNormal]; // [btnPerformanceRank addTarget:self action:@selector(performanceRank) forControlEvents:UIControlEventTouchUpInside]; // [vPerformanceRank addSubview:btnPerformanceRank]; // // bannerView = [[UIImageView alloc] initWithFrame:cg]; // [bannerView setImage:[UIImage imageNamed:@"setting_right_arrow"]]; // [vPerformanceRank addSubview:bannerView]; // // viewBackgroud = [UIView new]; // viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vPerformanceRank.frame), Screen_Width,heightLine); // viewBackgroud.backgroundColor = LineBackgroundColor; // [headView addSubview:viewBackgroud]; // UIView *vNotification = [UIView new]; // vNotification.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight); // [headView addSubview:vNotification]; // // imgview = [UIImageView new]; // imgview.frame=CGRectMake(lblx, valuey + margin, 15, 15); // [imgview setImage:[UIImage imageNamed:@"notification"]]; // [vNotification addSubview:imgview]; // // UIButton *btnNotification= [UIButton buttonWithType:UIButtonTypeCustom]; // btnNotification.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+2*margin, valuey, Screen_Width - CGRectGetMaxX(imgview.frame), valueheight); // btnNotification.titleLabel.font = [UIFont systemFontOfSize:fontsize]; // btnNotification.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; // [btnNotification setTitle:@"通知公告" forState:UIControlStateNormal]; // [btnNotification setTitleColor:NavTitleColor forState:UIControlStateNormal]; // [btnNotification addTarget:self action:@selector(notification) forControlEvents:UIControlEventTouchUpInside]; // [vNotification addSubview:btnNotification]; // // bannerView = [[UIImageView alloc] initWithFrame:cg]; // [bannerView setImage:[UIImage imageNamed:@"setting_right_arrow"]]; // [vNotification addSubview:bannerView]; // // viewBackgroud = [UIView new]; // viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vNotification.frame), Screen_Width,heightLine); // viewBackgroud.backgroundColor = LineBackgroundColor; // [headView addSubview:viewBackgroud]; // 退出登录 UIView *vexit = [UIView new]; vexit.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, titleHeight); [headView addSubview:vexit]; imgview = [UIImageView new]; imgview.frame=CGRectMake(lblx, valuey + margin, 15, 16); [imgview setImage:[UIImage imageNamed:@"setting_exit"]]; [vexit addSubview:imgview]; UIButton *btnExit= [UIButton buttonWithType:UIButtonTypeCustom]; btnExit.frame=CGRectMake(CGRectGetMaxX(imgview.frame)+2*margin, valuey, Screen_Width - CGRectGetMaxX(imgview.frame), valueheight); btnExit.titleLabel.font = [UIFont systemFontOfSize:fontsize]; btnExit.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [btnExit setTitle:@"退出登录" forState:UIControlStateNormal]; [btnExit setTitleColor:NavTitleColor forState:UIControlStateNormal]; [btnExit addTarget:self action:@selector(exitApp) forControlEvents:UIControlEventTouchUpInside]; [vexit addSubview:btnExit]; bannerView = [[UIImageView alloc] initWithFrame:cg]; [bannerView setImage:[UIImage imageNamed:@"setting_right_arrow"]]; [vexit addSubview:bannerView]; viewBackgroud = [UIView new]; viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vexit.frame), Screen_Width,heightLine); viewBackgroud.backgroundColor = LineBackgroundColor; [headView addSubview:viewBackgroud]; headView.frame=CGRectMake(0, CGRectGetMaxY(separatorView.frame), Screen_Width, CGRectGetMaxY(viewBackgroud.frame)); } /** 隐藏键盘 @param tap <#tap description#> */ - (void)keyboardHide:(UITapGestureRecognizer*)tap{ [self.view endEditing:YES]; } /** 切换用户 */ - (void)changeUser{ __weak typeof (self)weakself = self; // 初始化-> UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"切换用户" message:@"是否要切换用户吗?" preferredStyle:UIAlertControllerStyleAlert]; // addAction-> UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ weakself.downManager = [[ASIDownManager alloc] init]; weakself.downManager.delegate = self; weakself.downManager.onRequestSuccess = @selector(onLoadFinish:); weakself.downManager.onRequestFail = @selector(onLoadFail:); [weakself startLoading]; NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"SMDLogout" forKey:@"Action"]; [dict setObject:kkAccountCode forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [weakself.downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; }]; // addAction-> UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){ }]; UIColor *cancelColor = [UIColor blackColor]; UIColor *sureColor = [UIColor redColor]; [cancelAction setValue:cancelColor forKey:@"titleTextColor"]; [okAction setValue:sureColor forKey:@"titleTextColor"]; [alert addAction:okAction]; [alert addAction:cancelAction]; // 展示-> [self presentViewController:alert animated:YES completion:nil]; } /** 修改密码 */ - (void)changePw{ if(!_clickFlag){ return; } _clickFlag = false; _passwordModify = [DKPWModifyAlterView alterViewWithTitle:@"密码修改" cancel:@"取消" sure:@"确定"]; [self.view addSubview:_passwordModify]; [[_passwordModify sureBt] addTarget:self action:@selector(surePW) forControlEvents:UIControlEventTouchUpInside]; [[_passwordModify cancelBt] addTarget:self action:@selector(cancelPW) forControlEvents:UIControlEventTouchUpInside]; } /** 退出app程序 */ - (void)exitApp{ // NSMutableArray *arr = [NSMutableArray array]; // NSLog(@"%@",arr[10]); if(!_clickFlag){ return; } //初始化提示框; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"退出程序" message:@"是否要退出登录吗?" preferredStyle:UIAlertControllerStyleAlert ]; // addAction-> UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ [self exit]; }]; // addAction-> UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){ }]; UIColor *cancelColor = [UIColor blackColor]; UIColor *sureColor = [UIColor redColor]; [cancelAction setValue:cancelColor forKey:@"titleTextColor"]; [okAction setValue:sureColor forKey:@"titleTextColor"]; [alert addAction:okAction]; [alert addAction:cancelAction]; // 3.显示alertController:presentViewController [self presentViewController:alert animated:YES completion:nil]; } /** 退出登录 */ - (void) exit{ if([[Util getNetWorkStates] isEqualToString:@"无网络"]){ exit(0); return; } [self startLoading]; NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"SMDLogout" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; self.downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.onRequestSuccess = @selector(onExitFinish:); _downManager.onRequestFail = @selector(onExitFail:); [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } - (void) onExitFinish:(ASIDownManager *) sender { exit(0); } - (void) onExitFail:(ASIDownManager *) sender { exit(0); } -(void)loadStaffData{ NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetStaffRelations" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:kkUserID forKey:@"UserID"]; self.downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.onRequestSuccess = @selector(onStaffLoadFinish:); _downManager.onRequestFail = @selector(onStaffLoadFail:); [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** 加载数据成功回调 @param sender <#sender description#> */ - (void)onStaffLoadFinish:(ASIDownManager *)sender { // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if (iStatus == 0) { // 服务器返回数据结果 NSArray * infoArr = (NSArray *)resultModel.result; if(infoArr!=nil&&infoArr.count>0){ for(int i=0;i */ - (void)onStaffLoadFail:(ASIDownManager *)sender { [self showAlertViewText:@"网络异常"]; } /** 确定修改密码 */ - (void)surePW{ _originalPassword= _passwordModify.originalPassword.text; if(_originalPassword == nil||[_originalPassword isEqualToString:@""]){ [self showAlertViewText:@"原密码不能为空"]; return; } _newsPassword=_passwordModify.nePassword.text; if(_newsPassword == nil||[_newsPassword isEqualToString:@""]){ [self showAlertViewText:@"新密码不能为空"]; return; } _confirmPassword=_passwordModify.confirmPassword.text; if(_confirmPassword == nil||[_confirmPassword isEqualToString:@""]){ [self showAlertViewText:@"确认密码不能为空"]; return; } if(![_newsPassword isEqualToString:_confirmPassword]){ [self showAlertViewText:@"新密码与确认密码不一致"]; return; } self.downManager = [[ASIDownManager alloc] init]; [self startLoading]; self.downManager.delegate = self; self.downManager.onRequestSuccess = @selector(OnPasswordLoadFinish:); self.downManager.onRequestFail = @selector(OnPasswordLoadFail:); NSString *urlStr = ServerURL; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"SaveUserPassWordIphone" forKey:@"Action"]; [dict setObject:kkAccountCode forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:_originalPassword forKey:@"OldUserPassWord"]; [dict setObject:_newsPassword forKey:@"NewUserPassword"]; [self.downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** 取消修改密码 */ - (void)cancelPW{ _clickFlag = true; [_passwordModify removeFromSuperview]; } -(void)clearData{ // // 找到Documents文件夹路径 // NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; // NSString *dataFilePath = [documentsPath stringByAppendingPathComponent:@"IBOSSERROR"]; // // NSFileManager *fileManager = [NSFileManager defaultManager]; // // BOOL isDir = NO; // // // fileExistsAtPath 判断一个文件或目录是否有效,isDirectory判断是否一个目录 // BOOL existed = [fileManager fileExistsAtPath:dataFilePath isDirectory:&isDir]; // NSError *error = nil; // if ( (isDir == YES && existed == YES) ) { // NSArray *fileList = [[NSArray alloc] init]; // fileList = [fileManager contentsOfDirectoryAtPath:dataFilePath error:&error]; // NSString* str = fileList.firstObject; // NSString *resultStr = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",dataFilePath,str] encoding:NSUTF8StringEncoding error:nil]; // NSLog(@"%@",resultStr); // } UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"清除缓存" message:@"确定要清除所有缓存吗?" preferredStyle:UIAlertControllerStyleAlert ]; // addAction-> UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ [self deleteFile:IBOSSERROR]; [self deleteFile:IBOSSIMAGE]; [self deleteFile:IBOSSSOUND]; [self updateCacheSize:lbSize]; }]; // addAction-> UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){ }]; UIColor *cancelColor = [UIColor blackColor]; UIColor *sureColor = [UIColor redColor]; [cancelAction setValue:cancelColor forKey:@"titleTextColor"]; [okAction setValue:sureColor forKey:@"titleTextColor"]; [alert addAction:okAction]; [alert addAction:cancelAction]; // 3.显示alertController:presentViewController [self presentViewController:alert animated:YES completion:nil]; } /** 更新缓存大小 @param lbSize <#lbSize description#> */ - (void)updateCacheSize:(UILabel *) lbSize{ CGFloat sizeIBOSSERROR = [self folderSizeAtPath: IBOSSERROR]; CGFloat sizeIBOSSIMAGE = [self folderSizeAtPath: IBOSSIMAGE]; CGFloat sizeIBOSSSOUND = [self folderSizeAtPath: IBOSSSOUND]; CGFloat sum = sizeIBOSSERROR+sizeIBOSSIMAGE+sizeIBOSSSOUND; if(sum == 0){ lbSize.hidden = YES; }else{ lbSize.hidden = NO; } lbSize.text = [NSString stringWithFormat:@"约%.2fM",sum]; [lbSize sizeToFit]; } /** 删除Document下文件夹 @param fileName <#fileName description#> */ - (void)deleteFile:(NSString *) fileName{ NSFileManager* fileManager=[NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); //文件名 NSString *uniquePath=[[paths objectAtIndex:0] stringByAppendingPathComponent:fileName]; BOOL blHave=[[NSFileManager defaultManager] fileExistsAtPath:uniquePath]; if (!blHave) { NSLog(@"no have"); return ; }else { NSLog(@" have"); BOOL blDele= [fileManager removeItemAtPath:uniquePath error:nil]; if (blDele) { NSLog(@"dele success"); }else { NSLog(@"dele fail"); } } } //遍历文件夹获得文件夹大小,返回多少M - (float )folderSizeAtPath:(NSString*) folderPath{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); //文件名 folderPath=[[paths objectAtIndex:0] stringByAppendingPathComponent:folderPath]; NSFileManager* manager = [NSFileManager defaultManager]; if (![manager fileExistsAtPath:folderPath]) return 0; NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:folderPath] objectEnumerator]; NSString* fileName; long long folderSize = 0; while ((fileName = [childFilesEnumerator nextObject]) != nil){ NSString* fileAbsolutePath = [folderPath stringByAppendingPathComponent:fileName]; folderSize += [self fileSizeAtPath:fileAbsolutePath]; } return folderSize/(1024.0*1024.0); } //单个文件的大小 - (long long) fileSizeAtPath:(NSString*) filePath{ NSFileManager* manager = [NSFileManager defaultManager]; if ([manager fileExistsAtPath:filePath]){ return [[manager attributesOfItemAtPath:filePath error:nil] fileSize]; } return 0; } -(void)performanceRank{ PerformanceRankListVc *rankVc=[[PerformanceRankListVc alloc]init]; self.hidesBottomBarWhenPushed=YES; rankVc.staffList=_staffList; [self.navigationController setNavigationBarHidden:NO animated:YES]; [self.navigationController pushViewController:rankVc animated:YES]; self.hidesBottomBarWhenPushed=NO; } -(void)notification{ self.hidesBottomBarWhenPushed=YES; NotificationHomeVc *homeVC = [[NotificationHomeVc alloc] init]; [self.navigationController pushViewController:homeVC animated:YES]; [self.navigationController setNavigationBarHidden:NO animated:YES]; self.hidesBottomBarWhenPushed=NO; } @end