123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- //
- // InputPasswordVC.m
- // jiaPei
- //
- // Created by apple on 16/8/31.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "InputPasswordVC.h"
- #import "QGPassWordTextField.h"
- //#import <SMS_SDK/SMSSDK.h>
- @interface InputPasswordVC ()<UITextFieldDelegate,UIAlertViewDelegate>
- {
- 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<UITouch *> *)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
|