// // GIGaChangePassVC.m // GIGA // // Created by lianxiang on 2018/9/19. // Copyright © 2018年 com.giga.ios. All rights reserved. // #import "GIGaChangePassVC.h" #import "GiGaBaseAPiRequest.h" #import "GiGaNetManager.h" #import "GiGaServerConfig.h" #import "GiGaAPIResult.h" @interface GIGaChangePassVC () @end @implementation GIGaChangePassVC - (void)viewDidLoad { [super viewDidLoad]; [self addNavTitile:@"修改密码"]; // Do any additional setup after loading the view from its nib. UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [saveBtn addTarget:self action:@selector(doBtnAction:) forControlEvents:UIControlEventTouchUpInside]; saveBtn.frame = CGRectMake(0, 0,40, 36); NSAttributedString *attrititle = [GiGaHelper stringWithText:@"完成" textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTMEDIUM(16) leterSpace:0]; [saveBtn setAttributedTitle:attrititle forState:UIControlStateNormal]; UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithCustomView:saveBtn]; self.navigationItem.rightBarButtonItem = saveItem; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)doBtnAction:(UIButton *)btn{ if (self.oldPassField.text.length == 0) { //[self.view makeToast:@"请输入原密码" duration:2 position:CSToastPositionTop]; GIGA_ShowToast(@"请输入新密码"); return; } if (self.xinPassFiled.text.length == 0) { //[self.view makeToast:@"请输入新密码" duration:2 position:CSToastPositionTop]; GIGA_ShowToast(@"请输入新密码"); return; } int leng = [GiGaHelper convertToInt: self.xinPassFiled.text]; if (!(leng >= 6 && leng <= 20)) { GIGA_ShowToast(@"请输入6-20位数字和字母组成的新密码"); return; } if (self.reNewPassFiled.text.length == 0) { GIGA_ShowToast(@"请输入新密码"); return; } if (![self.reNewPassFiled.text isEqualToString:self.xinPassFiled.text]) { GIGA_ShowToast(@"两次输入密码不一致!"); return; } [self newPassBtnAction:btn]; } -(void)newPassBtnAction:(UIButton *)btn{ btn.userInteractionEnabled = NO; [self.view makeToastActivity:CSToastPositionCenter]; NSDictionary *params = @{ @"password":self.oldPassField.text, @"newPassword":self.xinPassFiled.text, @"newPasswordConfirm":self.reNewPassFiled.text }; NSString *url = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],kPAiUSerEditpwd]; [GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) { GiGaAPIResult *reult = [[GiGaAPIResult alloc] initWithDictionary:resDic]; [self.view hideToastActivity]; btn.userInteractionEnabled = YES; if (reult.success) { GIGA_WIndowTost(reult.message); [self.navigationController popViewControllerAnimated:YES]; }else{ if (reult.code == 401) { //token失效 [GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self]; } GIGA_WIndowTost(reult.message); } }]; } @end