//
//  LoginViewController.m
//  Open
//
//  Created by gao on 2017/2/8.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "LoginViewController.h"
#import "AppDelegate.h"
#import "UITextField+Shake.h"
#import "logViewController.h"
#import "kankanshebaoxieyi.h"
#import "FandRViewController.h"
#import "NSString+DecryptUseDES.h"
@interface LoginViewController ()<UITextFieldDelegate,CLKeyboardOffsetViewDelegate>
@property(nonatomic,strong)	 UIImageView* viewBackGround;
@property(nonatomic,strong)	 UIImageView *nameImage;
@property(nonatomic,strong)	 UIImageView *passwordImage;
@property(nonatomic,strong)	 UIImageView *lineImage;
@property(nonatomic,strong)	 UIImageView  *lineImage2;
@property(nonatomic,strong)     UIImageView  *lineImage3;
@property(nonatomic,strong)     UIImageView  *lineImage4;
@property(nonatomic,strong)	 UIButton *buttonForLog;
@property(nonatomic,strong)	 UIButton *ForgetPassWorldLabel;
@property(nonatomic,strong)     UIButton *timeLabel;
@property(nonatomic,strong)	 UIButton *RegisterPasswordLabel;
@property(nonatomic,strong) UIButton *freeRegistrationLabel;
@property(nonatomic,strong)  UIButton *emailLabel;
@property(nonatomic,strong)	 UITextField *textField1;
@property(nonatomic,strong)	 UITextField *textField2;
@property(nonatomic,strong)	 UILabel *LABEL;

@property(nonatomic,strong) UIButton* ThirdPartyWeChat;
@property(nonatomic,strong) UIButton *ThirdPartyQQ;
@property(nonatomic,strong) UIButton *ThirdPartyWeiBo;

//界面二
@property(nonatomic,strong)UIButton *back;
@property(nonatomic,strong)UIButton *back_2;
@property(nonatomic,strong)UILabel *registLabelTwo;
@property(nonatomic,strong)UILabel *weixinLabel;
@property(nonatomic,strong)UIView *registerView;
@property(nonatomic,strong)	 UIImageView *telephoneRE;
@property(nonatomic,strong)	 UIImageView *passwordRE;
@property(nonatomic,strong)	 UIButton *buttonForLogRE;
@property(nonatomic,strong)	 UITextField *textField1RE;
@property(nonatomic,strong)	 UITextField *textField2RE;
@property(nonatomic,strong)UIButton *verificationCodeButton;
@property(nonatomic,strong)	 UITextField *textField_1_RE;
@property(nonatomic,strong)	 UITextField *textField_2_RE;
@property(assign, nonatomic) NSInteger timeCount;
@property(strong, nonatomic) NSTimer *timer;
@property(nonatomic ,strong)NSString *code;//验证码
//服务协议的代码
@property(nonatomic,strong)UIButton *fuwuxiyiButton;
@property(nonatomic,strong)UIButton *fuwuxiyiLabel;
@property(nonatomic,strong)UIButton *fuwuxiyiLabel2;
@property(nonatomic)BOOL isFuWu;


//界面三
@property(nonatomic,strong)UIView *passView;
@property(nonatomic,strong)	 UITextField *textField1PSS;
@property(nonatomic,strong)	 UITextField *textField2PSS;
@property(nonatomic,strong)UIButton *buttonTranslateMain;

//获取验证码的code
@property(nonatomic,strong)logNetModel *logVM;
@property(nonatomic,strong)logViewController *logVC;
@property(nonatomic)BOOL changeBut;
//

@property (nonatomic,copy)NSString * phoneNumStr;
@property (nonatomic,copy)NSString * timeStr;


@property (nonatomic, strong)UIImageView *lineImage11;
@property (nonatomic, strong)UIImageView *lineImage22;

@end
//判断两者的关系

@implementation LoginViewController
-(UILabel *)LABEL
{
    if (!_LABEL) {
        _LABEL=[[UILabel alloc]init];
    }
    return _LABEL;
}


+ (LoginViewController *)sharedInstance{
    static LoginViewController *p = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        p = [LoginViewController new];
    });
    return p;
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    self.navigationController.navigationBar.translucent = YES;
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:27/255.0 green:132/255.0 blue:208/255.0 alpha:1.0]];
    

    
  
    
}
- (NSDate *)getCustomDateWithHour:(NSInteger)hour
{
    
        //获取当前时间

    NSDate * destinationDateNow = [NSDate
                                   date];
       
    NSCalendar *currentCalendar = [[NSCalendar
                                    alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    
        NSDateComponents *currentComps = [[NSDateComponents
                                           alloc]
                                          init];
    
        NSInteger unitFlags =
    NSCalendarUnitYear | NSCalendarUnitMonth |
    NSCalendarUnitDay | NSCalendarUnitHour |
    NSCalendarUnitMinute | NSCalendarUnitSecond;
    
        
        currentComps = [currentCalendar
                        components:unitFlags
                        fromDate:destinationDateNow];
    
        
    
        //设置当前的时间点
    
        NSDateComponents *resultComps = [[NSDateComponents
                                          alloc]
                                         init];
        [resultComps
         setYear:[currentComps
                  year]];
        [resultComps
         setMonth:[currentComps
                   month]];
        [resultComps
         setDay:[currentComps
                 day]];
        [resultComps
         setHour:hour];
    
        
       
    NSCalendar *resultCalendar = [[NSCalendar
                                   alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
       
    return [resultCalendar
            dateFromComponents:resultComps];
}


//获取时间段
-(NSString *)getTheTimeBucket
{
    
    //    NSDate * currentDate = [self getNowDateFromatAnDate:[NSDate date]];

    NSDate * currentDate = [NSDate
                            date];
    if ([currentDate compare:[self getCustomDateWithHour:0]] ==NSOrderedDescending && [currentDate compare:[self getCustomDateWithHour:9]] == NSOrderedAscending)
{ return @"早上好!";
    
} else if([currentDate
              compare:[self
                       getCustomDateWithHour:9]] ==
             NSOrderedDescending && [currentDate
                                     compare:[self
                                              getCustomDateWithHour:11]] ==
             NSOrderedAscending)
       {
            return @"上午好!";} else if ([currentDate
              compare:[self
                       getCustomDateWithHour:11]] ==
             NSOrderedDescending && [currentDate
                                     compare:[self
                                              getCustomDateWithHour:13]] ==
             NSOrderedAscending)
{
 return @"中午好!";
}
else if ([currentDate
              compare:[self
                       getCustomDateWithHour:13]] ==
             NSOrderedDescending && [currentDate
                                     compare:[self
                                              getCustomDateWithHour:18]] ==
             NSOrderedAscending)
{
return @"下午好!";}
else
{
return @"晚上好!";}
}


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.view openKeyboardOffsetView];
  
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
            [self zhiwenJieSuo];
    self.thirdStr=@"";
        self.ThirdPartyQQ.hidden =YES; //NO->YES
        self.ThirdPartyWeChat.hidden =NO;
    self.isEnterNoCode =NO;
    if (_editText == YES) {
        
        [self jjj];
        
    }else
    {
        self.passView.hidden=YES;
        self.registerView.hidden =YES;
        self.view.backgroundColor=[UIColor whiteColor];
         [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor] ];
        
    }
  
   self.emailSender =NO;
    //内部版使用
//    double delayInSeconds = 0.3;
//    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);    //    dispatch_after(popTime,
//    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//        [_textField1 becomeFirstResponder];
//    });

}

-(void)buttonClick_1{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
-(void)textFieldAddTwoBlackPlaceinTextFiled:(UITextField *)textField
{
    UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(textField.frame.origin.x,textField.frame.origin.y,5.0, textField.frame.size.height)];
    textField.leftView = blankView;
    textField.leftViewMode =UITextFieldViewModeAlways;
}


#pragma mark - life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"我的";
    self.view.backgroundColor=[UIColor whiteColor];
    NSLog(@"%f",self.view.bounds.size.width);
    

    
   // [self textFieldAddTwoBlackPlaceinTextFiled:self.textField1];
   // [self textFieldAddTwoBlackPlaceinTextFiled:self.textField2];

    
        UIButton * button_2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button_2.frame = CGRectMake(0, 0, 49, 49);
    button_2.titleLabel.textAlignment =NSTextAlignmentLeft;
//    [button_2 setTitle:@"asdasd按时打发第三方" forState:UIControlStateNormal];
    [button_2 setImage:[UIImage imageNamed:@"928返回"] forState:UIControlStateNormal];
//    [button_2 setBackgroundColor:[UIColor redColor]];
//    [button_2 setTitleColor:[UIColor colorWithRed:12.0 green:12.0 blue:12.0 alpha:1] forState:UIControlStateNormal];
    [button_2 addTarget:self action:@selector(buttonClick_1) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * backButtonItem_2 = [[UIBarButtonItem alloc] initWithCustomView:button_2];
    
    
//    self.fuwuxiyiLabel2=[UIButton buttonWithType:UIButtonTypeCustom];
//    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"服务协议"];
//    NSRange strRange = {0,[str length]};
//    [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
//    [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:strRange];
//
//    [self.fuwuxiyiLabel2 setAttributedTitle:str forState:UIControlStateNormal];
//    [ self.fuwuxiyiLabel2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

    
    
    
    
    
    
    
    self.navigationItem.leftBarButtonItem = backButtonItem_2;
    
    [self.view addSubview:self.viewBackGround];
    [self.view addSubview:self.timeLabel];
    [self.view addSubview:self.nameImage];
    [self.view addSubview:self.lineImage];
    [self.view addSubview:self.passwordImage];
    [self.view addSubview:self.lineImage2];
    [self.view addSubview: self.buttonForLog];
   // [self.view addSubview:self.RegisterPasswordLabel];
    [self.view addSubview:self.ForgetPassWorldLabel];
    [self.view addSubview:self.freeRegistrationLabel];
    [self.view addSubview:self.weixinLabel];
    [self.view addSubview:self.lineImage4];
    [self.view addSubview:self.lineImage3];
    [self.view addSubview:self.ThirdPartyWeChat];
    //短信快速登入
    [self.view addSubview:self.emailLabel];
    [self.view addSubview:self.ThirdPartyQQ];
   
//
//    _ThirdPartyWeiBo =[UIButton buttonWithType:UIButtonTypeCustom];
//    [_ThirdPartyWeiBo setBackgroundImage:[UIImage imageNamed:@"微博"] forState:UIControlStateNormal];
//    [_ThirdPartyWeiBo addTarget:self action:@selector(tapWeiBo) forControlEvents:UIControlEventTouchUpInside];
//
//    [self.view addSubview:_ThirdPartyWeiBo];
//    [_ThirdPartyWeiBo mas_makeConstraints:^(MASConstraintMaker *make) {
//        //        make.height.mas_equalTo(10);
//        //   make.top.mas_equalTo(_buttonForLog.mas_bottom).mas_equalTo(25);
//
//        make.centerX.mas_equalTo(70);
//        make.top.mas_equalTo(_ForgetPassWorldLabel.mas_bottom).mas_equalTo(10);
//        make.size.mas_equalTo(CGSizeMake(50, 50));
//        //          make.size.mas_equalTo(CGSizeMake(50, 10));
//    }];
    
    [self.view addSubview:self.textField1];
    [self.view addSubview:self.textField2];
}

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    
    __weak __typeof__(self) weakSelf = self;
    [self.viewBackGround mas_makeConstraints:^(MASConstraintMaker *make) {
        
        if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
        {
            make.size.mas_equalTo(CGSizeMake(weakSelf.view.bounds.size.width-60, 55));
        }else{
            make.size.mas_equalTo(CGSizeMake(weakSelf.view.bounds.size.width-60, 75));
        }
        NSLog(@"%f",[UIScreen mainScreen].bounds.size.height);
        if(IS_IPhoneX_All){
            make.top.mas_equalTo(64+24);
        }else{
            make.top.mas_equalTo(64);
        }
        
        
        make.left.mas_equalTo(30);
        make.right.mas_equalTo(-30);
    }];
    
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
               // make.size.mas_equalTo(CGSizeMake(100, 10));
        make.top.mas_equalTo(weakSelf.viewBackGround.mas_bottom).mas_equalTo(15);
       make.leftMargin.mas_equalTo(weakSelf.viewBackGround.mas_leftMargin).mas_equalTo(15);
    }];
    [self.nameImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(0, 22));
        // make.top.mas_equalTo(_timeLabel.mas_bottom).mas_equalTo(45);
        if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
        {
            make.top.mas_equalTo(weakSelf.timeLabel.mas_bottom).mas_equalTo(10);
        }else{
            make.top.mas_equalTo(weakSelf.timeLabel.mas_bottom).mas_equalTo(25);
        }
        make.left.mas_equalTo(58);
    }];
    [self.lineImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(297, 1));
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(weakSelf.nameImage.mas_bottom).mas_equalTo(5);
    }];
    [self.passwordImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(0, 22));
        make.top.mas_equalTo(weakSelf.lineImage.mas_bottom).mas_equalTo(40);
        make.left.mas_equalTo(58);
    }];
    [self.lineImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(297, 1));
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(weakSelf.passwordImage.mas_bottom).mas_equalTo(5);
    }];
    [self.buttonForLog mas_makeConstraints:^(MASConstraintMaker *make) {
        //  make.size.mas_equalTo(CGSizeMake(309, 43));

        make.leftMargin.mas_equalTo(weakSelf.viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(weakSelf.viewBackGround.mas_rightMargin).mas_equalTo(0);
        make.height.mas_equalTo(43);
        make.centerX.mas_equalTo(0);


        if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
        {
            make.top.mas_equalTo(weakSelf.lineImage2.mas_bottom).mas_equalTo(50);
        }else{
            make.top.mas_equalTo(weakSelf.lineImage2.mas_bottom).mas_equalTo(60);
        }

    }];
   
//    [self.RegisterPasswordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        //make.size.mas_equalTo(CGSizeMake(309, 43));
//        // make.centerX.mas_equalTo(0);
//        make.bottom.mas_equalTo(weakSelf.buttonForLog.mas_top).mas_equalTo(-4);
//        make.leftMargin.mas_equalTo(weakSelf.buttonForLog.mas_leftMargin);
//        //
//    }];
    
    [self.emailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.centerX.mas_equalTo(70);
        make.topMargin.mas_equalTo(weakSelf.ForgetPassWorldLabel.mas_topMargin);
        make.leftMargin.mas_equalTo(weakSelf.buttonForLog.mas_leftMargin);
    }];
    
    [self.ForgetPassWorldLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.size.mas_equalTo(CGSizeMake(100, 10));/
        make.bottom.mas_equalTo(weakSelf.buttonForLog.mas_top).mas_equalTo(-4);
        make.rightMargin.mas_equalTo(weakSelf.buttonForLog.mas_rightMargin);
    }];
    
   
    
//    [self.freeRegistrationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        //        make.size.mas_equalTo(CGSizeMake(309, 43));
//        //        make.centerX.mas_equalTo(0);
//
//        make.top.mas_equalTo(weakSelf.buttonForLog.mas_bottom).mas_equalTo(10);
//        //make.leftMargin.mas_equalTo(_buttonForLog.mas_leftMargin);
//        make.centerX.mas_equalTo(0);
//        //
//    }];
    [self.weixinLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.ForgetPassWorldLabel.mas_bottom).mas_equalTo(80);
        make.centerX.mas_equalTo(0);

    }];
    [self.lineImage4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.leftMargin.mas_equalTo(weakSelf.buttonForLog.mas_leftMargin);

        make.right.mas_equalTo(weakSelf.weixinLabel.mas_left).mas_equalTo(-5);
        make.centerY.mas_equalTo(weakSelf.weixinLabel).mas_equalTo(0);
        //   make.top.mas_equalTo(_ForgetPassWorldLabel.mas_bottom).mas_equalTo(5);
    }];

    [self.lineImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.rightMargin.mas_equalTo(weakSelf.buttonForLog.mas_rightMargin);

        make.left.mas_equalTo(weakSelf.weixinLabel.mas_right).mas_equalTo(5);
        make.centerY.mas_equalTo(weakSelf.weixinLabel).mas_equalTo(0);
        //  make.top.mas_equalTo(_ForgetPassWorldLabel.mas_bottom).mas_equalTo(5);
    }];
    [self.ThirdPartyWeChat mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.height.mas_equalTo(10);
        //   make.top.mas_equalTo(_buttonForLog.mas_bottom).mas_equalTo(25);

        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.weixinLabel.mas_bottom).mas_equalTo(15);
        make.size.mas_equalTo(CGSizeMake(50, 50));
        //          make.size.mas_equalTo(CGSizeMake(50, 10));
    }];
   
//    [self.ThirdPartyQQ mas_makeConstraints:^(MASConstraintMaker *make) {
//        //        make.height.mas_equalTo(10);
//        //   make.top.mas_equalTo(_buttonForLog.mas_bottom).mas_equalTo(25);
//
//        make.centerX.mas_equalTo(70);
//        make.top.mas_equalTo(weakSelf.ForgetPassWorldLabel.mas_bottom).mas_equalTo(10);
//        make.size.mas_equalTo(CGSizeMake(50, 50));
//        //          make.size.mas_equalTo(CGSizeMake(50, 10));
//    }];


    [self.textField1 mas_makeConstraints:^(MASConstraintMaker *make) {
        //  make.size.mas_equalTo(CGSizeMake(280, 54));

        make.leftMargin.mas_equalTo(weakSelf.viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(weakSelf.viewBackGround.mas_rightMargin).mas_equalTo(0);
        make.height.mas_equalTo(54);



        // make.left.mas_equalTo(_nameImage.mas_right).mas_equalTo(0);
        make.centerX.mas_equalTo(0);



        if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
        {
            make.top.mas_equalTo(weakSelf.timeLabel.mas_bottom).mas_equalTo(20);
        }else{
            make.top.mas_equalTo(weakSelf.timeLabel.mas_bottom).mas_equalTo(25);
        }
    }];

    [self.textField2 mas_makeConstraints:^(MASConstraintMaker *make) {
        //  make.size.mas_equalTo(CGSizeMake(280, 54));
        make.leftMargin.mas_equalTo(weakSelf.viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(weakSelf.viewBackGround.mas_rightMargin).mas_equalTo(0);
        make.height.mas_equalTo(54);
        // make.left.mas_equalTo(_passwordImage.mas_right).mas_equalTo(0);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.textField1.mas_bottom).mas_equalTo(-1);
    }];
}

//微信的第三方登入
-(void)tapWeChat{
    

        [self getUserInfoForPlatform:UMSocialPlatformType_WechatSession];
    
    
    
    
}




//qq的第三方登入
-(void)tapQQ{

    

        [self getUserInfoForPlatform:UMSocialPlatformType_QQ];
    
    
    
}
//微博的第三方登入
-(void)tapWeiBo{
    [[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_Sina currentViewController:nil completion:^(id result, NSError *error) {
        if (error) {
            
        } else {
            UMSocialUserInfoResponse *resp = result;
            // 授权信息
            NSLog(@"Sina uid: %@", resp.uid);
            NSLog(@"Sina accessToken: %@", resp.accessToken);
            NSLog(@"Sina refreshToken: %@", resp.refreshToken);
            NSLog(@"Sina expiration: %@", resp.expiration);
            // 用户信息
            NSLog(@"Sina name: %@", resp.name);
            NSLog(@"Sina iconurl: %@", resp.iconurl);
       //     NSLog(@"Sina gender: %@", resp.unionGender);
            
            // 第三方平台SDK源数据
            NSLog(@"Sina originalResponse: %@", resp.originalResponse);
        }
    }];
}
-(void)enterOtherViewController{
    NSArray * arrayHjt =  [HJTsqlite selectData:2 andModel:[logNSObject class] andName:@"LogId"];
    if (arrayHjt.count>0) {
        for (logNSObject * models in arrayHjt) {
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
            [getPeopleID getPeopletitle:models.cusName];
            [getPeopleID getPeoplePhoto:models.photo];
            [getPeopleID getPeopleID:models.ID];
            [getPeopleID getPeopleIphoneNmber:models.teltphone];
            if (models.account_type == 0) {
                [getPeopleID getpeopleLimitedAuthority:YES];
            }else
            {
                [getPeopleID getpeopleLimitedAuthority:NO];
            }
            //如果微信登入可以使用了就跳转
            dispatch_async(dispatch_get_main_queue(), ^{
                SVProgressHUD.minimumDismissTimeInterval = 1.0;
               // [SVProgressHUD showSuccessWithStatus:@"登录成功"];
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
                [[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"startAutoLoginState"];
                [self.navigationController popViewControllerAnimated:YES];
            });
        }
    }else{
        SVProgressHUD.minimumDismissTimeInterval =1.0;
        [SVProgressHUD showErrorWithStatus:@"首次使用请注册后登入"];
    

    }
    
    
}

#define mark - 微信和qq发送网络请求
//第三方老左的最后的一个接口
-(void)SenderthirdWeixinStr:(NSString *)weixinStr andTelephone:(NSString*)telphone andidentitfityUdid:(NSString*)telephonePwd andIdentitfyId:(NSString*)identitfyId andPicId:(NSString *)picId{
    
   // [logNetModel getLogMessage4:weixinStr andTelephone:telphone andLoginpassword:telephonePwd andUid:nil andl:2 andweixinId:identitfyId andPicId:picId  completionHandle:^(lodModel *model, NSError *error) {
//
//        if (error) {
//            [SVProgressHUD showErrorWithStatus:@"网络出错"];
//            return;
//        }
//        //test
//        [SVProgressHUD dismiss];
//        if ([model.status isEqualToString:@"0"]) {
//
//            self.peopleMessage =[[NSString alloc]init];
//            self.view.backgroundColor=[UIColor whiteColor];
//             [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor] ];
//            self.ThirdPartyWeChat.hidden =NO;
//            self.editText =NO;
//            self.thirdStr =@"";
//                [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"startAutoLoginState"];
//            //设置第一次登入为yes
//            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
//
//
//            if (self.weixinStr )  [getPeopleID getPeopletitle:model.userinfo.cus_name]; else   [getPeopleID getPeopletitle:self.weixinID];
//
//            if (!self.weixinPicId)  [getPeopleID getPeoplePhoto:model.userinfo.photo]; else [getPeopleID getPeoplePhoto:self.weixinPicId];
//
//
//            [getPeopleID getPeopleID:model.userinfo.ID];
//            [getPeopleID getPeopleIphoneNmber:model.userinfo.telphone];
//            if (model.userinfo.account_type == 0) {
//                [getPeopleID getpeopleLimitedAuthority:YES];
//            }else
//            {
//                [getPeopleID getpeopleLimitedAuthority:NO];
//            }
//            SVProgressHUD.minimumDismissTimeInterval = 1.0;
//           // [SVProgressHUD showSuccessWithStatus:@"登录成功"];
//            [self.navigationController popViewControllerAnimated:YES];
//
//        }else{
//            codeSelected *code = [codeSelected MustTakeReturn:[model.status intValue]];
//            [code returnCodeMethod];
//        }
//    }];
    
    
    
}

#pragma mark - 设置推送
-(void)setPushMessageTag:(NSString*)placeMark
{
    __autoreleasing NSMutableSet *tags = [NSMutableSet set];
    __autoreleasing NSString *alias = placeMark;
    [self analyseInput:&alias tags:&tags];
    
    
    
    
    
    
    //    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alias
    //                                                    message:@"已发送设置"
    //                                                   delegate:self
    //                                          cancelButtonTitle:@"确定"
    //                                          otherButtonTitles:nil, nil];
    //    [alert show];
    
    
    
    
}
- (void)analyseInput:(NSString **)alias tags:(NSSet **)tags {
    // alias analyse
    if (![*alias length]) {
        // ignore alias
        *alias = nil;
    }
    // tags analyse
    if (![*tags count]) {
        *tags = nil;
    } else {
        __block int emptyStringCount = 0;
        [*tags enumerateObjectsUsingBlock:^(NSString *tag, BOOL *stop) {
            if ([tag isEqualToString:@""]) {
                emptyStringCount++;
            } else {
                emptyStringCount = 0;
                *stop = YES;
            }
        }];
        if (emptyStringCount == [*tags count]) {
            *tags = nil;
        }
    }
}



//曹妈妈
-(void)SenderSecondNetWorking:(NSString *)weixinStr andTelephone:(NSString*)telphone andTelephonePassWord:(NSString*)telephonePwd andweixinId:(NSString*)weixinId andPicId:(NSString *)picId{
    
    [logNetModel getLogMessage3:weixinStr andTelephone:telphone andLoginpassword:telephonePwd andUid:nil andl:2 andweixinId:weixinId andPicId:picId  completionHandle:^(lodModel *model, NSError *error) {
        if (error) {
            [SVProgressHUD showErrorWithStatus:@"网络出错"];
            return;
        }
        //test
        [SVProgressHUD dismiss];
        
        if ([model.status isEqualToString:@"0"]) {
            NSLog(@"%@",model.code);
            self.peopleMessage =[[NSString alloc]init];
            [self setPushMessageTag:telphone];
            NSLog(@"%@",self.peopleMessage);
            self.editText =NO;
            self.thirdStr=@"";
            LAContext *context = [[LAContext alloc] init]; // 初始化上下文对象
            NSError *error = nil;
            // 判断设备是否支持指纹识别功能
            if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error] )
            {
                // 设备不支持，隐藏掉指纹登录cell，Demo不再实现
                logNSObject *logobject = [logNSObject  new];
                logobject.LogId =1;
                logobject.cusName =model.userinfo.cus_name;
                logobject.photo= model.userinfo.photo;
                logobject.ID = model.userinfo.ID;
                logobject.teltphone =model.userinfo.telphone;
                logobject.account_type = model.userinfo.account_type;
                logobject.firstlog = YES;
                [HJTsqlite addDate:logobject];
                //YES ->NO
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"startAutoLoginState"];
            }else{
                [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"startAutoLoginState"];
            }
            
            //设置第一次登入为yes
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
            if ([self.thirdStr isEqualToString:@"登入"]){
                
                if (self.weixinStr )  [getPeopleID getPeopletitle:model.userinfo.cus_name]; else   [getPeopleID getPeopletitle:self.weixinID];
                
                if (!self.weixinPicId)  [getPeopleID getPeoplePhoto:model.userinfo.photo]; else [getPeopleID getPeoplePhoto:self.weixinPicId];
         
            }else{
         
                [getPeopleID getPeopletitle:model.userinfo.cus_name];
                [getPeopleID getPeoplePhoto:model.userinfo.photo];
            }
            
            
            

            [getPeopleID getPeopleID:model.userinfo.ID];
            [getPeopleID getPeopleIphoneNmber:model.userinfo.telphone];
            if (model.userinfo.account_type == 0) {
                [getPeopleID getpeopleLimitedAuthority:YES];
            }else
            {
                [getPeopleID getpeopleLimitedAuthority:NO];
            }
            SVProgressHUD.minimumDismissTimeInterval = 1.0;
           // [SVProgressHUD showSuccessWithStatus:@"登录成功"];
            //计算微信登入成功的事件
            [MobClick event:@"login" label:@"微信登录"];
            
            //初始化数据
            [[clickEvent instance] initData];
            
            [self.navigationController popViewControllerAnimated:YES];
            
        }else if([model.status isEqualToString:@"1031"]){
           
        SVProgressHUD.minimumDismissTimeInterval =1.0;
            [SVProgressHUD showSuccessWithStatus:@"首次使用需要先注册账号"];
//添加特征值
            NSString *stringInt = [NSString stringWithFormat:@"%ld",(long)model.userinfo.ID];
            self.identitfityUdid = stringInt;

            [self tapLabel:self.emailLabel];
            

//            //微信注册
//            FandRViewController *logVC =    [[FandRViewController alloc]init];
//            logVC.strTitle =@"微信注册";
//            logVC.thirdStr =@"登入";
//            logVC.emailSender =YES;
//            logVC.weixinStr =self.weixinStr;
//            logVC.textField1RE =self.textField1RE;
//            logVC.identitfityUdid =self.identitfityUdid;
//            logVC.weixinPicId =self.weixinPicId;
//            logVC.hidesBottomBarWhenPushed =YES;
//            [self.navigationController pushViewController:logVC animated:YES];
        }else{
            self.thirdStr =@"";
            codeSelected *code = [codeSelected MustTakeReturn:[model.status intValue]];
            [code returnCodeMethod];
        }
    }];
    
    
    
}

//第三方登入
- (void)getUserInfoForPlatform:(UMSocialPlatformType)platformType
{
    [[UMSocialManager defaultManager] getUserInfoWithPlatform:platformType currentViewController:self completion:^(id result, NSError *error) {
        UMSocialUserInfoResponse *resp = result;
        
        
        
        if(resp.uid ){
            if (!resp.name) {
                resp.name =@"";
            }
            if (!resp.iconurl) {
                resp.iconurl=@"";
            }
            self.thirdStr =@"登入";
//            [self enterOtherViewController];
            [self SenderSecondNetWorking:resp.uid andTelephone:nil andTelephonePassWord:nil andweixinId:resp.name andPicId:resp.iconurl];
            self.weixinStr =resp.uid;
            self.weixinID=resp.name;
            self.weixinPicId=resp.iconurl;
        }else{
            self.thirdStr =@"";
        }
        
        
        // 第三方登录数据(为空表示平台未提供)
        // 授权数据
        NSLog(@" uid: %@", resp.uid);//uuid
        NSLog(@" openid: %@", resp.openid);
        NSLog(@" accessToken: %@", resp.accessToken);
        NSLog(@" refreshToken: %@", resp.refreshToken);
        NSLog(@" expiration: %@", resp.expiration);
        
        // 用户数据
        NSLog(@" name: %@", resp.name);
        NSLog(@" iconurl: %@", resp.iconurl);
        NSLog(@" gender: %@", resp.gender);
        
        // 第三方平台SDK原始数据
        NSLog(@" originalResponse: %@", resp.originalResponse);
        
  
        
        
        
    }];
}

#pragma mark -验证消息是否正常


-(void)zhiwenJieSuo{
    

      self.editText =NO;
    if ([[NSUserDefaults standardUserDefaults]boolForKey:@"startAutoLoginState"]){
   
        logNSObject *logobject = [logNSObject  new];
    LAContext *context = [[LAContext alloc] init]; // 初始化上下文对象
    NSError *error = nil;
    if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]){
        // 支持指纹验证
//        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"是否启用指纹登录" message:@"" preferredStyle:UIAlertControllerStyleAlert];
//
//        __weak typeof (self) weakSelf = self;
//
//        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消使用指纹" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//
//            [[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"startAutoLoginState"];
//        }];
//
//        UIAlertAction *startUseAction = [UIAlertAction actionWithTitle:@"启用登入" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            [logobject zhiwenHadnle:^(NSString *str, NSError *error) {
                if(error){
                    return ;
                }
                
                if ([str isEqualToString:@"成功"]) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        SVProgressHUD.minimumDismissTimeInterval = 1.0;
                      //  [SVProgressHUD showSuccessWithStatus:@"登录成功"];
        NSArray * arrayHjt =  [HJTsqlite selectData:2 andModel:[logNSObject class] andName:@"LogId"];
                        if (arrayHjt.count>0) {
                    [self.navigationController popViewControllerAnimated:NO];
                        }
                  });
               
                }
                
                
            }];
            
        
    
//        }];
//        [alertController addAction:cancelAction];
//        [alertController addAction:startUseAction];
//
//        [self presentViewController:alertController animated:YES completion:nil];
    }else{
         [[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"startAutoLoginState"];
    }

        
        }
    
    
}




-(void)registerBtnClick
{

    
         [SVProgressHUD show];
    
                            AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
       delegate.telephoneLoginStr =_textField1.text ;
    delegate.telephoneLoginPassport =_textField2.text ;
    if (_textField1.text.length ==11 && (_textField2.text.length <= 16) && (_textField2.text.length >= 6)) {
   
        [logNetModel getLogMessage3:nil andTelephone:_textField1.text andLoginpassword:_textField2.text andUid:nil andl:0 andweixinId:nil andPicId:nil  completionHandle:^(lodModel *model, NSError *error) {
            if (error) {
                [SVProgressHUD showErrorWithStatus:@"网络出错"];
                return;
            }
          
            
             [SVProgressHUD dismiss];
            if ([model.status isEqualToString:@"0"]) {
                NSLog(@"%@",model.code);
                self.peopleMessage =[[NSString alloc]init];
                   [self setPushMessageTag:_textField1.text];
                NSLog(@"%@",self.peopleMessage);
                      self.editText =NO;

                LAContext *context = [[LAContext alloc] init]; // 初始化上下文对象
                NSError *error = nil;
                // 判断设备是否支持指纹识别功能
                if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error])
                {
                    // 设备不支持，隐藏掉指纹登录cell，Demo不再实现
                 logNSObject *logobject = [logNSObject  new];
                    logobject.LogId =1;
                    logobject.cusName =model.userinfo.cus_name;
                    logobject.photo= model.userinfo.photo;
                    logobject.ID = model.userinfo.ID;
                    logobject.teltphone =model.userinfo.telphone;
                    logobject.account_type = model.userinfo.account_type;
                    logobject.firstlog = YES;
                    [HJTsqlite addDate:logobject];
                    //YES ->NO
                    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"startAutoLoginState"];
                }else{
                    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"startAutoLoginState"];
                }
  
                //设置第一次登入为yes
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
                [getPeopleID getPeopletitle:model.userinfo.cus_name];
                [getPeopleID getPeoplePhoto:model.userinfo.photo];
                [getPeopleID getPeopleID:model.userinfo.ID];
                [getPeopleID getPeopleIphoneNmber:model.userinfo.telphone];
                if (model.userinfo.account_type == 0) {
                    [getPeopleID getpeopleLimitedAuthority:YES];
                }else
                {
                    [getPeopleID getpeopleLimitedAuthority:NO];
                }
                SVProgressHUD.minimumDismissTimeInterval = 1.0;
                //[SVProgressHUD showSuccessWithStatus:@"登录成功"];
                [MobClick event:@"login" label:@"账号登录"];
                //初始化数据
                [[clickEvent instance] initData];
                [self.navigationController popViewControllerAnimated:YES];
                
            }else{
         

                
                
//                  [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"%@",model.status]];
                codeSelected *code = [codeSelected MustTakeReturn:[model.status intValue]];
                [code returnCodeMethod];
           
                if ([model.status isEqualToString:@"9999"]) {
                    [SVProgressHUD showErrorWithStatus:@"账号或密码错误"];
                }

            }
        }];
    }
    if (_textField2.text.length < 5 || _textField2.text.length > 16) {
        [_textField2 shake];
        
        [SVProgressHUD showErrorWithStatus:@"密码需大于5小于16"];
        return;
    }
    if (_textField1.text.length ==0) {
         [SVProgressHUD showErrorWithStatus:@"账号不能为空"];
        return;
        }
}
#pragma mark-设置textfield的代理
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == _textField1) {
        [_textField1 resignFirstResponder];
    }
    if (textField == _textField2) {
        [_textField2 resignFirstResponder];
    }
    if (textField == _textField1RE) {
        [_textField1RE resignFirstResponder];
    }
    if (textField == _textField2RE) {
        [_textField2RE resignFirstResponder];
    }
    if (textField == _textField1PSS) {
        [_textField1PSS resignFirstResponder];
    }
    if (textField == _textField2PSS) {
        [_textField2PSS resignFirstResponder];
    }
         if (_textField1.text.length >0 && (_textField2.text.length <= 16) && (_textField2.text.length > 0)) {
               _buttonForLog.backgroundColor=[UIColor colorWithRed:35/255.0 green:168/255.0 blue:222/255.0 alpha:1.0];
             _buttonForLog.userInteractionEnabled =YES;
         }else
         {
             _buttonForLog.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
             _buttonForLog.userInteractionEnabled =NO;
         }
    if (_textField1RE.text.length >0 && _textField2RE.text.length >0) {
        _buttonForLogRE.backgroundColor=[UIColor colorWithRed:49/255.0 green:160/255.0 blue:126/255.0 alpha:1.0];
    }else
    {
     _buttonForLogRE.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    }
    if (_textField1PSS.text.length >0 && _textField2PSS.text.length >0) {
        _buttonTranslateMain.backgroundColor=[UIColor colorWithRed:49/255.0 green:160/255.0 blue:126/255.0 alpha:1.0];
    }else
    {
        _buttonTranslateMain.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    }
    
    return YES;
}
//这里实现注册按钮的方法
-(void)tapLabel:(UIButton*)sender
{
   // self.ThirdPartyWeChat.hidden =YES;
    if (sender ==self.freeRegistrationLabel) {
        
        //耗时开始计时
//        CFAbsoluteTime startButtonClick   = CFAbsoluteTimeGetCurrent();
        
        [sender setEnabled:NO];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [sender setEnabled:YES];
        });
  
        
//        //s注册
//        FandRViewController *logVC =    [FandRViewController sharedInstance];
//        logVC.strTitle =@"注册";
//        logVC.changeBut =YES;
//        logVC.emailSender =NO;
//        logVC.registLabelTwo.text =@"注册";
//        logVC.hidesBottomBarWhenPushed =YES;
//        [self.navigationController pushViewController:logVC animated:YES];
        
        return;
    }else if(sender ==self.ForgetPassWorldLabel){
        //找回密码
        FandRViewController *logVC =    [[FandRViewController alloc]init];
        logVC.strTitle =@"找回密码";
        logVC.changeBut =NO;
        logVC.registLabelTwo.text =@"找回密码";
        logVC.hidesBottomBarWhenPushed =YES;
        [self.navigationController pushViewController:logVC animated:YES];
        
        
        return;
    }
        
        if(sender ==self.emailLabel){
        
 self.emailSender = YES;
       
    }

    
    
    
//        if(sender ==self.emailLabel){
//            //短信快捷登入
//
//        }
    if (self.editText == YES) {
        
        _registLabelTwo.text=@"找回密码";
    }
    

    
    
    
    if (sender ==self.ForgetPassWorldLabel) {
      //      _registLabelTwo.text=@"找回密码";
     //   self.changeBut=NO;
        
    }
    else if(sender == self.RegisterPasswordLabel || sender == self.emailLabel){
        self.view.backgroundColor =[UIColor lightGrayColor];
        [self.navigationController.navigationBar setBarTintColor:[UIColor lightGrayColor] ];
        __weak __typeof__(self) weakSelf = self;

        //添加弹框视图
        [self.view addSubview:self.registerView];
        
        
        
        
        [self.registerView mas_remakeConstraints:^(MASConstraintMaker *make) {
            
            
            if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
            {
                make.top.mas_equalTo(weakSelf.view).mas_equalTo(170);
            }else{
                make.top.mas_equalTo(weakSelf.view).mas_equalTo(200);
            }
            
            make.left.mas_equalTo(20);
            make.right.mas_equalTo(-20);
            make.height.mas_equalTo(290);
        }];
        self.registerView.hidden = NO;
        [self faceToAN:self.registerView];
   

    [self.registerView addSubview:self.registLabelTwo];
    [self.registLabelTwo mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(35);
        make.centerX.mas_equalTo(0);

    }];
    //
    [self.registerView addSubview:self.telephoneRE];
    [self.telephoneRE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 22));
    make.top.mas_equalTo(weakSelf.registLabelTwo.mas_bottom).mas_equalTo(20);
        make.left.mas_equalTo(35);
    }];
    [self.registerView addSubview:self.lineImage11];
    [self.lineImage11 mas_makeConstraints:^(MASConstraintMaker *make) {
      make.width.mas_equalTo(weakSelf.registerView.mas_width).mas_equalTo(-20);
        make.height.mas_equalTo(2);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.telephoneRE.mas_bottom).mas_equalTo(5);
    }];

    [self.registerView addSubview:self.passwordRE];
    [self.passwordRE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 22));
        make.top.mas_equalTo(weakSelf.lineImage11.mas_bottom).mas_equalTo(35);
        make.left.mas_equalTo(35);
    }];

    [_registerView addSubview:self.lineImage22];
    [self.lineImage22 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(weakSelf.registerView.mas_width).mas_equalTo(-20);
        make.height.mas_equalTo(2);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.passwordRE.mas_bottom).mas_equalTo(5);
    }];

    [_registerView addSubview: self.back];
    [_back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(3);
        make.leftMargin.mas_equalTo(weakSelf.lineImage22.mas_leftMargin);
    }];
   
    [_registerView addSubview:self.textField1RE];
    [_textField1RE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(250, 22));
        make.left.mas_equalTo(weakSelf.telephoneRE.mas_right).mas_equalTo(10);
        make.bottomMargin.mas_equalTo(weakSelf.telephoneRE.mas_bottomMargin);
    }];
    
    [_registerView addSubview:self.textField2RE];
    [_textField2RE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(130, 22));
        make.left.mas_equalTo(weakSelf.passwordRE.mas_right).mas_equalTo(10);
        make.topMargin.mas_equalTo(weakSelf.passwordRE.mas_bottomMargin);
    }];

    
    [_registerView addSubview: self.verificationCodeButton];
    [_verificationCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.topMargin.mas_equalTo(weakSelf.passwordRE.mas_topMargin);
        make.right.mas_equalTo(-20);

    }];
    [_registerView addSubview:self.buttonForLogRE];
    [_buttonForLogRE mas_makeConstraints:^(MASConstraintMaker *make) {
      make.width.mas_equalTo(weakSelf.registerView.mas_width).mas_equalTo(-20);
        make.height.mas_equalTo(40);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.lineImage22.mas_bottom).mas_equalTo(30);
    }];

    if ([_registLabelTwo.text isEqualToString:@"注册"]) {

       
        [_registerView addSubview: self.fuwuxiyiButton];
        [self.fuwuxiyiButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(30);
        make.top.mas_equalTo(weakSelf.buttonForLogRE.mas_bottom).mas_equalTo(30);
        }];
       
        [_registerView addSubview: self.fuwuxiyiLabel];
        [self.fuwuxiyiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakSelf.fuwuxiyiButton.mas_right).mas_equalTo(10);
            make.topMargin.mas_equalTo(weakSelf.fuwuxiyiButton.mas_topMargin).mas_equalTo(-3);
        }];

       
        [_registerView addSubview: self.fuwuxiyiLabel2];
        [self.fuwuxiyiLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakSelf.fuwuxiyiLabel.mas_right).mas_equalTo(0);
            make.topMargin.mas_equalTo(weakSelf.fuwuxiyiButton.mas_topMargin).mas_equalTo(-3);
        }];
    }

    }
    
    
}


#pragma mark - 其他登录方式
-(void)otherLoginWayBtnCliced:(UIButton*)btn {
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss];
        if (self.navigationController.viewControllers.lastObject.navigationController) {
            
            
            
            [self.navigationController.viewControllers.lastObject dismissViewControllerAnimated:YES completion:^{
                 NSLog(@"回到登录界面");
            }];
            
        }
    });
    
}
-(void)fuwuQueren:(UIButton*)sender
{
    sender.selected =!sender.selected;
    self.isFuWu = sender.enabled;

}
-(void)kankanShebaoXieyi
{
    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    kankanshebaoxieyi *kankan = [sb instantiateViewControllerWithIdentifier:@"kankanshebaoxieyi"];
    kankan.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:kankan animated:YES];
}
#pragma mark-获取验证码
-(void)verificationCodeButtonmetho:(UIButton *)sender
{
    self.verificationCodeButton.userInteractionEnabled =NO;
    NSScanner *scan = [NSScanner scannerWithString:_textField1RE.text];
    int val;
    BOOL PureInt = [scan scanInt:&val]&&[scan isAtEnd];
    NSLog(@"%d",PureInt);
    if (!PureInt || _textField1RE.text.length !=11)
    {
        [_textField1RE shake];
           self.verificationCodeButton.userInteractionEnabled =YES;
    }
    else
    {
        
        self.timeCount = 60;
        //self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];
        //微信登入注册接口
        if(self.emailSender == YES){
        //里面写接口
            NSString *asdfwgg =@"";
            if (self.weixinStr && self.identitfityUdid) {
                asdfwgg=      [[self.weixinStr stringByAppendingString:@"HELLO"] stringByAppendingString:self.identitfityUdid];
            }
        
            
            
            [logNetModel getLogMessage1:asdfwgg andTelephone:_textField1RE.text andTag:1003 completionHandle:^(lodModel *model, NSError *error) {
                //短信快捷登录
                if (error) {
                    [SVProgressHUD showErrorWithStatus:@"网络状态差"];
                    return ;
                }
                self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];

                
                if ([model.code isEqualToString:@"12"]) {
//                    SVProgressHUD.minimumDismissTimeInterval=1.0;
//                    [SVProgressHUD showErrorWithStatus:@"此手机没有注册"];
                    
                        //打开注册的页面
                    self.passView.hidden =YES;
                    [self backView];
                 
                        //s注册
                    FandRViewController *logVC = [FandRViewController sharedInstance];
                        logVC.strTitle =@"注册";
                        logVC.changeBut =YES;
                        logVC.emailSender =NO;
                        logVC.registLabelTwo.text =@"注册";
                        logVC.hidesBottomBarWhenPushed =YES;
                        [self.navigationController pushViewController:logVC animated:YES];
                        
                        
                    
                    self.timeCount = 0;
                     [self.timer invalidate];
                    
                 
                }
            

                
            }];
        }else{
        if(self.changeBut==NO ){
            [logNetModel getLogMessage1:nil andTelephone:_textField1RE.text andTag:1002 completionHandle:^(lodModel *model, NSError *error) {
                if (error) {
                      [SVProgressHUD showErrorWithStatus:@"网络状态差"];
                    return ;
                }
                self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];

                if ([model.code isEqualToString:@"12"]) {
                    //SVProgressHUD.minimumDismissTimeInterval=1.0;
                   // [SVProgressHUD showErrorWithStatus:@"此手机没有注册"];
                     self.passView.hidden =YES;
                     [self backView];
               
                        //s注册
                        FandRViewController *logVC =    [FandRViewController sharedInstance];
                        logVC.strTitle =@"注册";
                        logVC.changeBut =YES;
                        logVC.emailSender =NO;
                        logVC.registLabelTwo.text =@"注册";
                        logVC.hidesBottomBarWhenPushed =YES;
                        [self.navigationController pushViewController:logVC animated:YES];
                        
                       
                    
                    self.timeCount = 0;
                     [self.timer invalidate];
                }else{
                    codeSelected *code = [codeSelected MustTakeReturn:[model.code intValue]];
                    [code returnCodeMethod];
                }
            }];
        }
        if(self.changeBut==YES ){
            

            
            
            [logNetModel getLogMessage1:nil andTelephone:_textField1RE.text andTag:1001 completionHandle:^(lodModel *model, NSError *error) {
                
                if(error){
                    UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:@"收不到验证码请尝试打开流量并且关闭wifi" message:nil preferredStyle:UIAlertControllerStyleAlert];
                    [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {                               }]];
                    [self presentViewController:alertCon animated:YES completion:nil];
                    return;
                }
                if (error) {
                      [SVProgressHUD showErrorWithStatus:@"网络状态差"];
                    return ;
                  
                }
                self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];

                if ([model.code isEqualToString:@"0"]) {
                    //当验证码为
                    self.isEnterNoCode =YES;
             
                    if (model.status) {
                          [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(timeOut:) userInfo:model.status repeats:NO];
                    }
                  
                }
                
                if (![model.code isEqualToString:@"0"]) {
                    [SVProgressHUD showErrorWithStatus:@"手机号码已注册"];
                }
            }];
        
        }
        }
    }
    
    


}

//验证码的数字倒计时
-(void)timeOut:(NSTimer *)codeTimer{
   
 NSString *code =    codeTimer.userInfo;
   
    if (self.isEnterNoCode == YES &&  _textField1RE.text.length ==11 && _textField2RE.text.length ==0) {
        self.isEnterNoCode =NO;
         [self alertSHOW: code];
    }

    NSLog(@"timeout");
}
-(void)reduceTime:(NSTimer *)codeTimer
{
    self.timeCount--;
    if (self.timeCount == 0) {
        [_verificationCodeButton setTitle:@"重新获取验证码" forState:UIControlStateNormal];
        [_verificationCodeButton setTitleColor:[UIColor colorWithRed:90/255.0f green:178/255.0f blue:225/255.0f alpha:1] forState:UIControlStateNormal];
        UIButton *info = codeTimer.userInfo;
        info.enabled = YES;
        _verificationCodeButton.userInteractionEnabled = YES;
        [self.timer invalidate];
    } else if(self.timeCount > 0){
        NSString *str = [NSString stringWithFormat:@"%zd秒后重新获取", self.timeCount];
          [_verificationCodeButton setTitleColor:[UIColor colorWithRed:192/255.0f green:192/255.0f blue:192/255.0f alpha:1] forState:UIControlStateNormal];
        [_verificationCodeButton setTitle:str forState:UIControlStateNormal];
        _verificationCodeButton.userInteractionEnabled = NO;
        
    }else{
    
    }
}

-(void)dengru:(NSUInteger)jueding
{
    
    [logNetModel convenientLogin:self.textField1RE.text andValidateCode:self.textField2RE.text andKankanId:nil andUid:nil completionHandle:^(logModel_2 *model, NSError *error) {
        {
            
            [SVProgressHUD dismiss];
            NSLog(@"123212");
            if ([model.code isEqualToString:@"0"]) {
                NSLog(@"%@",model.code);
                self.peopleMessage =[[NSString alloc]init];
                NSLog(@"%@",self.peopleMessage);
                //判断账号是否登入时候使用
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
                [getPeopleID getPeopletitle:model.result.cus_name];
                [getPeopleID getPeoplePhoto:model.result.photo];
                [getPeopleID getPeopleID:model.result.ID];
                [getPeopleID getPeopleIphoneNmber:model.result.telphone];
                //初始化数据
                [[clickEvent instance] initData];
                AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
                
                if ( delegate.isLogin == NO) {
                    [getPeopleID getProvince:model.result.provinceName];
                    
                }
                if (model.result.account_type == 0) {
                    self.editText =NO;
                    _passView.hidden =YES;
                    _registerView.hidden =YES;
                    if ([self.thirdStr isEqualToString:@"登入"]) {

                    }else{
                        [getPeopleID getpeopleLimitedAuthority:YES];
                        [self.navigationController popViewControllerAnimated:YES];
                    }
                    
                }else if(model.result.account_type == 12){
                  //打开注册的页面
                
             
                        //s注册
                        FandRViewController *logVC =    [FandRViewController sharedInstance];
                        logVC.strTitle =@"注册";
                        logVC.changeBut =YES;
                        logVC.emailSender =NO;
                        logVC.registLabelTwo.text =@"注册";
                        logVC.hidesBottomBarWhenPushed =YES;
                        [self.navigationController pushViewController:logVC animated:YES];
                        
                       
                    
                }else
                {
                    [getPeopleID getpeopleLimitedAuthority:NO];
                     [self.navigationController popViewControllerAnimated:YES];
                }
                
            }else{
                codeSelected *code = [codeSelected MustTakeReturn:[model.code intValue]];
                [code returnCodeMethod];
                
            }
        }
        
    }];
}

-(void)buttonForLogRE:(UIButton*)button
{

//    if ([self.thirdStr isEqualToString:@"登入"]) {
//        self.ThirdPartyQQ.hidden =NO;
//        self.ThirdPartyWeChat.hidden =NO;
//    }
    
    //微信登入注册接口
    if (self.emailSender == YES) {
     //这里写接口
            [SVProgressHUD show];
        if (self.textField1RE.text.length ==0) {
            [SVProgressHUD dismiss];
            [SVProgressHUD showErrorWithStatus:@"账号不能为空"];
            return;
        }
      
        
        if ([self.thirdStr isEqualToString:@"登入"]) {
            //老左定义的第三个接口
            
            [self SenderthirdWeixinStr:self.weixinStr andTelephone:self.textField1RE.text  andidentitfityUdid:nil andIdentitfyId:self.identitfityUdid andPicId:self.textField2RE.text];
            
        }else{
              [self dengru:1];
        }
        
    
    }else{
    if (_textField1RE.text.length == 11 ) {

         self.view.backgroundColor =[UIColor lightGrayColor];
         [self.navigationController.navigationBar setBarTintColor:[UIColor lightGrayColor] ];
            _registerView.hidden =YES;
            _passView =[[UIView alloc]init];
            _passView.backgroundColor=[UIColor whiteColor];
            _passView.layer.cornerRadius=10.0;
            [self.view addSubview:_passView];
            [_passView mas_makeConstraints:^(MASConstraintMaker *make) {
                if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
                {
                    make.top.mas_equalTo(self.view).mas_equalTo(170);
                }else{
                    make.top.mas_equalTo(self.view).mas_equalTo(200);
                }
                make.left.mas_equalTo(20);
                make.right.mas_equalTo(-20);
                make.height.mas_equalTo(290);
            }];
            [self faceToAN:_passView];
                //注册
            _registLabelTwo =[[UILabel alloc]init];
            _registLabelTwo.text=@"设置密码";
            _registLabelTwo.font =[UIFont systemFontOfSize:18];
            _registLabelTwo.textColor=[UIColor blackColor];
        _registLabelTwo.textAlignment=NSTextAlignmentCenter;
            [_passView addSubview:_registLabelTwo];
            [_registLabelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(100, 20));
                make.top.mas_equalTo(35);
                make.centerX.mas_equalTo(0);
                
            }];
//            //
            UILabel *label1 =[[UILabel alloc]init];
         label1.text=@"密     码:";
        label1.font=[UIFont systemFontOfSize:18];
        label1.textAlignment=NSTextAlignmentLeft;
            [_passView addSubview:label1];
            [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(80, 22));
                make.top.mas_equalTo(_registLabelTwo.mas_bottom).mas_equalTo(20);
                make.left.mas_equalTo(35);
            }];
//
//        //line
            _lineImage =[[UIImageView alloc]init];
            _lineImage.backgroundColor =[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0];
            [_passView addSubview:_lineImage];
            [_lineImage mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.mas_equalTo(self.registerView.mas_width).mas_equalTo(-20);
                make.height.mas_equalTo(2);
                make.centerX.mas_equalTo(0);
                make.top.mas_equalTo(label1.mas_bottom).mas_equalTo(5);
            }];
        if (_editText == NO) {
     
            _back=[UIButton buttonWithType:UIButtonTypeCustom];
            [_back setTitle:@"返回" forState:UIControlStateNormal];
            [_back setTitleColor:[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0]  forState:UIControlStateNormal];
            _back.titleLabel.font = [UIFont systemFontOfSize:14];
            [_back addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
            [_passView addSubview: _back];
            [_back mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(3);
                make.leftMargin.mas_equalTo(_lineImage.mas_leftMargin);
            }];
        }
//   //label2
        UILabel *label_2 =[[UILabel alloc]init];
        label_2.text=@"确认密码:";
        label_2.font=[UIFont systemFontOfSize:17];
        label_2.textAlignment=NSTextAlignmentLeft;
                      [_passView addSubview:label_2];
            [label_2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(80, 22));
                make.top.mas_equalTo(_lineImage.mas_bottom).mas_equalTo(35);
                make.left.mas_equalTo(35);
            }];
            
            _lineImage2=[[UIImageView alloc]init];
            _lineImage2.backgroundColor =[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0];
            [_passView addSubview:_lineImage2];
            [_lineImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.mas_equalTo(self.registerView.mas_width).mas_equalTo(-20);
                make.height.mas_equalTo(2);
                make.centerX.mas_equalTo(0);
                make.top.mas_equalTo(label_2.mas_bottom).mas_equalTo(5);
            }];
            _textField1PSS=[UITextField new];
            _textField1PSS.font=[UIFont systemFontOfSize:14];
            _textField1PSS.clearButtonMode=UITextFieldViewModeWhileEditing;
            _textField1PSS.delegate=self;
        _textField1PSS.secureTextEntry =YES;
            [_passView addSubview:_textField1PSS];
            [_textField1PSS mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(250, 22));
                make.left.mas_equalTo(label1.mas_right).mas_equalTo(0);
                make.bottomMargin.mas_equalTo(label1.mas_bottomMargin);
            }];
            _textField2PSS=[UITextField new];

            _textField2PSS.font = [UIFont systemFontOfSize:14];
            _textField2PSS.clearButtonMode = UITextFieldViewModeWhileEditing;
         _textField2PSS.secureTextEntry =YES;
            _textField2PSS.delegate=self;
            [_passView addSubview:_textField2PSS];
            [_textField2PSS mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(250, 22));
                make.left.mas_equalTo(label_2.mas_right).mas_equalTo(0);
                make.topMargin.mas_equalTo(label_2.mas_topMargin);
            }];

            _buttonTranslateMain=[UIButton buttonWithType:UIButtonTypeCustom];
            [_buttonTranslateMain setTitle:@"确定" forState:UIControlStateNormal];
            [_buttonTranslateMain setTintColor:[UIColor whiteColor]];
            _buttonTranslateMain.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
            _buttonTranslateMain.titleLabel.font = [UIFont systemFontOfSize:26];
            [_buttonTranslateMain addTarget:self action:@selector(buttonSender:) forControlEvents:UIControlEventTouchUpInside];
            _buttonTranslateMain.layer.cornerRadius=9.0;
            [_passView addSubview: _buttonTranslateMain];
            [_buttonTranslateMain mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.mas_equalTo(self.registerView.mas_width).mas_equalTo(-20);
                make.height.mas_equalTo(40);
                make.centerX.mas_equalTo(0);
                make.top.mas_equalTo(_lineImage2.mas_bottom).mas_equalTo(45);
            }];
    }
    else{
        [_textField1RE shake];
        [_textField2RE shake];
    }
    }


}
-(void)buttonSender:(UIButton *)button
{
    //    self.ThirdPartyQQ.hidden =NO;
        self.ThirdPartyWeChat.hidden =NO;
    
    if ([_textField1PSS.text length]<8 || [_textField1PSS.text length] >16) {
            [SVProgressHUD  showErrorWithStatus:@"密码需要大于8小于16"];
        return;
    }
        if(![_textField1PSS.text isEqualToString:_textField2PSS.text]){
            [SVProgressHUD showErrorWithStatus:@"两次密码不一样"];
            return;
        }
    
    
    

    
    if(self.changeBut ==NO &&self.editing==NO){
        //重设密码接口
            NSString *path =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/resetPassword"];
            [logNetModel getLogMessage2:path andTelephone:_textField1RE.text andValidate:_textField2RE.text andCusPassword:_textField1PSS.text completionHandle:^(lodModel *model, NSError *error) {
                NSLog(@"%@",model.code);
                if ([model.code isEqualToString:@"0"] ) {
                    _passView.hidden =YES;
                    _registerView.hidden =YES;
                    self.view.backgroundColor=[UIColor whiteColor];
                     [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor] ];
                    self.textField1.text =@"";
                    self.textField2.text=@"";
                    //                UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                    //                logViewController *tc=[sb instantiateViewControllerWithIdentifier:@"logViewController"];
                    //                [self.navigationController pushViewController:tc animated:YES];
                    SVProgressHUD.minimumDismissTimeInterval=1.0;
                   // [SVProgressHUD showSuccessWithStatus:@"登录成功"];
                    
                   [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstlog"];
                    [self.navigationController popToRootViewControllerAnimated:YES];
                    
                }else
                {
                    codeSelected *code = [codeSelected MustTakeReturn:[model.code intValue]];
                    [code returnCodeMethod];
                    _passView.hidden =YES;
                    _registerView.hidden =NO;
                }
        }];
    }
    
    
    
    if(self.changeBut ==YES && self.editing ==NO){
        [logNetModel getLogMessage2:nil andTelephone:_textField1RE.text andValidate:_textField2RE.text andCusPassword:_textField1PSS.text completionHandle:^(lodModel *model, NSError *error) {
            
            
            
            if (error) {
                return;
            }
            
            NSLog(@"%@",model.code);
   
            
            
          
            if ([model.code isEqualToString:@"0"] ) {
                _passView.hidden =YES;
                _registerView.hidden =YES;
                self.view.backgroundColor=[UIColor whiteColor];
                 [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor] ];
                SVProgressHUD.minimumDismissTimeInterval=1.0;
                [SVProgressHUD showSuccessWithStatus:@"成功"];
            }else if([model.code isEqualToString:@"1031"]){
                _passView.hidden =YES;
                _registerView.hidden =YES;
                self.view.backgroundColor=[UIColor whiteColor];
                 [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor] ];
                SVProgressHUD.minimumDismissTimeInterval=1.0;
                [self SenderSecondNetWorking:self.weixinStr andTelephone:_textField1RE.text andTelephonePassWord:_textField1PSS.text andweixinId:self.weixinID andPicId:self.weixinPicId ];
           
                
                
            }else
            {
                codeSelected *code = [codeSelected MustTakeReturn:[model.code intValue]];
                [code returnCodeMethod];
                _passView.hidden =YES;
                _registerView.hidden =NO;
            }
        }];
    }
}

#pragma mark -view的动画
-(void)faceToAN:(UIView *)view1
{
    CATransition *applicationLoadViewIn =[CATransition animation];
        [self.view reloadInputViews];
    [applicationLoadViewIn setDuration:0.5];
    [applicationLoadViewIn setType:kCATransitionReveal];
    [applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
    //you view need to replace
    [applicationLoadViewIn setDuration:0.5];
    [applicationLoadViewIn setType:kCATransitionMoveIn];
    [applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
    //you view need to replace
    [[view1 layer]addAnimation:applicationLoadViewIn forKey:kCATransitionMoveIn];
    [[view1 layer]addAnimation:applicationLoadViewIn forKey:kCATransitionReveal];
    
    [view1 reloadInputViews];
    [self.view reloadInputViews];
    
    
    
}
#pragma mark -view的手势的变化
-(void)backView
{
    [self faceToAN:self.passView];
    [self faceToAN:self.registerView];
    self.passView.hidden=YES;
    self.registerView.hidden =YES;
    self.view.backgroundColor=[UIColor whiteColor];
 [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor] ];
       // self.ThirdPartyQQ.hidden =NO;
        self.ThirdPartyWeChat.hidden =NO;
     self.thirdStr =@"";
}
-(void)jjj
{
    self.view.backgroundColor =[UIColor lightGrayColor];
     [self.navigationController.navigationBar setBarTintColor:[UIColor lightGrayColor] ];
    _registerView =[[UIView alloc]init];
    _registerView.backgroundColor=[UIColor whiteColor];
    _registerView.layer.cornerRadius=10.0;
    [self.view addSubview:_registerView];
//    [_registerView mas_makeConstraints:^(MASConstraintMaker *make) {
//        if([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568)
//        {
//            make.top.mas_equalTo(self.view).mas_equalTo(170);
//        }else{
//            make.top.mas_equalTo(self.view).mas_equalTo(200);
//        }
//        make.left.mas_equalTo(20);
//        make.right.mas_equalTo(-20);
//        make.height.mas_equalTo(290);
//    }];
    //    //注册
    _registLabelTwo =[[UILabel alloc]init];
        _registLabelTwo.text=@"找回密码";
        self.changeBut=NO;
 
    _registLabelTwo.font =[UIFont systemFontOfSize:20];
    _registLabelTwo.textColor=[UIColor blackColor];
    _registLabelTwo.textAlignment=NSTextAlignmentCenter;
    [_registerView addSubview:_registLabelTwo];
    [_registLabelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(90, 20));
        make.top.mas_equalTo(35);
        make.centerX.mas_equalTo(0);
    }];
    //
    _telephoneRE =[[UIImageView alloc]init];
    _telephoneRE.image =[UIImage imageNamed:@"手机号"];
    [_registerView addSubview:_telephoneRE];
    [_telephoneRE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 22));
        make.top.mas_equalTo(_registLabelTwo.mas_bottom).mas_equalTo(20);
        make.left.mas_equalTo(35);
    }];
    _lineImage =[[UIImageView alloc]init];
    _lineImage.backgroundColor =[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0];
    [_registerView addSubview:_lineImage];
    [_lineImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.registerView.mas_width).mas_equalTo(-20);
        make.height.mas_equalTo(2);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_telephoneRE.mas_bottom).mas_equalTo(5);
    }];
    _passwordRE=[[UIImageView alloc]init];
    _passwordRE.image =[UIImage imageNamed:@"密码注册"];
    [_registerView addSubview:_passwordRE];
    [_passwordRE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 22));
        make.top.mas_equalTo(_lineImage.mas_bottom).mas_equalTo(35);
        make.left.mas_equalTo(35);
    }];
    
    _lineImage2=[[UIImageView alloc]init];
    _lineImage2.backgroundColor =[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0];
    [_registerView addSubview:_lineImage2];
    [_lineImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.registerView.mas_width).mas_equalTo(-20);
        make.height.mas_equalTo(2);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_passwordRE.mas_bottom).mas_equalTo(5);
    }];
//    _back=[UIButton buttonWithType:UIButtonTypeCustom];
//    [_back setTitle:@"返回" forState:UIControlStateNormal];
//    [_back setTitleColor:[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0]  forState:UIControlStateNormal];
//    _back.titleLabel.font = [UIFont systemFontOfSize:14];
//    [_back addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
//    [_registerView addSubview: _back];
//    [_back mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(3);
//        make.leftMargin.mas_equalTo(_lineImage2.mas_leftMargin);
//    }];
    _textField1RE=[UITextField new];
    _textField1RE.placeholder=@"请输入您的手机号";
    _textField1RE.font=[UIFont systemFontOfSize:14];
    _textField1RE.clearButtonMode=UITextFieldViewModeWhileEditing;
     _textField1RE.keyboardType =UIKeyboardTypeNumberPad;
    _textField1RE.delegate=self;
    [_registerView addSubview:_textField1RE];
    [_textField1RE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(250, 22));
        make.left.mas_equalTo(_telephoneRE.mas_right).mas_equalTo(10);
        make.bottomMargin.mas_equalTo(_telephoneRE.mas_bottomMargin);
    }];
    _textField2RE=[UITextField new];
    _textField2RE.placeholder = @"验证码";
    _textField2RE.font = [UIFont systemFontOfSize:14];
    _textField2RE.clearButtonMode = UITextFieldViewModeWhileEditing;
    _textField2RE.delegate=self;
    [_registerView addSubview:_textField2RE];
    [_textField2RE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(130, 22));
        make.left.mas_equalTo(_passwordRE.mas_right).mas_equalTo(10);
        make.topMargin.mas_equalTo(_passwordRE.mas_bottomMargin);
    }];
    
    _verificationCodeButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [_verificationCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    [_verificationCodeButton setTitleColor:[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0]  forState:UIControlStateNormal];
    _verificationCodeButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [_verificationCodeButton addTarget:self action:@selector(verificationCodeButtonmetho:) forControlEvents:UIControlEventTouchUpInside];
    _verificationCodeButton.titleLabel.textAlignment=NSTextAlignmentRight;
    [_registerView addSubview: _verificationCodeButton];
    [_verificationCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.topMargin.mas_equalTo(_passwordRE.mas_topMargin);
        make.right.mas_equalTo(-20);
    }];
    _buttonForLogRE=[UIButton buttonWithType:UIButtonTypeCustom];
    [_buttonForLogRE setTitle:@"确定" forState:UIControlStateNormal];
    [_buttonForLogRE setTintColor:[UIColor whiteColor]];
    _buttonForLogRE.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    _buttonForLogRE.titleLabel.font = [UIFont systemFontOfSize:26];
    [_buttonForLogRE addTarget:self action:@selector(buttonForLogRE:) forControlEvents:UIControlEventTouchUpInside];
    _buttonForLogRE.layer.cornerRadius=9.0;
    [_registerView addSubview: _buttonForLogRE];
    [_buttonForLogRE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.registerView.mas_width).mas_equalTo(-20);
        make.height.mas_equalTo(40);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_lineImage2.mas_bottom).mas_equalTo(45);
    }];



}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
    if (_textField1.text.length >0 && (_textField2.text.length <= 16) && (_textField2.text.length > 0)) {
        _buttonForLog.backgroundColor=[UIColor colorWithRed:35/255.0 green:168/255.0 blue:222/255.0 alpha:1.0];
        _buttonForLog.userInteractionEnabled =YES;
    }else
    {
        _buttonForLog.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
        _buttonForLog.userInteractionEnabled =NO;
    }
    if (_textField1RE.text.length >0 && _textField2RE.text.length >0) {
        _buttonForLogRE.backgroundColor=[UIColor colorWithRed:49/255.0 green:160/255.0 blue:126/255.0 alpha:1.0];
    }else
    {
        _buttonForLogRE.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    }
    if (_textField1PSS.text.length >0 && _textField2PSS.text.length >0) {
        _buttonTranslateMain.backgroundColor=[UIColor colorWithRed:49/255.0 green:160/255.0 blue:126/255.0 alpha:1.0];
    }else
    {
        _buttonTranslateMain.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    }

}


-(void)alertSHOW:(NSString*)str{
    
       //截取手机号码后四位
    if (str.length  == 11) {
 
        UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"请输入验证码%@",str] message:nil preferredStyle:UIAlertControllerStyleAlert];
//        __weak __typeof(self)weakSelf = self;
        [alertCon addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }]];
        [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
            });
        }]];
        [self presentViewController:alertCon animated:YES completion:nil];
    }else{
        UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"请输入验证码%@",str] message:nil preferredStyle:UIAlertControllerStyleAlert];
//        __weak __typeof(self)weakSelf = self;
        [alertCon addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }]];
        [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
            });
        }]];
        
        
        
    }
    
    
    
 
    
}








#pragma mark - private methods
- (void)showLoading{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.view addSubview:self->_hud];
        [self->_hud mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(0);
        }];
        self->_hud.hidden = NO;
        [self->_hud startAnimating];
    });
}
- (void)hideLoading{
    dispatch_async(dispatch_get_main_queue(), ^{
        self->_hud.hidden = YES;
        [self->_hud stopAnimating];
    });
}
- (void)getPhonenumber{
    NSString * telecom = [self.completeResultData valueForKey:@"telecom"];
    NSLog(@"Success:%@",self.completeResultData);
    NSString * urlStr = nil;
    if ([telecom isEqualToString:@"CMCC"]) {
        urlStr = [cl_SDK_URL stringByAppendingString:@"open/flashsdk/mobile-query-m"];
    }else if ([telecom isEqualToString:@"CUCC"]) {
        urlStr = [cl_SDK_URL stringByAppendingString:@"open/flashsdk/mobile-query-u"];
    }else if ([telecom isEqualToString:@"CTCC"]) {
        urlStr = [cl_SDK_URL stringByAppendingString:@"open/flashsdk/mobile-query-t"];
    }else{
        //失败
        //[SVProgressHUD showInfoWithStatus:@"此手机无SIM卡或不是联通卡"];
        return;
    }
    
    NSLog(@"tokenParamr:%@",self.completeResultData);
    [self showLoading];
    
    __weak typeof(self) weakSelf = self;
    
    [NetWorkManager POST_url:urlStr withParameter:self.completeResultData complete:^(NSDictionary * _Nonnull responseObject, NSError * _Nonnull error) {
        
        [self hideLoading];
        
        if (error) {
            weakSelf.error = [NSError errorWithDomain:[NSString stringWithFormat:@"手机号查询接口网络异常:%@",error.localizedDescription] code:error.code userInfo:error.userInfo];
            dispatch_async(dispatch_get_main_queue(), ^{
                // [weakSelf setFailedView];
            });
            NSLog(@"短信error%@",error);
        }else{
            //响应code码。200000：成功，其他失败，来源：闪验后台接入文档
            NSInteger code = [[responseObject valueForKey:@"code"] integerValue];
            if (code == 200000) {
                NSString * mobileName = responseObject[@"data"][@"mobileName"];
                mobileName = [NetWorkInfoManager replaceUnicode:mobileName];
                NSString * mobileCode = [mobileName decryptUseDESKey:cl_SDK_APPKEY];
                
                NSLog(@"免密登录成功,手机号：%@",mobileCode);
                [SVProgressHUD setContainerView:weakSelf.view];
                [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"免密登录成功,手机号：%@",mobileCode]];
                
                weakSelf.timeStr = [NSString stringWithFormat:@"%.2f",CFAbsoluteTimeGetCurrent() - weakSelf.timesStart];
                weakSelf.phoneNumStr = mobileCode;
                dispatch_async(dispatch_get_main_queue(), ^{
                    // [weakSelf setSuccessView];
                });
            } else {
                NSString * retMsg = [responseObject valueForKey:@"retMsg"];
                NSString * code = [responseObject valueForKey:@"code"];
                NSString * chargeStatus = [responseObject valueForKey:@"chargeStatus"];
                
                if (!retMsg) {
                    retMsg = @"免密登录失败";
                }
                if (!code) {
                    code = [NSString stringWithFormat:@"%@",chargeStatus];
                }
                weakSelf.error = [NSError errorWithDomain:retMsg code:[code integerValue] userInfo:responseObject];
                dispatch_async(dispatch_get_main_queue(), ^{
                    //[weakSelf setFailedView];
                });
            }
        }
    }];
}


#pragma mark - getters and setters
- (UIImageView *)viewBackGround
{
    if (!_viewBackGround) {
        _viewBackGround =[[UIImageView alloc]init];
        _viewBackGround.contentMode =UIViewContentModeScaleAspectFit;
        _viewBackGround.image =[UIImage imageNamed:@"背景_图"];
        _viewBackGround.clipsToBounds=YES;
    }
    return _viewBackGround;
}

- (UIButton *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel =[UIButton buttonWithType:UIButtonTypeCustom];
        
        NSString *timeInt =[self getTheTimeBucket];
        
        if (!timeInt || timeInt != NULL ) {
            
            if ((int)timeInt > 12) {
                [_timeLabel setTitle:timeInt forState:UIControlStateNormal];
                
            }
        }else{
            
            [_timeLabel setTitle:@"下午好!" forState:UIControlStateNormal];
        }
        
        
        [_timeLabel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _timeLabel.titleLabel.font =[UIFont systemFontOfSize:42 weight:20];
        _timeLabel.titleLabel.textAlignment=NSTextAlignmentLeft;
        _timeLabel.userInteractionEnabled =NO;
        // [_timeLabel addTarget:self action:@selector(tapLabel:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _timeLabel;
}

- (UIImageView *)nameImage
{
    if (!_nameImage) {
        _nameImage =[[UIImageView alloc]init];
        _nameImage.image =[UIImage imageNamed:@""];
    }
    return _nameImage;
}

- (UIImageView *)lineImage
{
    if (!_lineImage) {
        _lineImage =[[UIImageView alloc]init];
        _lineImage.backgroundColor =[UIColor clearColor];
    }
    return _lineImage;
}
- (UIImageView *)passwordImage
{
    if (!_passwordImage) {
        _passwordImage =[[UIImageView alloc]init];
        _passwordImage.image =[UIImage imageNamed:@""];
    }
    return _passwordImage;
}

- (UIImageView *)lineImage2
{
    if (!_lineImage2) {
        _lineImage2=[[UIImageView alloc]init];
        _lineImage2.backgroundColor =[UIColor clearColor];
    }
    return _lineImage2;
}

- (UIButton *)buttonForLog
{
    if (!_buttonForLog) {
        _buttonForLog=[UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonForLog setTitle:@"登录" forState:UIControlStateNormal];
        [_buttonForLog setTintColor:[UIColor whiteColor]];
        _buttonForLog.userInteractionEnabled =NO;
        _buttonForLog.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
        _buttonForLog.titleLabel.font = [UIFont systemFontOfSize:26];
        [_buttonForLog addTarget:self action:@selector(registerBtnClick) forControlEvents:UIControlEventTouchUpInside];
        _buttonForLog.layer.cornerRadius=22.0;
    }
    return _buttonForLog;
}

- (UIButton *)ForgetPassWorldLabel
{
    if (!_ForgetPassWorldLabel) {
        _ForgetPassWorldLabel =[UIButton buttonWithType:UIButtonTypeCustom];
        [_ForgetPassWorldLabel setTitle:@"找回密码" forState:UIControlStateNormal];
        [_ForgetPassWorldLabel setTitleColor:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0] forState:UIControlStateNormal];
        
        
        _ForgetPassWorldLabel.titleLabel.font =[UIFont systemFontOfSize:15];
        _ForgetPassWorldLabel.titleLabel.textAlignment=NSTextAlignmentLeft;
        [_ForgetPassWorldLabel addTarget:self action:@selector(tapLabel:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ForgetPassWorldLabel;
}


- (UIButton *)RegisterPasswordLabel
{
    if (!_RegisterPasswordLabel) {
        _RegisterPasswordLabel =[UIButton buttonWithType:UIButtonTypeCustom];
        [_RegisterPasswordLabel setTitle:@"注册z" forState:UIControlStateNormal];
        
        [_RegisterPasswordLabel setTitleColor:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0] forState:UIControlStateNormal];
        _RegisterPasswordLabel.titleLabel.font = [UIFont systemFontOfSize:15];
        
        [_RegisterPasswordLabel addTarget:self action:@selector(tapLabel:) forControlEvents:UIControlEventTouchUpInside];
        _RegisterPasswordLabel.titleLabel.textAlignment=NSTextAlignmentRight ;
    }
    return _RegisterPasswordLabel;
}

- (UIButton *)freeRegistrationLabel
{
    if (!_freeRegistrationLabel) {
        _freeRegistrationLabel =[UIButton buttonWithType:UIButtonTypeCustom];
        //[_RegisterPasswordLabel setTitle:@"注册账号" forState:UIControlStateNormal];
        [_freeRegistrationLabel setTitle:@"" forState:UIControlStateNormal];
        [_freeRegistrationLabel setTintColor:[UIColor whiteColor]];
        _freeRegistrationLabel.titleLabel.font = [UIFont systemFontOfSize:15];
        
        //    _RegisterPasswordLabel.backgroundColor=[UIColor colorWithRed:35/255.0 green:168/255.0 blue:222/255.0 alpha:1.0];
        [_freeRegistrationLabel setTitleColor:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0] forState:UIControlStateNormal];
        //    _RegisterPasswordLabel.layer.cornerRadius=11.0;
        //[_freeRegistrationLabel addTarget:self action:@selector(tapLabel:) forControlEvents:UIControlEventTouchUpInside];
        _freeRegistrationLabel.titleLabel.textAlignment=NSTextAlignmentRight ;
    }
    return _freeRegistrationLabel;
}

- (UILabel *)weixinLabel
{
    if (!_weixinLabel) {
        _weixinLabel =[[UILabel alloc]init];
        _weixinLabel.font  = [UIFont systemFontOfSize:15];
        
        _weixinLabel.text = @"第三方登入";
        _weixinLabel.textColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
        _weixinLabel.textAlignment=NSTextAlignmentCenter;
    }
    return _weixinLabel;
}

- (UIImageView *)lineImage4
{
    if (!_lineImage4) {
        _lineImage4=[[UIImageView alloc]init];
        _lineImage4.backgroundColor =[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    }
    return _lineImage4;
}

- (UIImageView *)lineImage3
{
    if (!_lineImage3) {
        _lineImage3=[[UIImageView alloc]init];
        _lineImage3.backgroundColor =[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    }
    return _lineImage3;
}

- (UIButton *)ThirdPartyWeChat
{
    if (!_ThirdPartyWeChat) {
        _ThirdPartyWeChat =[UIButton buttonWithType:UIButtonTypeCustom];
        [_ThirdPartyWeChat setBackgroundImage:[UIImage imageNamed:@"微信"] forState:UIControlStateNormal];
        [_ThirdPartyWeChat addTarget:self action:@selector(tapWeChat) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ThirdPartyWeChat;
}

- (UIButton *)emailLabel
{
    if (!_emailLabel) {
        _emailLabel =[UIButton buttonWithType:UIButtonTypeCustom];
        [_emailLabel setTitle:@"短信快捷登录" forState:UIControlStateNormal];
        [_emailLabel setTitleColor:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0] forState:UIControlStateNormal];
        _emailLabel.titleLabel.font =[UIFont systemFontOfSize:15];
        _emailLabel.titleLabel.textAlignment=NSTextAlignmentLeft;
        
        [_emailLabel addTarget:self action:@selector(tapLabel:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _emailLabel;
}

- (UIButton *)ThirdPartyQQ
{
    if (!_ThirdPartyQQ) {
        _ThirdPartyQQ =[UIButton buttonWithType:UIButtonTypeCustom];
        [_ThirdPartyQQ setBackgroundImage:[UIImage imageNamed:@"QQ"] forState:UIControlStateNormal];
        [_ThirdPartyQQ addTarget:self action:@selector(tapQQ) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ThirdPartyQQ;
}

- (UITextField *)textField1
{
    if (!_textField1) {
        _textField1=[UITextField new];
        _textField1.placeholder=@" 请输入手机号";
        _textField1.font=[UIFont systemFontOfSize:14];
        _textField1.clearButtonMode=UITextFieldViewModeWhileEditing;
        _textField1.keyboardType = UIKeyboardTypeNumberPad;
        _textField1.layer.borderColor = [UIColor colorWithRed:201/255.0 green:201/255.0 blue:201/255.0 alpha:0.5].CGColor;
        _textField1.layer.borderWidth = 1.0f;
        
        _textField1.delegate=self;
        
        [self textFieldAddTwoBlackPlaceinTextFiled:_textField1];
    }
    return _textField1;
}

- (UITextField *)textField2
{
    if (!_textField2) {
        _textField2=[UITextField new];
        _textField2.placeholder = @" 请输入密码";
        _textField2.font = [UIFont systemFontOfSize:14];
        _textField2.clearButtonMode = UITextFieldViewModeWhileEditing;
        _textField2.secureTextEntry=YES;
        _textField2.delegate=self;
        _textField2.layer.borderColor = [UIColor colorWithRed:201/255.0 green:201/255.0 blue:201/255.0 alpha:0.5].CGColor;
        _textField2.layer.borderWidth = 1.0f;
        [self textFieldAddTwoBlackPlaceinTextFiled:_textField2];
    }
    return _textField2;
}


//动画View
- (UIView *)registerView
{
    if (!_registerView) {
        _registerView =[[UIView alloc]init];
       
//        if ([[UIScreen mainScreen]bounds].size.height == 480 || [[UIScreen mainScreen]bounds].size.height == 568) {
//            _registerView.frame = CGRectMake(20, 170, self.view.bounds.size.width - 40, 290);
//        } else {
//            _registerView.frame = CGRectMake(20, 200, self.view.bounds.size.width - 40, 290);
//        }
        _registerView.backgroundColor=[UIColor whiteColor];
        _registerView.layer.cornerRadius=10.0;
    }
    return _registerView;
}

- (UILabel *)registLabelTwo
{
    if (!_registLabelTwo) {
        _registLabelTwo =[[UILabel alloc]init];
        _registLabelTwo.font  = [UIFont fontWithName:@"ArialMT" size:20];
        _registLabelTwo.textColor=[UIColor blackColor];
        _registLabelTwo.textAlignment=NSTextAlignmentCenter;
        //    //注册
        if ([self.thirdStr isEqualToString:@"登入"]){
           _registLabelTwo.text=@"第三方登入注册";}else{ _registLabelTwo.text=@"短信快捷登录";}
    }
    return _registLabelTwo;
}
- (UIImageView *)telephoneRE
{
    if (!_telephoneRE) {
        _telephoneRE =[[UIImageView alloc]init];
        _telephoneRE.image =[UIImage imageNamed:@"手机号"];
    }
    return _telephoneRE;
}
- (UIImageView *)lineImage11
{
    if (!_lineImage11) {
        _lineImage11 =[[UIImageView alloc]init];
        _lineImage11.backgroundColor =[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0];
    }
    return _lineImage11;
}
- (UIImageView *)passwordRE
{
    if (!_passwordRE) {
        _passwordRE=[[UIImageView alloc]init];
        _passwordRE.image =[UIImage imageNamed:@"密码注册"];
    }
    return _passwordRE;
}
- (UIImageView *)lineImage22
{
    if (!_lineImage22) {
        _lineImage22 =[[UIImageView alloc]init];
        _lineImage22.backgroundColor =[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0];
    }
    return _lineImage22;
}

- (UIButton *)back
{
    if (!_back) {
        _back=[UIButton buttonWithType:UIButtonTypeCustom];
        [_back setTitle:@"返回" forState:UIControlStateNormal];
        [_back setTitleColor:[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0]  forState:UIControlStateNormal];
        _back.titleLabel.font = [UIFont systemFontOfSize:14];
        [_back addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
    }
    return _back;
}

- (UITextField *)textField1RE
{
    if (!_textField1RE) {
        _textField1RE=[UITextField new];
        _textField1RE.placeholder=@"请输入您的手机号";
        _textField1RE.keyboardType =UIKeyboardTypeNumberPad;
        _textField1RE.font=[UIFont systemFontOfSize:14];
        _textField1RE.clearButtonMode=UITextFieldViewModeWhileEditing;
        _textField1RE.delegate=self;
    }
    return _textField1RE;
}

- (UITextField *)textField2RE
{
    if (!_textField2RE) {
        _textField2RE=[UITextField new];
        _textField2RE.placeholder = @"验证码";
        _textField2RE.keyboardType =UIKeyboardTypeNumberPad;
        _textField2RE.font = [UIFont systemFontOfSize:14];
        _textField2RE.clearButtonMode = UITextFieldViewModeWhileEditing;
        _textField2RE.delegate=self;
    }
    return _textField2RE;
}
- (UIButton *)verificationCodeButton
{
    if (!_verificationCodeButton) {
        _verificationCodeButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_verificationCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
        [_verificationCodeButton setTitleColor:[UIColor colorWithRed:90/255.0 green:178/255.0 blue:225/255.0 alpha:1.0]  forState:UIControlStateNormal];
        _verificationCodeButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_verificationCodeButton addTarget:self action:@selector(verificationCodeButtonmetho:) forControlEvents:UIControlEventTouchUpInside];
        _verificationCodeButton.titleLabel.textAlignment=NSTextAlignmentRight;
    }
    return _verificationCodeButton;
}

- (UIButton *)buttonForLogRE
{
    if (!_buttonForLogRE) {
        _buttonForLogRE=[UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonForLogRE setTitle:@"确定" forState:UIControlStateNormal];
        [_buttonForLogRE setTintColor:[UIColor whiteColor]];
        _buttonForLogRE.backgroundColor=[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
        _buttonForLogRE.titleLabel.font = [UIFont systemFontOfSize:26];
        [_buttonForLogRE addTarget:self action:@selector(buttonForLogRE:) forControlEvents:UIControlEventTouchUpInside];
        _buttonForLogRE.layer.cornerRadius=9.0;
    }
    return _buttonForLogRE;
}
- (UIButton *)fuwuxiyiButton
{
    if (!_fuwuxiyiButton) {
        _fuwuxiyiButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_fuwuxiyiButton setImage:[UIImage imageNamed:@"check_unselected"] forState:UIControlStateNormal];
        [_fuwuxiyiButton setImage:[UIImage imageNamed:@"check_selected"] forState:UIControlStateSelected];
        [_fuwuxiyiButton addTarget:self action:@selector(fuwuQueren:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _fuwuxiyiButton;
}
- (UIButton *)fuwuxiyiLabel
{
    if (!_fuwuxiyiLabel) {
        _fuwuxiyiLabel=[UIButton buttonWithType:UIButtonTypeCustom];
        [_fuwuxiyiLabel setTitleColor:kRGBColor(51, 51, 51) forState:UIControlStateNormal];
        [_fuwuxiyiLabel setTitle:@"同意看看生活" forState:UIControlStateNormal];
        _fuwuxiyiButton.selected =YES;
        _fuwuxiyiLabel.titleLabel.font = [UIFont systemFontOfSize:12];
        [_fuwuxiyiLabel addTarget:self action:@selector(kankanShebaoXieyi) forControlEvents:UIControlEventTouchUpInside];
    }
    return _fuwuxiyiLabel;
}

- (UIButton *)fuwuxiyiLabel2
{
    if (!_fuwuxiyiLabel2) {
        _fuwuxiyiLabel2=[UIButton buttonWithType:UIButtonTypeCustom];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"服务协议"];
        NSRange strRange = {0,[str length]};
        [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:strRange];
        
        [_fuwuxiyiLabel2 setAttributedTitle:str forState:UIControlStateNormal];
        [ _fuwuxiyiLabel2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        //        [self.fuwuxiyiLabel2 setTitle:@"服务协议" forState:UIControlStateNormal];
        _fuwuxiyiLabel2.titleLabel.font = [UIFont systemFontOfSize:12];
        [_fuwuxiyiLabel2 addTarget:self action:@selector(kankanShebaoXieyi) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _fuwuxiyiLabel2;
}
@end
