InputPasswordVC.m 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. //
  2. // InputPasswordVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/8/31.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "InputPasswordVC.h"
  9. #import "QGPassWordTextField.h"
  10. //#import <SMS_SDK/SMSSDK.h>
  11. @interface InputPasswordVC ()<UITextFieldDelegate,UIAlertViewDelegate>
  12. {
  13. QGPassWordTextField *pass;
  14. UITextField *psw1;
  15. UITextField *psw2;
  16. NSString *bindTel;
  17. NSString *SubmitNumType;
  18. NSInteger inputCount;
  19. }
  20. @end
  21. @implementation InputPasswordVC
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.title = @"输入支付密码";
  25. [self configNavigationBar];
  26. self.view.backgroundColor = backGroundColor;
  27. inputCount = 3;
  28. CGFloat x,y,w,h;
  29. x = 0;
  30. y = 40;
  31. w = kSize.width;
  32. h = 30;
  33. UILabel *label = [[UILabel alloc] setxywh];
  34. [label setText:@"输入支付密码,以完成支付" Font:Font17 TextColor:contentTextColor Alignment:NSTextAlignmentCenter];
  35. [self.view addSubview:label];
  36. y += h + 10;
  37. x = 20;
  38. w -= 40;
  39. h = w/6.0;
  40. pass = [[QGPassWordTextField alloc]init];
  41. pass.frame = setDIYFrame;
  42. pass.passWordCount = 6;
  43. [pass finishInput:^(NSString *password) {
  44. if ([defUser.userDict[@"accountInfo"] isKindOfClass:[NSDictionary class]]) {
  45. NSString *myPSW = [defUser.userDict[@"accountInfo"] objectForKey:@"pwd"];
  46. if ([[password md5Encrypt] isEqualToString:myPSW]) {
  47. //支付成功
  48. finishBlock(@"TRUE");
  49. [self.view endEditing:YES];
  50. [self.navigationController popViewControllerAnimated:YES];
  51. }else{
  52. //密码错误
  53. /*
  54. inputCount -= 1;
  55. if (inputCount == 0) {
  56. //冻结账户
  57. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"您的密码存在安全隐患,我们已冻结您的账户,请联系xxxxxxx来恢复使用" preferredStyle:UIAlertControllerStyleAlert];
  58. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  59. [self.navigationController popViewControllerAnimated:YES];
  60. }]];
  61. [self presentViewController:alertFind animated:true completion:nil];
  62. }
  63. */
  64. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"支付密码不正确,请重试" preferredStyle:UIAlertControllerStyleAlert];
  65. [alertFind addAction:[UIAlertAction actionWithTitle:@"重新输入" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  66. pass.text = @"";
  67. [pass passWordDidChange:pass];
  68. }]];
  69. [alertFind addAction:[UIAlertAction actionWithTitle:@"忘记密码" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  70. [self forgetPassword];
  71. }]];
  72. [self presentViewController:alertFind animated:true completion:nil];
  73. }
  74. }else{
  75. ShowMsg(@"请到个人中心设置支付密码");
  76. }
  77. }];
  78. [self.view addSubview:pass];
  79. y += h + 30;
  80. w = 80;
  81. x = kSize.width - 100;
  82. h = 30;
  83. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  84. btn.frame = setDIYFrame;
  85. [btn setTitle:@"忘记密码" textColor:[UIColor colorWithRed:55/255.0 green:147/255.0 blue:239/255.0 alpha:1] font:Font17 fotState:UIControlStateNormal];
  86. [btn addTarget:self action:@selector(forgetPassword) forControlEvents:UIControlEventTouchUpInside];
  87. [self.view addSubview:btn];
  88. }
  89. -(void)finishInput:(MyBlockType)block
  90. {
  91. finishBlock = block;
  92. }
  93. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  94. {
  95. [self.view endEditing:YES];
  96. }
  97. #pragma mark 找回密码功能
  98. -(void)forgetPassword
  99. {
  100. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:@"请填写账户绑定手机号码" preferredStyle:UIAlertControllerStyleAlert];
  101. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * phoneNumField) {
  102. phoneNumField.placeholder = @"请输入手机号码";
  103. }];
  104. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  105. [alertFind addAction:[UIAlertAction actionWithTitle:@"下一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  106. bindTel = [[alertFind.textFields firstObject] text];
  107. if (![bindTel isEqualToString:defUser.userDict[@"a c"]]) {
  108. ShowMsg(@"填写号码与绑定号码不匹配,请重试");
  109. [self presentViewController:alertFind animated:true completion:nil];
  110. return;
  111. }
  112. //调获取验证码接口
  113. SubmitNumType = @"1";
  114. [self clickToSubmitNumber];
  115. }]];
  116. [self presentViewController:alertFind animated:true completion:nil];
  117. }
  118. //获取验证码 这个方法可以用来公用 设置好参数SubmitNumType 及电话号码
  119. -(void)clickToSubmitNumber
  120. {
  121. // if (![Util connectedToNetWork])
  122. // {
  123. // showMsgUnconnect();
  124. // return;
  125. // }
  126. //
  127. // [MBProgressHUD showLoadToView:self.view];
  128. // [RQ_SHARE_FUNCTION checkMobPolicyOnResult:^(BOOL success) {
  129. // [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:bindTel zone:@"86" template:nil result:^(NSError *error) {
  130. // [MBProgressHUD hideHUDForView:self.view];
  131. // if (error) {
  132. // if (error.code == 477) {
  133. // ShowMsg(@"当天验证次数已超上限");
  134. // }else{
  135. // ShowMsg(@"请检查手机号码是否正确");
  136. // }
  137. // return;
  138. // }
  139. // ShowMsg(@"验证码已发送");
  140. // UIAlertController *subAlert = [UIAlertController alertControllerWithTitle:@"找回支付密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
  141. // [subAlert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  142. // textField.placeholder = @"请输入验证码";
  143. // }];
  144. // [subAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  145. // [subAlert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  146. //
  147. // NSString *subString = [[subAlert.textFields firstObject] text];
  148. // if (subString.length < 1) {
  149. // ShowMsg(@"请输入有效验证码");
  150. // [self presentViewController:subAlert animated:true completion:nil];
  151. // return;
  152. // }
  153. // //调检验验证码的接口
  154. // [self clickToSubmitWithSubNum:subString];
  155. // }]];
  156. // [self presentViewController:subAlert animated:true completion:nil];
  157. // }];
  158. // }];
  159. }
  160. //验证码有效性检验
  161. -(void)clickToSubmitWithSubNum:(NSString *)subNum
  162. {
  163. // //验证验证码是否过期
  164. // if (![Util connectedToNetWork]) {
  165. // showMsgUnconnect();
  166. // return;
  167. // }
  168. //
  169. // [MBProgressHUD showLoadToView:self.view];
  170. // [SMSSDK commitVerificationCode:subNum phoneNumber:bindTel zone:@"86" result:^( NSError *error) {
  171. // [MBProgressHUD hideHUDForView:self.view];
  172. // if (error) {
  173. // ShowMsg(@"输入验证码错误");
  174. //
  175. // }else{
  176. // if ([SubmitNumType isEqualToString:@"1"]) {
  177. // //设置支付密码
  178. // UIAlertView *alertKey = [[UIAlertView alloc] initWithTitle:@"设置新密码" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil];
  179. // [alertKey setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
  180. // alertKey.tag = 11;
  181. // psw1 = [alertKey textFieldAtIndex:0];
  182. // psw2 = [alertKey textFieldAtIndex:1];
  183. //
  184. // psw1.placeholder = @"请输入新密码";
  185. // psw2.placeholder = @"请确认密码";
  186. // [psw1 setSecureTextEntry:YES];
  187. // [alertKey show];
  188. // }
  189. // }
  190. // }];
  191. //
  192. }
  193. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  194. {
  195. if (alertView.tag == 11) {
  196. if (buttonIndex == 1)
  197. {
  198. [self bindAccountZfmm];
  199. }
  200. }
  201. }
  202. //设置支付密码
  203. -(void)bindAccountZfmm
  204. {
  205. if (![psw1.text isEqualToString:psw2.text])
  206. {
  207. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码不一致,请您核查" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  208. [alert show];
  209. return;
  210. }
  211. NSMutableArray *arr =[NSMutableArray array];
  212. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  213. [arr addPro:@"pwd" Value:[psw1.text md5Encrypt]];
  214. NSString* method = @"bindAccountZfmm";
  215. [MBProgressHUD showLoadToView:self.view];
  216. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  217. [MBProgressHUD hideHUDForView:self.view];
  218. if (!root)
  219. {
  220. ShowMsgFailed();
  221. return;
  222. }
  223. if ( 1 == [root[@"code"] integerValue]) {
  224. ShowMsg(root[@"body"]);
  225. return;
  226. }
  227. ShowMsgSuc();
  228. [self upDateUserInfo];
  229. }];
  230. }
  231. //更新数据
  232. -(void)upDateUserInfo
  233. {
  234. [LoginViewController reLoginFromViewController:self finishBlock:nil];
  235. }
  236. - (void)didReceiveMemoryWarning {
  237. [super didReceiveMemoryWarning];
  238. }
  239. @end