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

#import "FandRViewController.h"
#import "AppDelegate.h"
#import "UITextField+Shake.h"
#import "logViewController.h"
#import "kankanshebaoxieyi.h"
@interface FandRViewController ()<UITextFieldDelegate>

//

@end
//判断两者的关系

@implementation FandRViewController

+ (FandRViewController *)sharedInstance{
    static FandRViewController *p;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        p = [LoginViewController new];
    });
    return p;
}


-(void)buttonClick_1{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

#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.navigationItem.leftBarButtonItem = backButtonItem_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.view addSubview:self.viewBackGround];
    [self.view addSubview:self.timeLabel];
    

    //隐藏视图添加
    [self.view addSubview: self.buttonForLog];
    [self.view addSubview:self.ForgetPassWorldLabel];
    [self.view addSubview:self.RegisterPasswordLabel];
    [self.view addSubview:self.weixinLabel];
    [self.view addSubview:self.ThirdPartyWeChat];
    [self.view addSubview:self.emailLabel];
    [self.view addSubview:self.ThirdPartyQQ];
   
    
    //真正的UI
    [self.view addSubview:self.textField1RE];
    //[self textFieldAddTwoBlackPlaceinTextFiled:_textField1RE];
    [self.view addSubview:self.lineImage];
    [self.view addSubview:self.textField2RE];
    [self.view addSubview:self.lineImage2];
    [self.view addSubview: self.verificationCodeButton];
    [self.view addSubview:self.textField1PSS];
    [self.view addSubview:self.lineImage3];
    [self.view addSubview:self.textField2PSS];
    [self.view addSubview:self.lineImage4];
    [self.view addSubview: self.fuwuxiyiButton];
    [self.view addSubview: self.fuwuxiyiLabel];
    [self.view addSubview: self.fuwuxiyiLabel2];
    [self.view addSubview: self.buttonTranslateMain];
    
  //  [self createField];
}

-(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]];
}


-(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 =YES;
    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];
    //    });
    
    
    
    __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(_viewBackGround.mas_bottom).mas_equalTo(15);
        // make.leftMargin.mas_equalTo(_viewBackGround.mas_leftMargin).mas_equalTo(15);
        make.centerX.mas_equalTo(weakSelf.view);
    }];
    
    
    
    //隐藏控件的约束
    
    [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(45);
        }else{
            make.top.mas_equalTo(weakSelf.lineImage2.mas_bottom).mas_equalTo(55);
        }
        
    }];
    [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.leftMargin.mas_equalTo(weakSelf.buttonForLog.mas_leftMargin);
    }];
    
    [self.RegisterPasswordLabel 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(5);
        make.leftMargin.mas_equalTo(weakSelf.buttonForLog.mas_leftMargin);
        
        //
    }];
    [self.weixinLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.RegisterPasswordLabel.mas_bottom).mas_equalTo(5);
        make.centerX.mas_equalTo(0);
        
    }];
    [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.emailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.centerX.mas_equalTo(70);
        make.topMargin.mas_equalTo(weakSelf.ForgetPassWorldLabel.mas_topMargin);
        make.rightMargin.mas_equalTo(weakSelf.buttonForLog.mas_rightMargin);
    }];
    [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));
    }];
    //
    //    _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));
    //    }];
    
    
    //未隐藏的UI
    [self.textField1RE mas_makeConstraints:^(MASConstraintMaker *make) {
        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(35);
        // make.left.mas_equalTo(_nameImage.mas_right).mas_equalTo(0);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.timeLabel.mas_bottom).mas_equalTo(20);
        
    }];
    [self.lineImage mas_makeConstraints:^(MASConstraintMaker *make) {
        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(1);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.textField1RE.mas_bottom).mas_equalTo(1);
    }];
    
    // [self textFieldAddTwoBlackPlaceinTextFiled:_textField2RE];
    [self.textField2RE mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(100, 35));
        make.leftMargin.mas_equalTo(weakSelf. viewBackGround.mas_leftMargin).mas_equalTo(0);
        // make.rightMargin.mas_equalTo(_viewBackGround.mas_rightMargin).mas_equalTo(0);
       // make.height.mas_equalTo(35);
        // make.left.mas_equalTo(_nameImage.mas_right).mas_equalTo(0);
        //make.centerX.mas_equalTo(0);
        
        make.top.mas_equalTo(weakSelf.textField1RE.mas_bottom).mas_equalTo(20);
        
        
    }];
    
    [self.lineImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        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(1);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.textField2RE.mas_bottom).mas_equalTo(1);
    }];
    [self.verificationCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.size.mas_equalTo(CGSizeMake(130, 22));
        make.rightMargin.mas_equalTo(weakSelf.lineImage.mas_rightMargin);
        make.centerY.mas_equalTo(weakSelf.textField2RE.mas_centerY);
    }];
    [self.textField1PSS mas_makeConstraints:^(MASConstraintMaker *make) {
        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(35);
        // make.left.mas_equalTo(_nameImage.mas_right).mas_equalTo(0);
        make.centerX.mas_equalTo(0);
        
        make.top.mas_equalTo(weakSelf.textField2RE.mas_bottom).mas_equalTo(20);
    }];
    
    [self.lineImage3 mas_makeConstraints:^(MASConstraintMaker *make) {
        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(1);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.textField1PSS.mas_bottom).mas_equalTo(1);
    }];
    
    [self.textField2PSS mas_makeConstraints:^(MASConstraintMaker *make) {
        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(35);
        // make.left.mas_equalTo(_nameImage.mas_right).mas_equalTo(0);
        make.centerX.mas_equalTo(0);
        
        make.top.mas_equalTo(weakSelf.textField1PSS.mas_bottom).mas_equalTo(20);
    }];
    
    [self.lineImage4 mas_makeConstraints:^(MASConstraintMaker *make) {
        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(1);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.textField2PSS.mas_bottom).mas_equalTo(1);
    }];
    
    [self.fuwuxiyiButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leftMargin.mas_equalTo(weakSelf.textField2PSS.mas_leftMargin);
        make.top.mas_equalTo(weakSelf.textField2PSS.mas_bottom).mas_equalTo(20);
    }];
    [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);
    }];
    [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);
    }];
    [self.buttonTranslateMain mas_makeConstraints:^(MASConstraintMaker *make) {
        
        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(40);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(weakSelf.fuwuxiyiButton.mas_bottom).mas_equalTo(20);
    }];
    
    
}


-(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 =YES;
            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 popToRootViewControllerAnimated: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:@"登录成功"];
            [self.navigationController popToRootViewControllerAnimated: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];
        }else{
            self.thirdStr =@"";
            codeSelected *code = [codeSelected MustTakeReturn:[model.status intValue]];
            [code returnCodeMethod];
        }
    }];
    
    
    
}



#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:@"登录成功"];
                [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 && _textField2RE.text.length >0 && _textField1RE.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;
    //  self.ThirdPartyQQ.hidden =YES;
    
    
    if (sender == self.RegisterPasswordLabel) {
        self.changeBut =YES;
        self.emailSender = NO;
    }
    
    
    

    
    NSLog(@"...");
    
    //ui
    self.view.backgroundColor =[UIColor lightGrayColor];
    _registerView =[[UIView alloc]init];
    [self.navigationController.navigationBar setBarTintColor:[UIColor lightGrayColor] ];
    
    _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);
    }];
    
    //动画
    [self faceToAN:_registerView];
    
    
    //    //注册
    _registLabelTwo =[[UILabel alloc]init];
    if (sender ==self.ForgetPassWorldLabel) {
        _registLabelTwo.text=@"找回密码";
        self.changeBut=NO;
    }else if(sender == self.RegisterPasswordLabel)
    {
        _registLabelTwo.text=@"注册";
        self.changeBut =YES;
        self.emailSender = NO;
    }else
    {
        
        
        if ([self.thirdStr isEqualToString:@"登入"]){
            _registLabelTwo.text=@"第三方登入注册";}else{ _registLabelTwo.text=@"短信快捷登录";}
        
        
    }
    if (self.editText == YES) {
        _registLabelTwo.text=@"找回密码";
    }
    
    
    
    
    _registLabelTwo.font  = [UIFont fontWithName:@"ArialMT" size:20];
    _registLabelTwo.textColor=[UIColor blackColor];
    _registLabelTwo.textAlignment=NSTextAlignmentCenter;
    [_registerView addSubview:_registLabelTwo];
    [_registLabelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(35);
        make.centerX.mas_equalTo(0);
        
    }];
    
    
    
//////////////////

    
  
}


-(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];
                    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 ;
                    }

                   
                    
                    if ([model.code isEqualToString:@"12"]) {
                        SVProgressHUD.minimumDismissTimeInterval=1.0;
                         [SVProgressHUD showErrorWithStatus:@"此手机没有注册"];
                        self.verificationCodeButton.userInteractionEnabled =YES;
                        self.passView.hidden =YES;
                        [self backView];
                       // self.timeCount = 1;
                        [self.timer invalidate];
                    }else if([model.code isEqualToString:@"0"]){
                    self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];
                    }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];
                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){
                    //打开注册的页面
                    // [self tapLabel:self.RegisterPasswordLabel];
                    
                }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=@"设置密码";
            _registerView.hidden =YES;
            _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.hidden =YES;
            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 =YES;
    
    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.strTitle isEqualToString:@"找回密码"]){
        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 popViewControllerAnimated:YES];
//                dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
//
//                                             (int64_t)(0.1 * NSEC_PER_SEC)),
//
//                               dispatch_get_main_queue(), ^{
//                                   if (self.navigationController) {
//                                       if (self.navigationController.viewControllers.count == 1) {
//                                           [self.navigationController dismissModalViewControllerAnimated:YES];
//                                       } else {
//                                           [self.navigationController popViewControllerAnimated:YES];
//                                       }
//                                   } else {
//                                       [self dismissModalViewControllerAnimated:YES];
//                                   }
//                               });
                
            }else
            {
                codeSelected *code = [codeSelected MustTakeReturn:[model.code intValue]];
                [code returnCodeMethod];
                _passView.hidden =YES;
                _registerView.hidden =YES;
            }
        }];
    }
    
    
    
    if([self.strTitle isEqualToString:@"注册"] || [self.strTitle isEqualToString:@"微信注册"] ){

        
        [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:@"成功"];
           [self.navigationController popViewControllerAnimated:YES];
            }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 ];
               // [self.navigationController popViewControllerAnimated:YES];

                
                
            }else
            {
             
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    codeSelected *code = [codeSelected MustTakeReturn:[model.code intValue]];
                    
                    [code returnCodeMethod];
                    _passView.hidden =YES;
                    _registerView.hidden =YES;
                });
            }
        }];
    }
}

#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 =YES;
    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;
    _registerView.hidden =YES;
    _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:@"密码注册"];
    _passwordRE.hidden =YES;
    [_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);
    }];

    


    
    //注册
    _textField1RE=[UITextField new];
    _textField1RE.placeholder=@"请输入您的手机号";
    _textField1RE.font=[UIFont systemFontOfSize:14];
    _textField1RE.clearButtonMode=UITextFieldViewModeWhileEditing;
    _textField1RE.keyboardType =UIKeyboardTypeNumberPad;
    _textField1RE.delegate=self;
    [self.view addSubview:_textField1RE];
    [_textField1RE mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leftMargin.mas_equalTo(_viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(_viewBackGround.mas_rightMargin).mas_equalTo(0);
        make.height.mas_equalTo(54);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_textField2.mas_bottom).mas_equalTo(25);
        

    }];
    _textField2RE=[UITextField new];
    _textField2RE.placeholder = @"验证码";
    _textField2RE.font = [UIFont systemFontOfSize:14];
    _textField2RE.clearButtonMode = UITextFieldViewModeNever;
    _textField2RE.delegate=self;
    [self.view addSubview:_textField2RE];
    [_textField2RE mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leftMargin.mas_equalTo(_viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(_viewBackGround.mas_rightMargin).mas_equalTo(0);
        make.height.mas_equalTo(54);
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_textField1RE.mas_bottom).mas_equalTo(25);

    }];
    
    _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;
    [self.view addSubview: _verificationCodeButton];
    [_verificationCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.topMargin.mas_equalTo(_textField2RE.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;
    [self.view 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(_textField2RE.mas_bottom).mas_equalTo(45);
    }];
    
    
    
}

#pragma mark - event response
-(void)fuwuQueren:(UIButton*)sender
{
    sender.selected =!sender.selected;
    self.isFuWu = sender.enabled;
    
}
-(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 && _textField1RE.text.length >0 && _textField2RE.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)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);
        }
    }];
}



#pragma mark - private methods
-(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;
}
//第三方登入
- (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);
        
        
        
        
        
    }];
}

- (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)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(), ^{
                
                
            });
        }]];
        
        
        
    }
    
}

-(void)createField
{
    _textField1=[UITextField new];
    _textField1.hidden =YES;
    _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.view addSubview:_textField1];
    [self textFieldAddTwoBlackPlaceinTextFiled:_textField1];
    [_textField1 mas_makeConstraints:^(MASConstraintMaker *make) {
        //  make.size.mas_equalTo(CGSizeMake(280, 54));
        
        make.leftMargin.mas_equalTo(_viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(_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(_timeLabel.mas_bottom).mas_equalTo(20);
        }else{
            make.top.mas_equalTo(_timeLabel.mas_bottom).mas_equalTo(25);
        }
    }];
    
    _textField2=[UITextField new];
    _textField2.hidden =YES;
    _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.view addSubview:_textField2];
    [self textFieldAddTwoBlackPlaceinTextFiled:_textField2];
    
    [_textField2 mas_makeConstraints:^(MASConstraintMaker *make) {
        //  make.size.mas_equalTo(CGSizeMake(280, 54));
        make.leftMargin.mas_equalTo(_viewBackGround.mas_leftMargin).mas_equalTo(0);
        make.rightMargin.mas_equalTo(_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(_textField1.mas_bottom).mas_equalTo(-1);
    }];
    
}


//雷俊博把get和set方法位置调整一下,方便看代码
#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 setTitle:self.strTitle forState:UIControlStateNormal];
        // [_timeLabel addTarget:self action:@selector(tapLabel:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _timeLabel;
}

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

- (UILabel *)weixinLabel
{
    if (!_weixinLabel) {
        _weixinLabel =[[UILabel alloc]init];
        _weixinLabel.font  = [UIFont systemFontOfSize:15];
        _weixinLabel.hidden =YES;
        _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;
}

- (UIButton *)ThirdPartyWeChat
{
    if (!_ThirdPartyWeChat) {
        _ThirdPartyWeChat =[UIButton buttonWithType:UIButtonTypeCustom];
        _ThirdPartyWeChat.hidden =YES;
        [_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.hidden =YES;
        [_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.hidden =YES;
        [_ThirdPartyQQ setBackgroundImage:[UIImage imageNamed:@"QQ"] forState:UIControlStateNormal];
        [_ThirdPartyQQ addTarget:self action:@selector(tapQQ) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ThirdPartyQQ;
}


//新添加的控件
- (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;
}

- (UIImageView *)lineImage
{
    if (!_lineImage) {
        _lineImage =[[UIImageView alloc]init];
        _lineImage.backgroundColor =[UIColor grayColor];
    }
    return _lineImage;
}

- (UITextField *)textField2RE
{
    if (!_textField2RE) {
        //验证码
        _textField2RE=[[UITextField alloc]init];
        _textField2RE.placeholder = @"手机验证码";
        _textField2RE.textAlignment =NSTextAlignmentLeft;
        _textField2RE.keyboardType =UIKeyboardTypeNumberPad;
        _textField2RE.font = [UIFont systemFontOfSize:14];
        _textField2RE.clearButtonMode = UITextFieldViewModeNever;
        _textField2RE.delegate=self;
    }
    return _textField2RE;
}
- (UIImageView *)lineImage2
{
    if (!_lineImage2) {
        _lineImage2 =[[UIImageView alloc]init];
        _lineImage2.backgroundColor =[UIColor grayColor];
    }
    return _lineImage2;
}

- (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;
}

- (UITextField *)textField1PSS
{
    
    if (!_textField1PSS) {
        _textField1PSS=[UITextField new];
        _textField1PSS.placeholder = @"请输入新密码";
        _textField1PSS.font=[UIFont systemFontOfSize:14];
        //    _textField1PSS.clearButtonMode=UITextFieldViewModeWhileEditing;
        _textField1PSS.delegate=self;
        _textField1PSS.secureTextEntry =YES;
    }
    return _textField1PSS;
}

- (UIImageView *)lineImage3
{
    if (!_lineImage3) {
        _lineImage3 =[[UIImageView alloc]init];
        _lineImage3.backgroundColor =[UIColor grayColor];
    }
    return _lineImage3;
}

- (UITextField *)textField2PSS
{
    if (!_textField2PSS) {
        _textField2PSS=[UITextField new];
        _textField2PSS.placeholder = @"请重复输入密码";
        
        _textField2PSS.font = [UIFont systemFontOfSize:14];
        _textField2PSS.clearButtonMode = UITextFieldViewModeNever;
        _textField2PSS.secureTextEntry =YES;
        _textField2PSS.delegate=self;
    }
    return _textField2PSS;
}

- (UIImageView *)lineImage4
{
    if (!_lineImage4) {
        _lineImage4 =[[UIImageView alloc]init];
        _lineImage4.backgroundColor =[UIColor grayColor];
    }
    return _lineImage4;
}

- (UIButton *)fuwuxiyiButton
{
    if (!_fuwuxiyiButton) {
        _fuwuxiyiButton=[UIButton buttonWithType:UIButtonTypeCustom];
         _fuwuxiyiButton.selected =YES;
        [_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];
        
        _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;
}

- (UIButton *)buttonTranslateMain
{
    if (!_buttonTranslateMain) {
        _buttonTranslateMain=[UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonTranslateMain setTitle:self.strTitle 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;
    }
    return _buttonTranslateMain;
}


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




@end

