NewForgotPasswordViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. //
  2. // MMMessageVerificationVC.m
  3. // MingMen
  4. //
  5. // Created by 肖雨 on 2017/3/11.
  6. // Copyright © 2017年 肖雨. All rights reserved.
  7. //
  8. #import "NewForgotPasswordViewController.h"
  9. #import "NewRegistCell.h"
  10. @interface NewForgotPasswordViewController ()
  11. {
  12. NSMutableArray *dataArray;
  13. UIButton *verificationCodeButton;
  14. UIButton *confirm2;
  15. NSString *yonghutype;
  16. }
  17. @property (strong ,nonatomic) UITextField * account;
  18. @property (strong ,nonatomic) UITextField * iphoneNumber;
  19. @property (strong ,nonatomic) UITextField * yanzhenma;
  20. @property (strong ,nonatomic) UITextField * password;
  21. @property (strong ,nonatomic) UITextField * querenpassword;
  22. @property (strong ,nonatomic) UIButton * yhtypeStr;
  23. @end
  24. @implementation NewForgotPasswordViewController
  25. -(void)dealloc
  26. {
  27. NSLog(@"找回密码界面销毁");
  28. }
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. // Do any additional setup after loading the view.
  32. [self setNavTitle:@"忘记密码"];
  33. [self dataInitialization];
  34. [self loadsView];
  35. }
  36. #pragma mark - 数据初始化
  37. -(void)dataInitialization
  38. {
  39. verificationCodeButton = nil;
  40. yonghutype = @"请选择用户类型";
  41. }
  42. #pragma mark - UI初始化
  43. -(void)loadsView
  44. {
  45. UIImageView *backimage = [UIImageView new];
  46. [backimage setImage:[UIImage imageNamed:@"dlbj"]];
  47. backimage.backgroundColor = NewClearColor;
  48. backimage.userInteractionEnabled = YES;
  49. [self.view addSubview:backimage];
  50. backimage.sd_layout
  51. .leftEqualToView(self.view)
  52. .topEqualToView(self.view)
  53. .bottomEqualToView(self.view)
  54. .rightEqualToView(self.view);
  55. UIButton *fanhuiBT = [UIButton new];
  56. [fanhuiBT setBackgroundImage:NewImageNamed(@"fh") forState:UIControlStateNormal];
  57. NewTouchUpInside(fanhuiBT, fanhuiBTclick:);
  58. [backimage addSubview:fanhuiBT];
  59. fanhuiBT.sd_layout
  60. .leftSpaceToView(backimage, 17)
  61. .topSpaceToView(backimage, 32)
  62. .heightIs(21)
  63. .widthIs(11);
  64. UIImageView *logoimage = [UIImageView new];
  65. [logoimage setImage:[UIImage imageNamed:@"logo"]];
  66. logoimage.backgroundColor = NewClearColor;
  67. [backimage addSubview:logoimage];
  68. logoimage.sd_layout
  69. .centerXEqualToView(backimage)
  70. .topSpaceToView(backimage, fitScreenHeight(90))
  71. .heightIs(fitScreenWidth(80))
  72. .widthIs(fitScreenWidth(80));
  73. //用户名
  74. UIView *usernameview = [UIView new];
  75. usernameview.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  76. usernameview.userInteractionEnabled = YES;
  77. ViewRadius(usernameview, 5);
  78. // [backimage addSubview:usernameview];
  79. usernameview.sd_layout
  80. .leftSpaceToView(backimage, 45)
  81. .rightSpaceToView(backimage, 45)
  82. .heightIs(45)
  83. .topSpaceToView(logoimage, fitScreenHeight(65));
  84. UIImageView *usernameimage = [UIImageView new];
  85. [usernameimage setImage:[UIImage imageNamed:@"yh"]];
  86. [usernameimage setBackgroundColor:NewClearColor];
  87. [usernameview addSubview:usernameimage];
  88. usernameimage.sd_layout
  89. .centerYEqualToView(usernameview)
  90. .leftSpaceToView(usernameview, 15)
  91. .heightIs(16)
  92. .widthIs(16);
  93. [usernameview addSubview:self.account];
  94. _account.sd_layout
  95. .leftSpaceToView(usernameimage, 15)
  96. .heightIs(30)
  97. .centerYEqualToView(usernameview)
  98. .rightSpaceToView(usernameview, 15);
  99. //手机号码
  100. UIView *iponeNumView = [UIView new];
  101. iponeNumView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  102. iponeNumView.userInteractionEnabled = YES;
  103. ViewRadius(iponeNumView, 5);
  104. [backimage addSubview:iponeNumView];
  105. iponeNumView.sd_layout
  106. .leftSpaceToView(backimage, 45)
  107. .rightSpaceToView(backimage, 45)
  108. .heightIs(45)
  109. .topSpaceToView(logoimage, fitScreenHeight(65));
  110. UIImageView *iponeNumimage = [UIImageView new];
  111. [iponeNumimage setImage:[UIImage imageNamed:@"sj"]];
  112. [iponeNumimage setBackgroundColor:NewClearColor];
  113. [iponeNumView addSubview:iponeNumimage];
  114. iponeNumimage.sd_layout
  115. .centerYEqualToView(iponeNumView)
  116. .leftSpaceToView(iponeNumView, 15)
  117. .heightIs(20)
  118. .widthIs(17);
  119. [iponeNumView addSubview:self.iphoneNumber];
  120. _iphoneNumber.sd_layout
  121. .leftSpaceToView(iponeNumimage, 15)
  122. .heightIs(30)
  123. .centerYEqualToView(iponeNumimage)
  124. .rightSpaceToView(iponeNumView, 15);
  125. //验证码
  126. UIView *yanzhenmaView = [UIView new];
  127. yanzhenmaView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  128. yanzhenmaView.userInteractionEnabled = YES;
  129. ViewRadius(yanzhenmaView, 5);
  130. [backimage addSubview:yanzhenmaView];
  131. yanzhenmaView.sd_layout
  132. .leftSpaceToView(backimage, 45)
  133. .rightSpaceToView(backimage, 45)
  134. .heightIs(45)
  135. .topSpaceToView(iponeNumView, 15);
  136. UIImageView *yanzhenmaimage = [UIImageView new];
  137. [yanzhenmaimage setImage:[UIImage imageNamed:@"yz"]];
  138. [yanzhenmaimage setBackgroundColor:NewClearColor];
  139. [yanzhenmaView addSubview:yanzhenmaimage];
  140. yanzhenmaimage.sd_layout
  141. .centerYEqualToView(yanzhenmaView)
  142. .leftSpaceToView(yanzhenmaView, 15)
  143. .heightIs(20)
  144. .widthIs(18);
  145. [yanzhenmaView addSubview:self.yanzhenma];
  146. self.yanzhenma.sd_layout
  147. .leftSpaceToView(yanzhenmaimage, 15)
  148. .heightIs(30)
  149. .centerYEqualToView(yanzhenmaimage)
  150. .rightSpaceToView(yanzhenmaView, 80);
  151. verificationCodeButton = [UIButton new];
  152. [verificationCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
  153. [verificationCodeButton setTitleColor:[UIColor colorWithString:@"#2987DE"] forState:UIControlStateNormal];
  154. verificationCodeButton.titleLabel.font = NewFont(13);
  155. verificationCodeButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  156. NewTouchUpInside(verificationCodeButton, touchVerificationCode:);
  157. [yanzhenmaView addSubview:verificationCodeButton];
  158. verificationCodeButton.sd_layout
  159. .centerYEqualToView(yanzhenmaView)
  160. .rightSpaceToView(yanzhenmaView, 10)
  161. .heightIs(15)
  162. .widthIs(80);
  163. //第一次密码
  164. UIView *passwordView = [UIView new];
  165. passwordView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  166. passwordView.userInteractionEnabled = YES;
  167. ViewRadius(passwordView, 5);
  168. [backimage addSubview:passwordView];
  169. passwordView.sd_layout
  170. .leftSpaceToView(backimage, 45)
  171. .rightSpaceToView(backimage, 45)
  172. .heightIs(45)
  173. .topSpaceToView(yanzhenmaView, 15);
  174. UIImageView *passwordimage = [UIImageView new];
  175. [passwordimage setImage:[UIImage imageNamed:@"mm"]];
  176. [passwordimage setBackgroundColor:NewClearColor];
  177. [passwordView addSubview:passwordimage];
  178. passwordimage.sd_layout
  179. .centerYEqualToView(passwordView)
  180. .leftSpaceToView(passwordView, 15)
  181. .heightIs(19)
  182. .widthIs(16);
  183. [passwordView addSubview:self.password];
  184. _password.sd_layout
  185. .leftSpaceToView(passwordimage, 15)
  186. .heightIs(30)
  187. .centerYEqualToView(passwordimage)
  188. .rightSpaceToView(passwordView, 15);
  189. //第二次密码
  190. UIView *querenpasswordView = [UIView new];
  191. querenpasswordView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  192. querenpasswordView.userInteractionEnabled = YES;
  193. ViewRadius(querenpasswordView, 5);
  194. [backimage addSubview:querenpasswordView];
  195. querenpasswordView.sd_layout
  196. .leftSpaceToView(backimage, 45)
  197. .rightSpaceToView(backimage, 45)
  198. .heightIs(45)
  199. .topSpaceToView(passwordView, 15);
  200. UIImageView *querenpasswordimage = [UIImageView new];
  201. [querenpasswordimage setImage:[UIImage imageNamed:@"qr"]];
  202. [querenpasswordimage setBackgroundColor:NewClearColor];
  203. [querenpasswordView addSubview:querenpasswordimage];
  204. querenpasswordimage.sd_layout
  205. .centerYEqualToView(querenpasswordView)
  206. .leftSpaceToView(querenpasswordView, 15)
  207. .heightIs(19)
  208. .widthIs(16);
  209. [querenpasswordView addSubview:self.querenpassword];
  210. _querenpassword.sd_layout
  211. .leftSpaceToView(querenpasswordimage, 15)
  212. .heightIs(30)
  213. .centerYEqualToView(querenpasswordimage)
  214. .rightSpaceToView(querenpasswordView, 15);
  215. UIView *yhtypeView = [UIView new];
  216. yhtypeView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  217. yhtypeView.userInteractionEnabled = YES;
  218. ViewRadius(yhtypeView, 5);
  219. [backimage addSubview:yhtypeView];
  220. yhtypeView.sd_layout
  221. .leftSpaceToView(backimage, 45)
  222. .rightSpaceToView(backimage, 45)
  223. .heightIs(45)
  224. .topSpaceToView(querenpasswordView, 15);
  225. UIImageView *yhtype = [UIImageView new];
  226. [yhtype setImage:[UIImage imageNamed:@"用户类型"]];
  227. [yhtype setBackgroundColor:NewClearColor];
  228. [yhtypeView addSubview:yhtype];
  229. yhtype.sd_layout
  230. .centerYEqualToView(yhtypeView)
  231. .leftSpaceToView(yhtypeView, 15)
  232. .heightIs(19)
  233. .widthIs(16);
  234. _yhtypeStr = [UIButton new];
  235. [_yhtypeStr setTitle:yonghutype forState:UIControlStateNormal];
  236. [_yhtypeStr setTitleColor:[UIColor colorWithString:@"#9A9A9A"] forState:UIControlStateNormal];
  237. _yhtypeStr.titleLabel.font = NewFont(fitScreenWidth(12));
  238. NewTouchUpInside(_yhtypeStr, yhbuttoncilck);
  239. _yhtypeStr.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  240. [yhtypeView addSubview:_yhtypeStr];
  241. self.yhtypeStr.sd_layout
  242. .leftSpaceToView(yhtype, 15)
  243. .heightIs(30)
  244. .centerYEqualToView(yhtype)
  245. .rightSpaceToView(yhtypeView, 15);
  246. [backimage addSubview:confirm2 = [NewControlPackage buttonInitWithTitle:@"确 定" Frame:CGRectMake(0, 0, 0, 0) backgroundImage:nil backgroundImageHighlighted:nil backgroundColor:NewButtonColor textColor:NewWhiteColor textAlignment:UIControlContentHorizontalAlignmentCenter font:NewFont(14) tag:105 target:self action:@selector(touchConfirm) hidden:NO userInteractionEnabled:YES]];
  247. ViewRadius(confirm2, 8);
  248. confirm2.sd_layout
  249. .leftEqualToView(querenpasswordView)
  250. .bottomSpaceToView(backimage, 35)
  251. .heightIs(40)
  252. .rightEqualToView(querenpasswordView);
  253. }
  254. - (UITextField *)account
  255. {
  256. if (!_account)
  257. {
  258. _account = [UITextField new];
  259. [_account setBackgroundColor:[UIColor clearColor]];
  260. [_account setTextColor:NewGrayColor];
  261. [_account setPlaceholder:@"请输入用户名"];
  262. [_account setText:@""];
  263. [_account setFont:[UIFont systemFontOfSize:fitScreenWidth(12)]];
  264. [_account setSecureTextEntry:NO];
  265. [_account setKeyboardType:UIKeyboardTypeNumberPad];
  266. [_account setReturnKeyType:UIReturnKeyDefault];
  267. [_account addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  268. }
  269. return _account;
  270. }
  271. - (UITextField *)password
  272. {
  273. if (!_password)
  274. {
  275. _password = [UITextField new];
  276. [_password setBackgroundColor:[UIColor clearColor]];
  277. [_password setTextColor:[UIColor colorWithString:@"#9A9A9A"]];
  278. [_password setPlaceholder:@"请输入密码"];
  279. [_password setText:@""];
  280. [_password setFont:[UIFont systemFontOfSize:fitScreenWidth(12)]];
  281. [_password setSecureTextEntry:YES];
  282. [_password setKeyboardType:UIKeyboardTypeDefault];
  283. [_password setReturnKeyType:UIReturnKeyDefault];
  284. [_password addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  285. }
  286. return _password;
  287. }
  288. - (UITextField *)yanzhenma
  289. {
  290. if (!_yanzhenma)
  291. {
  292. _yanzhenma = [UITextField new];
  293. [_yanzhenma setBackgroundColor:[UIColor clearColor]];
  294. [_yanzhenma setTextColor:[UIColor colorWithString:@"#9A9A9A"]];
  295. [_yanzhenma setPlaceholder:@"请输入验证码"];
  296. [_yanzhenma setText:@""];
  297. [_yanzhenma setFont:[UIFont systemFontOfSize:fitScreenWidth(12)]];
  298. [_yanzhenma setSecureTextEntry:NO];
  299. [_yanzhenma setKeyboardType:UIKeyboardTypeDefault];
  300. [_yanzhenma setReturnKeyType:UIReturnKeyDefault];
  301. [_yanzhenma addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  302. }
  303. return _yanzhenma;
  304. }
  305. - (UITextField *)iphoneNumber
  306. {
  307. if (!_iphoneNumber)
  308. {
  309. _iphoneNumber = [UITextField new];
  310. [_iphoneNumber setBackgroundColor:[UIColor clearColor]];
  311. [_iphoneNumber setTextColor:[UIColor colorWithString:@"#9A9A9A"]];
  312. [_iphoneNumber setPlaceholder:@"请输入手机号码"];
  313. [_iphoneNumber setText:@""];
  314. [_iphoneNumber setFont:[UIFont systemFontOfSize:fitScreenWidth(12)]];
  315. [_iphoneNumber setSecureTextEntry:NO];
  316. [_iphoneNumber setKeyboardType:UIKeyboardTypeDefault];
  317. [_iphoneNumber setReturnKeyType:UIReturnKeyDefault];
  318. [_iphoneNumber addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  319. }
  320. return _iphoneNumber;
  321. }
  322. - (UITextField *)querenpassword
  323. {
  324. if (!_querenpassword)
  325. {
  326. _querenpassword = [UITextField new];
  327. [_querenpassword setBackgroundColor:[UIColor clearColor]];
  328. [_querenpassword setTextColor:[UIColor colorWithString:@"#9A9A9A"]];
  329. [_querenpassword setPlaceholder:@"请确认新密码"];
  330. [_querenpassword setText:@""];
  331. [_querenpassword setFont:[UIFont systemFontOfSize:fitScreenWidth(12)]];
  332. [_querenpassword setSecureTextEntry:YES];
  333. [_querenpassword setKeyboardType:UIKeyboardTypeDefault];
  334. [_querenpassword setReturnKeyType:UIReturnKeyDefault];
  335. [_querenpassword addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  336. }
  337. return _querenpassword;
  338. }
  339. #pragma mark - 作字符输入限制
  340. - (void)textFieldEditingChanged:(UITextField *)textField
  341. {
  342. /*
  343. @property (strong ,nonatomic) UITextField * account;
  344. @property (strong ,nonatomic) UITextField * iphoneNumber;
  345. @property (strong ,nonatomic) UITextField * yanzhenma;
  346. @property (strong ,nonatomic) UITextField * Customer;
  347. @property (strong ,nonatomic) UITextField * password;
  348. @property (strong ,nonatomic) UITextField * querenpassword;
  349. */
  350. if (textField == self.iphoneNumber) {
  351. if ([textField.text length]>11) {
  352. textField.text=[textField.text substringToIndex:11];//手机号码11位
  353. }
  354. }else if (textField == self.yanzhenma) {
  355. if ([textField.text length]>6) {
  356. textField.text=[textField.text substringToIndex:6];//验证码4位
  357. }
  358. }else if (textField == self.account) {
  359. if ([textField.text length]>6) {
  360. textField.text=[textField.text substringToIndex:6];//用户名
  361. }
  362. }else if (textField == self.password) {
  363. if ([textField.text length]>20) {
  364. textField.text=[textField.text substringToIndex:20];//第一次密码最多20位
  365. }
  366. }else if (textField == self.querenpassword) {
  367. if ([textField.text length]>20) {
  368. textField.text=[textField.text substringToIndex:20];//第二次密码最多20位
  369. }
  370. }
  371. }
  372. #pragma mark - 获取验证码
  373. - (void)touchVerificationCode:(UIButton *)sender
  374. {
  375. if (![self verification:@"校验手机号"]) {
  376. return;
  377. }
  378. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  379. verificationCodeButton.sd_layout
  380. .widthIs(fitScreenWidth(100));
  381. [MBProgressHUD showSuccess:@"短信已发送" toView:self.view];
  382. sender.frame = CGRectMake(sender.left, sender.top, 80, sender.height);
  383. [self verificationCode:60 sender:sender];
  384. return;
  385. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  386. [parameters safeSetObject:self.iphoneNumber.text forKey:@"mobile"];//手机号码
  387. [parameters safeSetObject:@"0" forKey:@"type"];//
  388. [NetworkRequestManager requestGetWithInterfacePrefix:JT_getResetMCode parameters:parameters onSuccess:^(id requestdict) {
  389. [MBProgressHUD hideHUDForView:self.view];
  390. if ([requestdict[@"error"] count] !=0) {
  391. for (NSDictionary *dic in requestdict[@"error"]) {
  392. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  393. verificationCodeButton.sd_layout
  394. .widthIs(fitScreenWidth(66));
  395. }
  396. }else{
  397. verificationCodeButton.sd_layout
  398. .widthIs(fitScreenWidth(100));
  399. [MBProgressHUD showSuccess:@"短信已发送" toView:self.view];
  400. sender.frame = CGRectMake(sender.left, sender.top, 80, sender.height);
  401. [self verificationCode:60 sender:sender];
  402. }
  403. } onFailure:^{
  404. [MBProgressHUD hideHUDForView:self.view];
  405. }];
  406. }
  407. - (BOOL)verification:(NSString *)status
  408. {
  409. if ([status isEqualToString:@"校验手机号"]) {
  410. if (self.iphoneNumber.text.length <= 0) {
  411. [self.view makeToast:@"请输入手机号码" duration:1.0 position:CSToastPositionCenter];
  412. return NO;
  413. }else if (self.iphoneNumber.text.length < 11){
  414. [self.view makeToast:@"手机号码输入有误" duration:1.0 position:CSToastPositionCenter];
  415. return NO;
  416. }
  417. }else if([status isEqualToString:@"个人注册"]){
  418. if (self.iphoneNumber.text.length < 11) {
  419. [self.view makeToast:@"手机号码输入有误" duration:1.5 position:CSToastPositionCenter];
  420. return NO;
  421. }
  422. if (self.yanzhenma.text.length <= 0) {
  423. [self.view makeToast:@"验证码输入有误" duration:1.5 position:CSToastPositionCenter];
  424. return NO;
  425. }
  426. if (self.password.text.length<6||self.querenpassword.text.length<6) {
  427. [self.view makeToast:@"新密码不能少于6位数" duration:1.5 position:CSToastPositionCenter];
  428. return NO;
  429. }
  430. if (self.password.text.length < 6) {
  431. [self.view makeToast:@"新密码输入有误" duration:1.5 position:CSToastPositionCenter];
  432. return NO;
  433. }
  434. if (self.querenpassword.text.length < 6) {
  435. [self.view makeToast:@"确认新密码输入有误" duration:1.5 position:CSToastPositionCenter];
  436. return NO;
  437. }
  438. if (![self.password.text isEqualToString:self.querenpassword.text]) {
  439. [self.view makeToast:@"设置密码和确认密码不同" duration:1.5 position:CSToastPositionCenter];
  440. return NO;
  441. }
  442. // if (self.account.text.length<=0) {
  443. // [self.view makeToast:@"用户名输入有误" duration:1.5 position:CSToastPositionCenter];
  444. // return NO;
  445. // }
  446. }
  447. return YES;
  448. }
  449. - (void)verificationCode:(NSInteger)code sender:(UIButton *)sender{
  450. NSString *str=[NSString stringWithFormat:@"%d秒后重新发送",(int)code];
  451. [sender setTitle:str forState:UIControlStateNormal];
  452. sender.enabled=NO;
  453. if (code==0) {
  454. sender.enabled=YES;
  455. [sender setTitle:@"获取验证码" forState:UIControlStateNormal];
  456. sender.frame = CGRectMake(sender.left, sender.top, 66, sender.height);
  457. return;
  458. }
  459. code--;
  460. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  461. [self verificationCode:code sender:sender];
  462. });
  463. }
  464. #pragma mark - 确认按钮
  465. - (void)touchConfirm
  466. {
  467. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  468. if (![self verification:@"个人注册"]) {
  469. return;
  470. }
  471. if ([yonghutype isEqualToString:@"请选择用户类型"]) {
  472. [MBProgressHUD showError:@"请先选择用户类型" toView:self.view];
  473. return;
  474. }
  475. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  476. [parameters safeSetObject:self.iphoneNumber.text forKey:@"mobile"];//手机号
  477. [parameters safeSetObject:self.password.text forKey:@"newPwd"];//密码
  478. [parameters safeSetObject:self.yanzhenma.text forKey:@"resetCode"];//短信验证码
  479. [parameters safeSetObject:self.account.text forKey:@"username"];//您的姓名
  480. if ([yonghutype isEqualToString:@"个人"]) {
  481. [parameters safeSetObject:@"0" forKey:@"type"];//
  482. }else if ([yonghutype isEqualToString:@"企业"]){
  483. [parameters safeSetObject:@"1" forKey:@"type"];//您的姓名
  484. }
  485. // [parameters safeSetObject:NewUDID forKey:@"uuid"];
  486. [NetworkRequestManager requestPostWithInterfacePrefix:JT_appResetPwd parameters:parameters onSuccess:^(id requestData) {
  487. [MBProgressHUD hideHUDForView:self.view];
  488. if ([requestData[@"error"] count] !=0) {
  489. for (NSDictionary *dic in requestData[@"error"]) {
  490. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  491. }
  492. }else{
  493. [MBProgressHUD showSuccess:@"修改密码成功" toView:self.view];
  494. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  495. NewPopViewController;
  496. });
  497. }
  498. } onFailure:^{
  499. [MBProgressHUD hideHUDForView:self.view];
  500. }];
  501. }
  502. - (void)fanhuiBTclick:(UIButton *)sender {
  503. NewPopViewController;
  504. }
  505. -(void)yhbuttoncilck
  506. {
  507. UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"用户类型" message:@"请选择用户类型" preferredStyle:UIAlertControllerStyleActionSheet];
  508. // 创建action,这里action1只是方便编写,以后再编程的过程中还是以命名规范为主
  509. UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"个人" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  510. yonghutype = @"个人";
  511. [_yhtypeStr setTitle:yonghutype forState:UIControlStateNormal];
  512. }];
  513. UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"企业" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  514. yonghutype = @"企业";
  515. [_yhtypeStr setTitle:yonghutype forState:UIControlStateNormal];
  516. }];
  517. UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  518. }];
  519. //把action添加到actionSheet里
  520. [actionSheet addAction:action1];
  521. [actionSheet addAction:action2];
  522. [actionSheet addAction:action3];
  523. //相当于之前的[actionSheet show];
  524. [self presentViewController:actionSheet animated:YES completion:nil];
  525. }
  526. - (void)didReceiveMemoryWarning {
  527. [super didReceiveMemoryWarning];
  528. // Dispose of any resources that can be recreated.
  529. }
  530. /*
  531. #pragma mark - Navigation
  532. // In a storyboard-based application, you will often want to do a little preparation before navigation
  533. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  534. // Get the new view controller using [segue destinationViewController].
  535. // Pass the selected object to the new view controller.
  536. }
  537. */
  538. @end