EditPhoneOrEmailVC.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. //
  2. // EditPhoneOrEmailVC.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/1.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "EditPhoneOrEmailVC.h"
  9. #import "TabBarController.h"
  10. @interface EditPhoneOrEmailVC ()<UITextFieldDelegate>
  11. @property (strong,nonatomic) IBOutlet UILabel *pageTitleLabel;
  12. //绑定手机号/邮箱背景View
  13. @property (strong,nonatomic) IBOutlet UIView *bindingBgView;
  14. //更换手机号/邮箱背景View
  15. @property (strong,nonatomic) IBOutlet UIView *changeBgView;
  16. @property (strong,nonatomic) IBOutlet UIImageView *bindingShowImgView;
  17. @property (strong,nonatomic) IBOutlet UILabel *bindingShowLabel;
  18. @property (strong,nonatomic) IBOutlet UIButton *bindingChangeBtn;
  19. @property (strong,nonatomic) IBOutlet UILabel *changeShowLabel;
  20. @property (strong,nonatomic) IBOutlet UITextField *changeOneTextField;
  21. @property (strong,nonatomic) IBOutlet UITextField *changeTwoTextField;
  22. @property (strong,nonatomic) IBOutlet UIButton *changeSendYZMBtn;
  23. @property (strong,nonatomic) IBOutlet UIButton *sureBtn;
  24. @end
  25. @implementation EditPhoneOrEmailVC
  26. +(EditPhoneOrEmailVC *)initEditPhoneOrEmailVC{
  27. EditPhoneOrEmailVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"EditPhoneOrEmailVC"];
  28. return controller;
  29. }
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. self.fd_prefersNavigationBarHidden = YES;
  33. self.bindingChangeBtn.layer.masksToBounds = YES;
  34. self.bindingChangeBtn.layer.cornerRadius = 8.0;
  35. self.sureBtn.layer.masksToBounds = YES;
  36. self.sureBtn.layer.cornerRadius = 8.0;
  37. WS(weakSelf);
  38. if(self.pageType == BindingOrChangePhoneOrEmailPageType1){
  39. self.pageTitleLabel.text = @"绑定手机号";
  40. self.bindingBgView.hidden = NO;
  41. self.changeBgView.hidden = YES;
  42. self.bindingShowImgView.image = [UIImage imageNamed:@"my_edit_phoneOrEmail_icon"];
  43. self.bindingShowLabel.text = [NSString stringWithFormat:@"绑定的手机号:%@",[AppUserModel sharedAppUserModel].Phone];
  44. [self.bindingChangeBtn setTitle:@"更换手机号" forState:UIControlStateNormal];
  45. [self.bindingChangeBtn setAction:^{
  46. EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC];
  47. vc.pageType = BindingOrChangePhoneOrEmailPageType3;
  48. [weakSelf.navigationController pushViewController:vc animated:YES];
  49. }];
  50. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType2){
  51. self.pageTitleLabel.text = @"绑定邮箱";
  52. self.bindingBgView.hidden = NO;
  53. self.changeBgView.hidden = YES;
  54. self.bindingShowImgView.image = [UIImage imageNamed:@"my_edit_phoneOrEmail_icon"];
  55. [self.bindingChangeBtn setTitle:@"更换邮箱" forState:UIControlStateNormal];
  56. self.bindingShowLabel.text = [NSString stringWithFormat:@"绑定的邮箱:%@",[AppUserModel sharedAppUserModel].Email];
  57. [self.bindingChangeBtn setAction:^{
  58. EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC];
  59. vc.pageType = BindingOrChangePhoneOrEmailPageType4;
  60. [weakSelf.navigationController pushViewController:vc animated:YES];
  61. }];
  62. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType3){
  63. self.pageTitleLabel.text = @"更换手机号";
  64. self.bindingBgView.hidden = YES;
  65. self.changeBgView.hidden = NO;
  66. self.changeShowLabel.text = @"输入新手机号并验证后即可更换手机号";
  67. self.changeOneTextField.text = @"";
  68. self.changeOneTextField.delegate = self;
  69. self.changeOneTextField.placeholder = @"请输入手机号";
  70. self.changeOneTextField.textColor = RGB(51, 51, 51);
  71. [self.changeOneTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  72. NSAttributedString *attrStringONE = [[NSAttributedString alloc] initWithString:self.changeOneTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.changeOneTextField.font}];
  73. self.changeOneTextField.attributedPlaceholder = attrStringONE;
  74. [self.changeSendYZMBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  75. self.changeTwoTextField.text = @"";
  76. self.changeTwoTextField.delegate = self;
  77. self.changeTwoTextField.placeholder = @"请输入验证码";
  78. self.changeTwoTextField.textColor = RGB(51, 51, 51);
  79. [self.changeTwoTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  80. NSAttributedString *attrStringTWO = [[NSAttributedString alloc] initWithString:self.changeTwoTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.changeTwoTextField.font}];
  81. self.changeTwoTextField.attributedPlaceholder = attrStringTWO;
  82. [self.sureBtn setAction:^{
  83. [weakSelf modiPhoneCommitData];
  84. }];
  85. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType4){
  86. self.pageTitleLabel.text = @"更换邮箱";
  87. self.bindingBgView.hidden = YES;
  88. self.changeBgView.hidden = NO;
  89. self.changeShowLabel.text = @"输入新邮箱并验证后即可更换绑定邮箱";
  90. self.changeOneTextField.text = @"";
  91. self.changeOneTextField.delegate = self;
  92. self.changeOneTextField.placeholder = @"请输入新邮箱";
  93. self.changeOneTextField.textColor = RGB(51, 51, 51);
  94. [self.changeOneTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  95. NSAttributedString *attrStringONE = [[NSAttributedString alloc] initWithString:self.changeOneTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.changeOneTextField.font}];
  96. self.changeOneTextField.attributedPlaceholder = attrStringONE;
  97. [self.changeSendYZMBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  98. self.changeTwoTextField.text = @"";
  99. self.changeTwoTextField.delegate = self;
  100. self.changeTwoTextField.placeholder = @"请输入验证码";
  101. self.changeTwoTextField.textColor = RGB(51, 51, 51);
  102. [self.changeTwoTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  103. NSAttributedString *attrStringTWO = [[NSAttributedString alloc] initWithString:self.changeTwoTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.changeTwoTextField.font}];
  104. self.changeTwoTextField.attributedPlaceholder = attrStringTWO;
  105. [self.sureBtn setAction:^{
  106. [weakSelf modiEMailCommitData];
  107. }];
  108. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType5){
  109. self.pageTitleLabel.text = @"绑定手机号";
  110. self.bindingBgView.hidden = YES;
  111. self.changeBgView.hidden = NO;
  112. self.changeShowLabel.text = @"输入手机号并验证后即可绑定手机号";
  113. self.changeOneTextField.text = @"";
  114. self.changeOneTextField.delegate = self;
  115. self.changeOneTextField.placeholder = @"请输入手机号";
  116. self.changeOneTextField.textColor = RGB(51, 51, 51);
  117. [self.changeOneTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  118. NSAttributedString *attrStringONE = [[NSAttributedString alloc] initWithString:self.changeOneTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.changeOneTextField.font}];
  119. self.changeOneTextField.attributedPlaceholder = attrStringONE;
  120. [self.changeSendYZMBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
  121. self.changeTwoTextField.text = @"";
  122. self.changeTwoTextField.delegate = self;
  123. self.changeTwoTextField.placeholder = @"请输入验证码";
  124. self.changeTwoTextField.textColor = RGB(51, 51, 51);
  125. [self.changeTwoTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  126. NSAttributedString *attrStringTWO = [[NSAttributedString alloc] initWithString:self.changeTwoTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.changeTwoTextField.font}];
  127. self.changeTwoTextField.attributedPlaceholder = attrStringTWO;
  128. [self.sureBtn setAction:^{
  129. if (weakSelf.openId.length > 0) {
  130. [weakSelf modiWinXin:weakSelf.openId];
  131. }
  132. }];
  133. }
  134. }
  135. -(void)startTime{
  136. __block int timeout = 60; //倒计时时间
  137. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  138. dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
  139. dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
  140. dispatch_source_set_event_handler(_timer, ^{
  141. if(timeout <= 0){ //倒计时结束,关闭
  142. dispatch_source_cancel(_timer);
  143. WS(weakSelf);
  144. dispatch_async(dispatch_get_main_queue(), ^{
  145. //设置界面的按钮显示 根据自己需求设置 特别注明:UI的改变一定要在主线程中进行
  146. //倒计时完成,恢复到原来的效果
  147. NSString *text = @"获取验证码";
  148. weakSelf.changeSendYZMBtn.enabled = YES;
  149. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateNormal];
  150. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateHighlighted];
  151. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateSelected];
  152. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateDisabled];
  153. [weakSelf.changeSendYZMBtn setTitleColor:RGB(37, 138, 220) forState:UIControlStateNormal];
  154. [weakSelf.changeSendYZMBtn.titleLabel setFont:[UIFont systemFontOfSize:13]];
  155. [weakSelf.changeSendYZMBtn setEnabled:YES];
  156. });
  157. }else{
  158. int seconds = timeout % 60;
  159. if(seconds == 0&&timeout==60){
  160. seconds = 60;
  161. }
  162. // NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
  163. WS(weakSelf);
  164. dispatch_async(dispatch_get_main_queue(), ^{
  165. //设置界面的按钮显示 根据自己需求设置
  166. // NSLog(@"____%@",strTime);
  167. weakSelf.changeSendYZMBtn.enabled = NO;
  168. NSString *text = [NSString stringWithFormat:@"重新获取(%lus)",(unsigned long)seconds];
  169. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateNormal];
  170. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateHighlighted];
  171. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateSelected];
  172. [weakSelf.changeSendYZMBtn setTitle:text forState:UIControlStateDisabled];
  173. [weakSelf.changeSendYZMBtn.titleLabel setFont:[UIFont systemFontOfSize:13]];
  174. [weakSelf.changeSendYZMBtn setTitleColor:RGB(37, 138, 220) forState:UIControlStateNormal];
  175. });
  176. timeout--;
  177. }
  178. });
  179. dispatch_resume(_timer);
  180. }
  181. - (IBAction)verifyCodeAction:(UIButton *)sender {
  182. [self.view endEditing:YES];
  183. if(self.pageType == BindingOrChangePhoneOrEmailPageType1){
  184. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType2){
  185. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType3){
  186. [self modiPhoneNumberSendCode];
  187. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType4){
  188. [self modiEMailberSendCode];
  189. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType5){
  190. [self bandWXSendCode];
  191. }
  192. }
  193. #pragma mark - 修改手机号
  194. /// 修改手机号发送验证码
  195. - (void)bandWXSendCode
  196. {
  197. if (self.changeOneTextField.text.length == 0) {
  198. SHOWERROR(@"请输入正确手机号码");
  199. return;
  200. }
  201. NSLog(@"⚠️ 更换手机获取验证码 %@",self.changeOneTextField.text);
  202. SHOWLOADING
  203. WS(weakSelf);
  204. [[HttpManager sharedHttpManager] GETUrl:Host(LoginSendCodeGet) parameters:@{@"phone":self.changeOneTextField.text} responseStyle:DATA success:^(id _Nonnull responseObject) {
  205. REMOVESHOW
  206. [weakSelf startTime];
  207. } failure:^(NSError * _Nonnull error) {
  208. REMOVESHOW
  209. SHOWERROR([ZYCTool handerResultData:error]);
  210. }];
  211. }
  212. - (void)modiPhoneNumberSendCode{
  213. if (self.changeOneTextField.text.length == 0) {
  214. SHOWERROR(@"请输入正确手机号码");
  215. return;
  216. }
  217. NSLog(@"⚠️ 更换手机获取验证码 %@",self.changeOneTextField.text);
  218. SHOWLOADING
  219. WS(weakSelf);
  220. [[HttpManager sharedHttpManager] GETUrl:Host(Modify_UserPhone_SendCode_Post) parameters:@{@"phone":self.changeOneTextField.text} responseStyle:DATA success:^(id _Nonnull responseObject) {
  221. REMOVESHOW
  222. [weakSelf startTime];
  223. } failure:^(NSError * _Nonnull error) {
  224. REMOVESHOW
  225. // SHOWERROR([ZYCTool handerResultData:error]);
  226. }];
  227. }
  228. /// 修改手机号 提交数据
  229. - (void)modiPhoneCommitData{
  230. if (self.changeOneTextField.text.length != 11) {
  231. SHOWERROR(@"请输入正确手机号码");
  232. return;
  233. }
  234. if (self.changeTwoTextField.text.length != 6) {
  235. SHOWERROR(@"请输入正确验证码");
  236. return;
  237. }
  238. SHOWLOADING
  239. WEAKSELF
  240. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserPhone_Post] parameters:@{@"phone":self.changeOneTextField.text,@"code":self.changeTwoTextField.text} responseStyle:DATA success:^(id _Nonnull responseObject) {
  241. [UserManager getUserInfoDetailSuccess:^(id _Nonnull responseObject) {
  242. REMOVESHOW
  243. STRONGSELF
  244. // [strongSelf.navigationController popToRootViewControllerAnimated:YES];
  245. NSLog(@"-=-=-=-=-=-=-%@",strongSelf.navigationController.viewControllers);
  246. [strongSelf.navigationController popToViewController:strongSelf.navigationController.viewControllers[1] animated:YES];
  247. } failure:^(NSError * _Nonnull error) {
  248. REMOVESHOW
  249. SHOWERROR([ZYCTool handerResultData:error]);
  250. }];
  251. } failure:^(NSError * _Nonnull error) {
  252. REMOVESHOW
  253. SHOWERROR([ZYCTool handerResultData:error]);
  254. }];
  255. }
  256. #pragma mark - 修改邮箱
  257. /// 修改邮箱 发送验证码
  258. - (void)modiEMailberSendCode{
  259. if (![self.changeOneTextField.text isEmailAddress]) {
  260. SHOWERROR(@"请输入正确邮箱地址");
  261. return;
  262. }
  263. NSLog(@"⚠️ 更换邮箱获取验证码 %@",self.changeOneTextField.text);
  264. SHOWLOADING
  265. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserEMail_SendCode_Post] parameters:@{@"email":self.changeOneTextField.text} responseStyle:DATA success:^(id _Nonnull responseObject) {
  266. REMOVESHOW
  267. [self startTime];
  268. } failure:^(NSError * _Nonnull error) {
  269. REMOVESHOW
  270. SHOWERROR([ZYCTool handerResultData:error])
  271. }];
  272. }
  273. /// 修改邮箱 提交数据
  274. - (void)modiEMailCommitData{
  275. if (![self.changeOneTextField.text isEmailAddress]) {
  276. SHOWERROR(@"请输入正确邮箱地址");
  277. return;
  278. }
  279. if (self.changeTwoTextField.text.length != 6) {
  280. SHOWERROR(@"请输入正确验证码");
  281. return;
  282. }
  283. SHOWLOADING
  284. WEAKSELF
  285. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserEMail_Post] parameters:@{@"email":self.changeOneTextField.text,@"code":self.changeTwoTextField.text} responseStyle:DATA success:^(id _Nonnull responseObject) {
  286. [UserManager getUserInfoDetailSuccess:^(id _Nonnull responseObject) {
  287. REMOVESHOW
  288. STRONGSELF
  289. NSLog(@"%@",strongSelf.navigationController.viewControllers);
  290. for ( int i = 0 ;i< strongSelf.navigationController.viewControllers.count;i++) {
  291. if ([strongSelf.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyInfoVC")]) {
  292. [strongSelf.navigationController popToViewController:strongSelf.navigationController.viewControllers[i] animated:YES];
  293. return;
  294. }
  295. }
  296. } failure:^(NSError * _Nonnull error) {
  297. REMOVESHOW
  298. SHOWERROR([ZYCTool handerResultData:error])
  299. }];
  300. } failure:^(NSError * _Nonnull error) {
  301. REMOVESHOW
  302. SHOWERROR([ZYCTool handerResultData:error])
  303. }];
  304. }
  305. #pragma mark - 绑定微信
  306. - (void)modiWinXin:(NSString *)openId{
  307. if (self.changeOneTextField.text.length != 11) {
  308. SHOWERROR(@"请输入正确手机号码");
  309. return;
  310. }
  311. if (self.changeTwoTextField.text.length != 6) {
  312. SHOWERROR(@"请输入正确验证码");
  313. return;
  314. }
  315. SHOWLOADING
  316. WEAKSELF
  317. [[HttpManager sharedHttpManager] POSTUrl:Host(API_App_Set_Opend_Id) parameters:@{@"Phone":self.changeOneTextField.text,@"Code":self.changeTwoTextField.text,@"OpenId":openId} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  318. REMOVESHOW
  319. NSDictionary *dic = responseObject;
  320. USERDEFAULTSSET(dic[@"Token"][@"Expires"],@"tokenExpires");
  321. NSString *token = [NSString stringWithFormat:@"%@ %@",dic[@"Token"][@"Type"],dic[@"Token"][@"Token"]];
  322. USERDEFAULTSSET(token,@"LOGINTOKEN");
  323. NSLog(@"登录成功之后的token%@\n%@",kToken,token);
  324. USERDEFAULTSSET(dic[@"UserId"],@"userId");
  325. [weakSelf getUserInfoDetail];
  326. } failure:^(NSError * _Nonnull error) {
  327. REMOVESHOW
  328. SHOWERROR([ZYCTool handerResultData:error])
  329. }];
  330. }
  331. - (void)getUserInfoDetail{
  332. SHOWLOADING
  333. WEAKSELF
  334. NSLog(@"%@",kUserId);
  335. [[HttpManager sharedHttpManager].manager.requestSerializer setValue:[UserManager token] forHTTPHeaderField:@"Authorization"];
  336. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,UserDetailGet] parameters:@{} success:^(id _Nonnull responseObject) {
  337. NSLog(@"%@",responseObject);
  338. AppUserModel * model = [[AppUserModel alloc] initWithDictionary:responseObject error:nil];
  339. [model saveUserInfor];
  340. REMOVESHOW
  341. [weakSelf changeToHome];
  342. NSData * data = [NSKeyedArchiver archivedDataWithRootObject:model];
  343. USERDEFAULTSSET(data,@"USERINFO");
  344. //在这里登陆环信
  345. [[EaseSDKHelper shareHelper] loginEaseWithUsername:model.ImId password:@"123456"];
  346. } failure:^(NSError * _Nonnull error) {
  347. REMOVESHOW
  348. SHOWERROR([ZYCTool handerResultData:error])
  349. }];
  350. }
  351. -(void)changeToHome{
  352. UIWindow *window = [UtilsTools getWindow];
  353. window.rootViewController = [TabBarController sharedTabBarController];
  354. [[TabBarController sharedTabBarController] setSelectedIndex:0];
  355. [window makeKeyAndVisible];
  356. }
  357. /****************************************************/
  358. #pragma mark - UITextFieldDelegate
  359. /****************************************************/
  360. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  361. // NSString *tempString = [textField.text stringByReplacingCharactersInRange:range withString:string];
  362. if ([string isEqualToString:@""] || [string isEqualToString:@"\n"]) {
  363. return YES;
  364. }
  365. NSString *regex = @"[\u4e00-\u9fa5]{0,}$"; // 中文
  366. NSPredicate *predicateRe1 = [NSPredicate predicateWithFormat:@"self matches %@", regex];
  367. // 3、匹配字符串
  368. BOOL resualt = [predicateRe1 evaluateWithObject:string];
  369. if (resualt)
  370. {
  371. return NO;
  372. }
  373. return YES;
  374. }
  375. - (void)textFieldDidEndEditing:(UITextField *)textField{
  376. if (self.pageType == BindingOrChangePhoneOrEmailPageType3){
  377. }else if (self.pageType == BindingOrChangePhoneOrEmailPageType4){
  378. }
  379. }
  380. -(void)textFieldDidChange:(UITextField *)textField{
  381. if (textField.text.length > 20) {
  382. textField.text = [textField.text substringToIndex:20];
  383. }
  384. }
  385. - (BOOL)textFieldShouldReturn:(UITextField *)textField{
  386. [textField resignFirstResponder];
  387. return YES;
  388. }
  389. - (void)viewWillDisappear:(BOOL)animated
  390. {
  391. [super viewWillDisappear:animated];
  392. }
  393. @end