// // InputPasswordVC.m // jiaPei // // Created by apple on 16/8/31. // Copyright © 2016年 JCZ. All rights reserved. // #import "InputPasswordVC.h" #import "QGPassWordTextField.h" //#import @interface InputPasswordVC () { QGPassWordTextField *pass; UITextField *psw1; UITextField *psw2; NSString *bindTel; NSString *SubmitNumType; NSInteger inputCount; } @end @implementation InputPasswordVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"输入支付密码"; [self configNavigationBar]; self.view.backgroundColor = backGroundColor; inputCount = 3; CGFloat x,y,w,h; x = 0; y = 40; w = kSize.width; h = 30; UILabel *label = [[UILabel alloc] setxywh]; [label setText:@"输入支付密码,以完成支付" Font:Font17 TextColor:contentTextColor Alignment:NSTextAlignmentCenter]; [self.view addSubview:label]; y += h + 10; x = 20; w -= 40; h = w/6.0; pass = [[QGPassWordTextField alloc]init]; pass.frame = setDIYFrame; pass.passWordCount = 6; [pass finishInput:^(NSString *password) { if ([defUser.userDict[@"accountInfo"] isKindOfClass:[NSDictionary class]]) { NSString *myPSW = [defUser.userDict[@"accountInfo"] objectForKey:@"pwd"]; if ([[password md5Encrypt] isEqualToString:myPSW]) { //支付成功 finishBlock(@"TRUE"); [self.view endEditing:YES]; [self.navigationController popViewControllerAnimated:YES]; }else{ //密码错误 /* inputCount -= 1; if (inputCount == 0) { //冻结账户 UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"您的密码存在安全隐患,我们已冻结您的账户,请联系xxxxxxx来恢复使用" preferredStyle:UIAlertControllerStyleAlert]; [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { [self.navigationController popViewControllerAnimated:YES]; }]]; [self presentViewController:alertFind animated:true completion:nil]; } */ UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"支付密码不正确,请重试" preferredStyle:UIAlertControllerStyleAlert]; [alertFind addAction:[UIAlertAction actionWithTitle:@"重新输入" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { pass.text = @""; [pass passWordDidChange:pass]; }]]; [alertFind addAction:[UIAlertAction actionWithTitle:@"忘记密码" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { [self forgetPassword]; }]]; [self presentViewController:alertFind animated:true completion:nil]; } }else{ ShowMsg(@"请到个人中心设置支付密码"); } }]; [self.view addSubview:pass]; y += h + 30; w = 80; x = kSize.width - 100; h = 30; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = setDIYFrame; [btn setTitle:@"忘记密码" textColor:[UIColor colorWithRed:55/255.0 green:147/255.0 blue:239/255.0 alpha:1] font:Font17 fotState:UIControlStateNormal]; [btn addTarget:self action:@selector(forgetPassword) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; } -(void)finishInput:(MyBlockType)block { finishBlock = block; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } #pragma mark 找回密码功能 -(void)forgetPassword { UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:@"请填写账户绑定手机号码" preferredStyle:UIAlertControllerStyleAlert]; [alertFind addTextFieldWithConfigurationHandler:^(UITextField * phoneNumField) { phoneNumField.placeholder = @"请输入手机号码"; }]; [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]]; [alertFind addAction:[UIAlertAction actionWithTitle:@"下一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { bindTel = [[alertFind.textFields firstObject] text]; if (![bindTel isEqualToString:defUser.userDict[@"a c"]]) { ShowMsg(@"填写号码与绑定号码不匹配,请重试"); [self presentViewController:alertFind animated:true completion:nil]; return; } //调获取验证码接口 SubmitNumType = @"1"; [self clickToSubmitNumber]; }]]; [self presentViewController:alertFind animated:true completion:nil]; } //获取验证码 这个方法可以用来公用 设置好参数SubmitNumType 及电话号码 -(void)clickToSubmitNumber { // if (![Util connectedToNetWork]) // { // showMsgUnconnect(); // return; // } // // [MBProgressHUD showLoadToView:self.view]; // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) { // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) { // [MBProgressHUD hideHUDForView:self.view]; // if (error) { // if (error.code == 477) { // ShowMsg(@"当天验证次数已超上限"); // }else{ // ShowMsg(@"请检查手机号码是否正确"); // } // return; // } // ShowMsg(@"验证码已发送"); // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:nil preferredStyle:UIAlertControllerStyleAlert]; // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) { // textField.placeholder = @"请输入验证码"; // }]; // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]]; // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { // // NSString *subString = [[subAlert.textFields firstObject] text]; // if (subString.length < 1) { // ShowMsg(@"请输入有效验证码"); // [self presentViewController:subAlert animated:true completion:nil]; // return; // } // //调检验验证码的接口 // [self clickToSubmitWithSubNum:subString]; // }]]; // [self presentViewController:subAlert animated:true completion:nil]; // }]; // }]; } //验证码有效性检验 -(void)clickToSubmitWithSubNum:(NSString *)subNum { // //验证验证码是否过期 // if (![Util connectedToNetWork]) { // showMsgUnconnect(); // return; // } // // [MBProgressHUD showLoadToView:self.view]; // [SMSSDK commitVerificationCode:subNum phoneNumber:bindTel zone:@"86" result:^( NSError *error) { // [MBProgressHUD hideHUDForView:self.view]; // if (error) { // ShowMsg(@"输入验证码错误"); // // }else{ // if ([SubmitNumType isEqualToString:@"1"]) { // //设置支付密码 // UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"设置新密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil]; // [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput]; // alertKey.tag = 11; // psw1 = [alertKey textFieldAtIndex:0]; // psw2 = [alertKey textFieldAtIndex:1]; // // psw1.placeholder = @"请输入新密码"; // psw2.placeholder = @"请确认密码"; // [psw1 setSecureTextEntry:YES]; // [alertKey show]; // } // } // }]; // } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 11) { if (buttonIndex == 1) { [self bindAccountZfmm]; } } } //设置支付密码 -(void)bindAccountZfmm { if (![psw1.text isEqualToString:psw2.text]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码不一致,请您核查" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alert show]; return; } NSMutableArray *arr =[NSMutableArray array]; [arr addPro:@"user" Value:defUser.userDict[@"id"]]; [arr addPro:@"pwd" Value:[psw1.text md5Encrypt]]; NSString* method = @"bindAccountZfmm"; [MBProgressHUD showLoadToView:self.view]; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) { [MBProgressHUD hideHUDForView:self.view]; if (!root) { ShowMsgFailed(); return; } if ( 1 == [root[@"code"] integerValue]) { ShowMsg(root[@"body"]); return; } ShowMsgSuc(); [self upDateUserInfo]; }]; } //更新数据 -(void)upDateUserInfo { [LoginViewController reLoginFromViewController:self finishBlock:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end