123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- //
- // RegistVC.m
- // jiaPei
- //
- // Created by apple on 2017/9/26.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #import "RegistVC.h"
- #import "RegistTestVC.h"
- @interface RegistVC ()
- {
- UITextField *phoneField;
- UITextField *pswField;
- UITextField *pswAgainField;
- }
- @end
- @implementation RegistVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self.view setBackgroundColor:[UIColor whiteColor]];
- self.title = @"注册账号";
- [self configNavigationBarDismissNav];
-
- UIImageView *imageV= [[UIImageView alloc] initWithFrame:kFrame];
- imageV.image = [UIImage imageNamed:@"login0.png"];
- [self.view addSubview:imageV];
-
-
-
- CGFloat y = 60;
- CGFloat h = 40;
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, y, 85, h)];
- [label setText:@"手机号" Font:FontTitle TextColor:kTitleColor];
- [self.view addSubview:label];
-
- UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(110, y, kSize.width - 125, h)];
- textField.borderStyle = UITextBorderStyleNone;
- textField.placeholder = @"请输入手机号";
- textField.font = [UIFont scaleSize:FontTitle];
- textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- textField.keyboardType = UIKeyboardTypeNumberPad;
- [self.view addSubview:textField];
- phoneField = textField;
-
- [textField addViewWithRect:CGRectMake(15, y+h, kSize.width - 30, 1.5)];
-
-
-
- y += h + 10;
- label = [[UILabel alloc] initWithFrame:CGRectMake(15, y, 85, h)];
- [label setText:@"密码" Font:FontTitle TextColor:kTitleColor];
- [self.view addSubview:label];
-
- textField = [[UITextField alloc] initWithFrame:CGRectMake(110, y, kSize.width - 125, h)];
- textField.borderStyle = UITextBorderStyleNone;
- textField.placeholder = @"6~20字符以内,字母或数字";
- textField.font = [UIFont scaleSize:FontTitle];
- textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- textField.secureTextEntry = YES;
- textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- [self.view addSubview:textField];
- pswField = textField;
-
- [textField addViewWithRect:CGRectMake(15, y+h, kSize.width - 30, 1.5)];
-
-
-
- y += h + 10;
- label = [[UILabel alloc] initWithFrame:CGRectMake(15, y, 85, h)];
- [label setText:@"确认密码" Font:FontTitle TextColor:kTitleColor];
- [self.view addSubview:label];
-
- textField = [[UITextField alloc] initWithFrame:CGRectMake(110, y, kSize.width - 125, h)];
- textField.borderStyle = UITextBorderStyleNone;
- textField.placeholder = @"请再次输入";
- textField.font = [UIFont scaleSize:FontTitle];
- textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- textField.secureTextEntry = YES;
- textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
- [self.view addSubview:textField];
- pswAgainField = textField;
-
- [textField addViewWithRect:CGRectMake(15, y+h, kSize.width - 30, 1.5)];
-
-
- y += h + 50;
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(15, y, kSize.width - 30, h)];
- btn.backgroundColor = defGreen;
- btn.layer.masksToBounds = YES;
- btn.layer.cornerRadius = 4;
- [btn setTitle:@"下一步" textColor:[UIColor whiteColor] font:FontTitle fotState:UIControlStateNormal];
- [btn target:self tag:1];
- [self.view addSubview:btn];
- }
- - (void)btnClick:(UIButton *)sender {
-
- [self.view endEditing:YES];
-
- if (phoneField.text.length < 1) {
- [self showMsgWithString:@"请输入手机号!"];
- return;
- }
- if (pswField.text.length < 1 || pswAgainField.text.length < 1) {
- [self showMsgWithString:@"请输入并确认密码!"];
- return;
- }
- if (![pswField.text isEqualToString:pswAgainField.text]) {
- [self showMsgWithString:@"两次密码输入不一致,请重试!"];
- pswField.text = @"";
- pswAgainField.text = @"";
- return;
- }
- NSString *regex = @"^[0-9A-Za-z]{6,20}$";
- NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
- BOOL result = [pred evaluateWithObject:pswField.text];
- if (!result) {
- [self showMsgWithString:@"请输入6~20字符以内的数字或字母密码!"];
- return;
- }
- if ([self isTooSimpleWithString:pswField.text]) {
- [self showMsgWithString:@"密码设置太简单,请重新设置!"];
- pswField.text = @"";
- pswAgainField.text = @"";
- return;
- }
-
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- //发送验证码
- RegistTestVC *vc = [[RegistTestVC alloc] init];
- vc.phoneString = phoneField.text;
- vc.passwordString = pswField.text;
- [self.navigationController pushViewController:vc animated:NO];
- }
- - (void)showMsgWithString:(NSString *)string {
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:string delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- }
- //判断是否是简单的叠字或者升降序列 是返回YES
- - (BOOL)isTooSimpleWithString:(NSString *)pswString {
-
- int differentInt = 100;
- for (int i = 1; i < pswString.length; i ++) {
- NSInteger number = [pswString characterAtIndex:i];
- NSInteger lastNumber = [pswString characterAtIndex:i - 1];
- // NSLog(@"---->>>>%d-%d = %d",number,lastNumber,differentInt);
- if (differentInt != number - lastNumber && differentInt != 100) {
- return NO;
- }else {
- differentInt = number - lastNumber;
- }
- }
- return YES;
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
-
- [self.view endEditing:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|