//
//  AuthB1ViewController.m
//  Open
//
//  Created by weface on 2023/8/16.
//  Copyright © 2023 QXY. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AuthB1ViewController.h"
#import "UIView+frameAdjust.h"
#import "RZUserCollectionViewCell.h"
#import "RZBottomCell.h"
#import "rzUserModel.h"
#import "Constants.h"
#import "SocialSecurityApproveSuccessVC.h"
#import "CQColorfulAlertView.h"

#import "InsuredInfoViewController.h"
#import "quickInsuredInfoViewController.h"

#import "SCCaptureCameraController.h"
#import "kankanshebaoxieyi.h"
#import "successViewController.h"
#import "SSTerminationViewController.h"

#import "KKUserAuthViewController.h"

#import "KKAuthWhiteAlertView.h"

#import "KKBanCopyPasteTextField.h"
//电子社保卡导包
#import <esscsdk/esscsdk.h>
#import "AuthB2ViewController.h"
@interface AuthB1ViewController()<UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,SCNavigationControllerDelegate,UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,EESBCallbackDelegate>
{
    UICollectionView* _mainCollectionView;
    UILabel*          _lb_message;
    UIView*           _leftLine;
    UIView*           _rightLine;
    
     NSString *ggtime;
     NSString *ggaddress;
     NSString *ggimage;
     rzUserModel* userModel;
    
    //记录是普通认证还是快速认证
    NSInteger currentIndex;
    NSString* name;
    NSString* idNumber;
    NSString* bak;
    NSString*province;
    NSString* city;
    NSString* county;
}
@property (nonatomic, strong)UIScrollView*scrollView;

@property (nonatomic, strong)UIImageView* topCircleImg;

@property (nonatomic, strong)UIView* whiteView;

@property (nonatomic, strong)UIImageView* nameImg;

@property (nonatomic, strong)UITextField*nameText;

@property (nonatomic, strong)KKBanCopyPasteTextField*IDText;

@property (nonatomic, strong)UIView* hideView;

@property (nonatomic, strong)UIButton* button_xieyi;

@property (nonatomic, strong)UIButton* PhotoBtn;

@property (nonatomic, strong)UICollectionView* collectionView;

@property (nonatomic, strong)UIView*backImgView;
@property (nonatomic, strong)UIImageView*topBg;

@property (nonatomic, strong)UIImageView*videoImage;

@property (nonatomic, strong)UIView*clearView;

@property (nonatomic, strong)UIImageView*cardImage;

@property (nonatomic, strong)UIButton* cardBtn;

@property (nonatomic, strong)UIButton* agressBtn;

@property (nonatomic, strong)NSMutableArray* dataArray;

@property(nonatomic)BOOL isEnter;

@property(nonatomic,strong)NSString  *ocrBase64;
@property(nonatomic,strong)NSString *ocrBase64_;


@property(nonatomic,strong)     NSMutableArray *array;
@property(nonatomic,strong)     NSMutableArray *baochunShuZu;
@property(nonatomic,strong)     NSMutableArray *dataArr;

@end

@implementation AuthB1ViewController

-(void) viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self navigationConfig];
    [self.view addSubview:self.scrollView];
    [self creatBottomView];
    
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(jiePing) name:UIApplicationUserDidTakeScreenshotNotification  object:nil];//禁止截屏
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    if ([getPeopleID getpeopleLimited]) {
        self.isEnter = YES;
    }else{
        self.isEnter = NO;
    }
    
    @try {
        //此处写可能出现崩溃的代码
        //数组插入nil对象
        //[self showUser];
        [self creatTable];
    } @catch (NSException *exception) {
        //捕获到异常要执行的代码
        NSLog(@"exc == %@, 最后我弹了一个弹框说这样不合适",exception);
    } @finally {
        //不管能不能捕获到异常都会执行的方法
        NSLog(@"最后");
    }
    
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    
    self.navigationController.navigationBar.translucent = YES;
    
    [GTCountSDK trackCountEvent:@"home_SBAuth_commitInfoPage" withArgs:@{}];

}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [JANALYTICSService startLogPageView:@"社保认证 - 基础信息验证"];
     [MobClick beginLogPageView:@"社保认证 - 基础信息验证"];
}
-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    [JANALYTICSService stopLogPageView:@"社保认证 - 基础信息验证"];
    [MobClick endLogPageView:@"社保认证 - 基础信息验证"];

}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}

- (void)navigationConfig
{
     UIButton * button_2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button_2.frame = CGRectMake(0, 0, 0, 49*WIDTHRADIU);
    button_2.titleLabel.textAlignment =NSTextAlignmentRight;
    [button_2 setTitle:@"     客服" forState:UIControlStateNormal];
    [button_2 addTarget:self action:@selector(buttonClick_1) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * backButtonItem_2 = [[UIBarButtonItem alloc] initWithCustomView:button_2];
    self.navigationItem.rightBarButtonItem = backButtonItem_2;
    
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
}

- (void)creatBottomView
{
    CGFloat height = 49;
    if (cl_kNavigationBarHeight > 64) {
        height = 83;
    }
    
    UIView*view = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight - height - 5 , ScreenWidth, 49 + 5)];
    view.backgroundColor = [UIColor whiteColor];
    
    UIView*line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.5)];
    line.backgroundColor = [UIColor colorWithHex:0x4d4d4d];
    
    
    [self.view addSubview:view];
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
     // 设置item的行间距和列间距
    layout.minimumInteritemSpacing = 0;
    layout.minimumLineSpacing = 0;
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    UICollectionView*collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 5, ScreenWidth, 49) collectionViewLayout:layout];
    collectionView.backgroundColor = [UIColor whiteColor];
    collectionView.showsVerticalScrollIndicator = NO;   //是否显示滚动条
    collectionView.scrollEnabled = YES;  //滚动使能
    collectionView.delegate = self;
    collectionView.dataSource = self;
    [collectionView registerNib:[UINib nibWithNibName:@"RZBottomCell" bundle:nil] forCellWithReuseIdentifier:@"userCell"];
     
     self.collectionView = collectionView;
    [view addSubview:self.collectionView];
    [view addSubview:line];
    
   
}
- (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {
    if (jsonString == nil) {
        return nil;
    }
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
    if(err) {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;
}



-(void)SDKManageReturnData:(NSString *)strData{
    NSLog(@"SDK是否调用成功返回参数：%@",strData);
}
#pragma mark -load data
-(void)getDataCompleteHandle:(NSInteger)index
{
    NSString *aesName= @"";
    NSString *aesId = @"";
    NSString *idName= @"";
    NSString *idNum = @"";
    currentIndex = index;
    if (index == 100) {//正常通道
        //对输入框的身份证去空格
        NSString *newStr = [self.IDText.text  stringByReplacingOccurrencesOfString:@" " withString:@""];
        idNum=newStr;
        idName=self.nameText.text;
        NSLog(@"%@",newStr);
        //姓名AES加密
        aesName =  [EnercryTool AES256Encrypt:self.nameText.text key:MZAESKEY];
        //身份证号AES加密
        aesId = [EnercryTool AES256Encrypt:newStr key:MZAESKEY];
        
        NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
        [userDefault setValue:self.nameText.text forKey:@"name"];
        [userDefault setValue:newStr  forKey:@"identityNumber"];
        [userDefault synchronize];
        BOOL IDCardInjudicious = [IDCardNumber_Validate isValidateIDCardString:newStr];
        if (IDCardInjudicious) {
            
        }else{
            [SVProgressHUD showErrorWithStatus:@"身份证上有格式上的错误"];
            //               self.hideView.hidden =NO;
            return;
        }
    }else{//快速认证
        name = userModel.name;
        idNumber = userModel.idNumber;
        idNum=userModel.idNumber;
        idName=userModel.name;
        //姓名AES加密
        aesName =  [EnercryTool AES256Encrypt:name key:MZAESKEY];
        //身份证号AES加密
        aesId = [EnercryTool AES256Encrypt:idNumber key:MZAESKEY];
        NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
        [userDefault setValue:userModel.name forKey:@"name"];
        [userDefault setValue:userModel.idNumber  forKey:@"identityNumber"];
        [userDefault synchronize];
    }
    [KKLoadingAnimationView show];
    Boolean type=[getPeopleID getpeopleLimited];
    int accountType;
    if(type){
        accountType=0;
    }else{
        accountType=1;
    }

    NSDictionary *params = @{
        @"fromModel":@"2",
        @"fromApp":@"kksh",
        @"accountType":[NSNumber numberWithInteger:accountType],
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"name":aesName,
                             @"idCard":aesId,
                             @"telPhone":[EnercryTool AES256Encrypt:[getPeopleID PeopleIphoneNmber] key:MZAESKEY]
                             };
    NSString *url=@"https://h5.weface.com.cn/renshe/multichannel/auth/query";
    [NetworkRequest PostNo:url Params:params Success:^(id _Nonnull obj) {
        [KKLoadingAnimationView dismiss];
        NSString* state = [NSString stringWithFormat:@"%@",obj[@"state"]];
        NSDictionary *result=obj[@"result"];
        if ([state isEqualToString:@"200"]){//成功查询
            AuthB2ViewController *vc=[AuthB2ViewController new];
            vc.title=@"参保信息";
            vc.auth_id=idNum;
            vc.auth_name=idName;
            vc.auth_card=self.ocrBase64;
            vc.auth_head=self.ocrBase64_;
            vc.auth_result=result;
            [self.navigationController pushViewController:vc animated:YES];
        }else if([state isEqualToString:@"200003"]){//用户不存在,电子社保卡
            //[SVProgressHUD showErrorWithStatus:@""];
            [self essphoto:nil];
        }else{//其他情况
            NSString* describe = [NSString stringWithFormat:@"%@",obj[@"describe"]];
            [SVProgressHUD showErrorWithStatus:describe];
        }
    } Failure:^(NSError* error) {
        NSLog(@"error:%@",error);
        [KKLoadingAnimationView dismiss];
        [SVProgressHUD showErrorWithStatus:@"服务器异常!"];
    }];
    
}

#pragma mark - 有token的社保认证请求
-(void)get2DataCompleteHandle:(NSInteger)index {
    
    NSString* url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipKKSBConfig],KKSBAuthCommitInfoRequest];
    
    NSString *NameEnerypt= @"";
    NSString *IdentiftyEnerypt = @"";
    NSDictionary* params = nil;
    
    if (index == 100) {
        name = self.nameText.text;
        NSString *newStr = [self.IDText.text  stringByReplacingOccurrencesOfString:@" " withString:@""];
        
        idNumber = [newStr uppercaseString];
        //对输入框的身份证去空格
       
        //姓名AES加密
        NameEnerypt =  [EnercryTool A:self.nameText.text];
        //身份证号AES加密
        IdentiftyEnerypt = [EnercryTool A:newStr];
        NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
        [userDefault setValue:self.nameText.text forKey:@"name"];
        [userDefault setValue:newStr  forKey:@"identityNumber"];
        [userDefault synchronize];
        
        BOOL IDCardInjudicious = [IDCardNumber_Validate isValidateIDCardString:newStr];
        if (!IDCardInjudicious) {
            [Tools showMessage:@"身份证号码有格式上的错误"];
            return;
        }
        
        
    }else{
        name = userModel.name;
        idNumber = [userModel.idNumber uppercaseString];
       //姓名AES加密
        NameEnerypt =  [EnercryTool A:userModel.name];
        //身份证号AES加密
        IdentiftyEnerypt = [EnercryTool A:userModel.idNumber];
        NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
        [userDefault setValue:userModel.name forKey:@"name"];
        [userDefault setValue:userModel.idNumber  forKey:@"identityNumber"];
        [userDefault synchronize];
    }
    
    
    NSString* sign = [NSString stringWithFormat:@"identityNumber=%@&name=%@&KkweInfo",IdentiftyEnerypt,NameEnerypt];
    sign = [MyMD5 md5:sign];
    
    params = @{
        @"name":NameEnerypt,
        @"identityNumber":IdentiftyEnerypt,
        @"sign":sign,
        @"flag":@2,
      @"userId":@([getPeopleID PeopleID]),
      @"versionflag":@2
    };
    
    NSLog(@"社保认证提交身份信息接口url:%@",url);
    NSLog(@"params:%@",params);
    
    [KKLoadingAnimationView show];
    [NetworkRequest SBAuthPost:url Params:params Success:^(id _Nonnull objc) {
        //[KKLoadingAnimationView dismiss];
        NSLog(@"objc:%@",objc);
        CityModel* model = [CityModel mj_objectWithKeyValues:objc];
        AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
         paramResult *model_2 =  (paramResult*)model.param;
        self.cityModel = [[CityModel alloc]init];
        self->ggimage =   MHSafeStrings(model_2.verifyPhoto);
        self->ggtime = MHSafeStrings(model_2.vafiryTime);
        self->ggaddress =MHSafeStrings(model_2.verifyAdress);
        self.cityModel.param =model_2;
        if ([[EnercryTool decryptUseDES:model_2.telphoneValue key:DESKEY] isEqualToString:@"null"] ) {
            delegate.isTel = NO;
        }else{
            delegate.telStr = [EnercryTool decryptUseDES:model_2.telphoneValue key:DESKEY];
            delegate.isTel = YES;
        }
        if (model.bak ==nil || [model.bak isEqualToString:@"pQBOvaCaU+k="]) {
            model.bak =nil;
        }
        
        if (model.code == 0) {
            [KKLoadingAnimationView dismiss];
           
           //雷俊博
//            SocialSecurityApproveSuccessVC *vc = [[SocialSecurityApproveSuccessVC alloc]init];
//            vc.title = @"认证成功";
//
//            vc.model = model.param;
//
//            [self.navigationController pushViewController:vc animated:YES];
           
           self->bak = model.bak;
           self->province = model_2.provinceName;
           self->city = model_2.cityName;
           self->county = model_2.countryName;
           
            [self performSegueWithIdentifier:@"successSegueTwo" sender:self];
           return;
        } else {
            [UserDefault setObject:model.bak forKey:@"bak"];
            [UserDefault synchronize];
            
            if (model.code == 2) {
                [KKLoadingAnimationView dismiss];
                NSString *aesParam =   [UserDefault objectForKey:@"AESparam"];
                if ([getPeopleID getpeopleLimited] == YES) {
                    
                    
                    if ([aesParam isEqualToString:@""] || aesParam == NULL ) {
                        return   [self alertSHOW:@"该用户未在社保系统中,是否新增用户?"];
                    }else{
                        [self qitalaojiLAOZUO:model andName:aesParam];
                        return;
                    }
                    
                }else{
                    if ([aesParam isEqualToString:@""] || aesParam == NULL ) {
                        //return   [SVProgressHUD showErrorWithStatus:@"您不在本次认证范围内，请咨询当地社保局"];
                        return [self showThirdAuthTip];
                    }else{
                        return    [SVProgressHUD showErrorWithStatus:@"请判断姓名是否正确"];
                    }
                    
                }
            }else if (model.code == 1015) {
                [KKLoadingAnimationView dismiss];
                [self alertSHOW:@"信息未采集,请采集"];
                return;
            }else if (model.code == 23) {
                [KKLoadingAnimationView dismiss];
                return [SVProgressHUD showInfoWithStatus:@"不在认证时间内"];
            }else if (model.code == 43) {
                [KKLoadingAnimationView dismiss];
                return [SVProgressHUD showInfoWithStatus:@"当前账号当天认证次数已达上限"];
            }else if(model.code == 24){
                [KKLoadingAnimationView dismiss];
                 
                 codeSelected *code = [codeSelected MustTakeReturn:model.code];
                 [code returnCodeMethod];
                 
                 self.nameText.userInteractionEnabled = YES;
                 return ;
                 
             }else if (model.code == 29){
                 [KKLoadingAnimationView dismiss];
                 [CQColorfulAlertView showAuthenticationFailedAlertWithMessage:@"未采集成功,\n是否重新采集?" checkCouponButtonClickedBlock:^{
                        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                                  socialOnceViewController *once  = [sb instantiateViewControllerWithIdentifier:@"socialOnceViewController"];
                                  //            socialSecurityViewController *once = [socialSecurityViewController sharedInstance];
                               once.personPrivate = [getPeopleID getpeopleLimited] ? 1 : 0;
                                  once.offLineGather =@"";
                                  [self.navigationController pushViewController:once animated:YES];
                    }];
                 return;
             }
             else if (model.code == 28 ){
                 [KKLoadingAnimationView dismiss];
                 codeSelected *code = [codeSelected MustTakeReturn:model.code];
                 [code returnCodeMethod];
                 return;
             }else {
                 [self.array addObjectsFromArray:model.result];
                 if (self.array.count <= 0 ) {
                     [KKLoadingAnimationView dismiss];
                     codeSelected *code = [codeSelected MustTakeReturn:model.code];
                     [code returnCodeMethod];
                     return ;
                 }
                 for (int row = 0 ; row < 31 ; row++) {
                     if (self.array == nil) {
                         [KKLoadingAnimationView dismiss];
                         return;
                     }
                     CityResultModel *city =self.array[row];
                     [self.baochunShuZu addObject:city.provice_name];
                     NSData *data =[NSKeyedArchiver archivedDataWithRootObject:city.provice_id];
                     [self.dataArr addObject:data];
                 }
                 //        NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults];
                 [UserDefault setObject:self.dataArr forKey:@"myPrivinceModel"];
                 [UserDefault synchronize];
                 
                 if (model.code == 3 || model.code == 1 || model.code == 26) {
                     //      [self performSegueWithIdentifier:@"GCDSegue" sender:self];
     //                [SVProgressHUD doneShow];
     //                [SVProgressHUD dismiss];
                     
                     pickerViewController *blueVC =[pickerViewController sharedInstance];
                     blueVC.OCRData =self.ocrBase64;
                     blueVC.OCRData_ =self.ocrBase64_;
                     for (int i = 0; i < 31; i++) {
                         blueVC.array2[i] =self.baochunShuZu[i];
                     }
                     AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
                     
                     if ([[EnercryTool decryptUseDES:model_2.telphoneValue key:DESKEY] isEqualToString:@"null"] ) {
                         delegate.isTel = NO;
                     }else{
                         delegate.telStr =@"";
                         if (model_2.telphoneValue == nil || [model_2.telphoneValue isEqualToString:@"null"] || [model_2.telphoneValue isEqualToString:@""] ) {
                             delegate.telStr =@"18888888888";
                         }else{
                             
                             delegate.telStr = [EnercryTool decryptUseDES:model_2.telphoneValue key:DESKEY];
                         }
                         delegate.isTel = YES;
                     }
                     blueVC.telStr = delegate.telStr;
                     
                     [self Sender2TWO:model_2 index:index];
                     
                 }else{
                     [KKLoadingAnimationView dismiss];
                     codeSelected *code = [codeSelected MustTakeReturn:model.code];
                     [code returnCodeMethod];
                     
                 }
                 
             }
            
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"服务器无法连接"];
    }];
    
    
    
}


- (void)Sender2TWO:(paramResult*)model_2 index:(NSInteger)index {
    NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
    NSString *names =[userDefault objectForKey:@"name"];
    NSString *identifity =[userDefault objectForKey:@"identityNumber"];
    NSString *u =[userDefault objectForKey:@"bak"];
    NSLog(@"%@,%@",names,identifity);
    if ([u isEqualToString:@""]) {
        u =nil;
    }
    NSString *path =@"";
    path  = [IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/verifyAddress"];

    NSString *telPhone =@"";
    AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
    if (delegate.isTel == YES) {
        if (delegate.telStr) {
             telPhone =delegate.telStr;
        }


        delegate.isTel =NO;
    }
    [UserDefault setObject:MHSafeStrings(model_2.provinceName) forKey:@"provinceAABBCC"];
    
    self.paramSModel = [paramResult new];
 
    self.paramSModel =model_2;
    
    NSString* province_name = [EnercryTool encryptUseDES:MHSafeStrings(model_2.provinceName) key:DESKEY];
    NSString* city_name =[EnercryTool encryptUseDES:MHSafeStrings(model_2.cityName) key:DESKEY];
    NSString* county_name = [EnercryTool encryptUseDES:MHSafeStrings(model_2.countryName) key:DESKEY];
    NSString* town_name = [EnercryTool encryptUseDES:MHSafeStrings(model_2.townName) key:DESKEY];
    NSString* village_name = [EnercryTool encryptUseDES:MHSafeStrings(model_2.villageName) key:DESKEY];
    NSString* company_name = [EnercryTool encryptUseDES:MHSafeStrings(model_2.companyName) key:DESKEY];
    NSString* phone_number = [EnercryTool encryptUseDES:telPhone key:DESKEY];
    NSInteger verifyType = model_2.verify_type;
    NSString* IDs = u ? u : @"";
    NSString *str1 = [NSString stringWithFormat:@"identityNumber=%@&name=%@&KkweInfo",[EnercryTool A:identifity],[EnercryTool A:names]];
    NSLog(@"%@",str1);
    str1 =  [MyMD5 md5:str1];
    
    NSString* ocrTotalImage = self.ocrBase64 ? self.ocrBase64 : @"";
    
    NSString* ocrHeadImage = self.ocrBase64_ ? self.ocrBase64_ : @"";
    
    
    
    NSDictionary *params = @{
        @"flag":@2,
        @"name":[EnercryTool A:names],
        @"identityNumber":[EnercryTool A:identifity],
        @"province_name":[Tools isBlankString:province_name] ? @"" : province_name,
        @"city_name":[Tools isBlankString:city_name] ? @"" : city_name,
        @"county_name":[Tools isBlankString:county_name] ? @"" : county_name,
        @"town_name":[Tools isBlankString:town_name] ? @"" : town_name,
        @"village_name":[Tools isBlankString:village_name] ? @"" : village_name,
        @"company_name":[Tools isBlankString:company_name] ? @"" : company_name,
        @"phone_number":[Tools isBlankString:phone_number] ? @"" : phone_number,
        @"verify_type": @(verifyType),
        @"id":IDs,
        @"sign":str1,
        @"userId":@([getPeopleID PeopleID]),
        @"ocrTotalImage":ocrTotalImage,
        @"ocrHeadImage":ocrHeadImage
    };
    
    NSLog(@"path:%@",path);
    NSLog(@"params:%@",params);
    
    [NetworkRequest SBAuthPost:path Params:params Success:^(id _Nonnull objc) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"objc:%@",objc);
        verifyAdressModel *model = [verifyAdressModel mj_objectWithKeyValues:objc];
        if (model.code != 0) {
            [SVProgressHUD showErrorWithStatus:@"输入的信息不正确,请检查"];
            return;
        }else {
            [userDefault setObject:model.bak forKey:@"bak"];
            
            if (index == 100) {
                InsuredInfoViewController* vc = [InsuredInfoViewController new];
                vc.title = @"参保信息";
                vc.paramSModel = model_2;
                vc.ValidationName = [self.nameText.text stringByReplacingOccurrencesOfString:@" " withString:@""];
                vc.ValidationIdNumber = [self.IDText.text stringByReplacingOccurrencesOfString:@" " withString:@""];
                vc.bak = model.bak;
                if (MHSafeStrings(self.paramSModel.provinceName)) {
                   [getPeopleID getprovinceNightSix:MHSafeStrings(self.paramSModel.provinceName)];
                }
                [self.navigationController pushViewController:vc animated:YES];
            }else if (index == 101){
                
                quickInsuredInfoViewController *vc = [[quickInsuredInfoViewController alloc]init];
                vc.title = @"参保信息";
                vc.paramSModel = model_2;
                vc.ValidationName = [self->userModel.name stringByReplacingOccurrencesOfString:@" " withString:@""];
                vc.ValidationIdNumber = [self->userModel.idNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
                vc.bak = model.bak;
                if (MHSafeStrings(self.paramSModel.provinceName)) {
                   [getPeopleID getprovinceNightSix:MHSafeStrings(self.paramSModel.provinceName)];
                }
                [self.navigationController pushViewController:vc animated:YES];
                
                
            }
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"服务器无法连接"];
    }];
}










-(void)SenderTWO:(paramResult*)model_2 index:(NSInteger)index{
    NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
    NSString *names =[userDefault objectForKey:@"name"];
    NSString *identifity =[userDefault objectForKey:@"identityNumber"];
    NSString *u =[userDefault objectForKey:@"bak"];
    NSLog(@"%@,%@",names,identifity);
    if ([u isEqualToString:@""]) {
        u =nil;
    }
    NSString *path =@"";
    path  = [IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/verifyAddress"];

    NSString *telPhone =@"";
    AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
    if (delegate.isTel == YES) {
        if (delegate.telStr) {
             telPhone =delegate.telStr;
        }


        delegate.isTel =NO;
    }
    [[NSUserDefaults standardUserDefaults]setObject:MHSafeStrings(model_2.provinceName) forKey:@"provinceAABBCC"];
    
    self.paramSModel = [paramResult new];
 
    self.paramSModel =model_2;
      __weak typeof(self) wself = self;

    [CityNetManager getVeriftAdressNameToThePath:path FortheName:names encrypt:[EnercryTool A:names] theIdentityNumberPara:identifity twoEncrypt:[EnercryTool A:identifity] theProvince_namePara:MHSafeStrings(model_2.provinceName) theCity_namePara:MHSafeStrings(model_2.cityName) theCounty_namePara:MHSafeStrings(model_2.countryName) theTown_namePara:MHSafeStrings(model_2.townName) theVillageNameThPara:MHSafeStrings(model_2.villageName) thePhoneNumber:telPhone companyName:MHSafeStrings(model_2.companyName) verifyType:model_2.verify_type idName:u youP:self.ocrBase64 youP:self.ocrBase64_ completionHandle:^(verifyAdressModel *model, NSError *error) {
        [KKLoadingAnimationView dismiss];;
      
        if (model.code != 0) {
            
            NSLog(@"bak:%@",model.bak);
            
            
            SVProgressHUD.minimumDismissTimeInterval =3.0;
            [SVProgressHUD showErrorWithStatus:@"输入的信息不正确,请检查"];
            return;
        }
        
        NSLog(@"code:%ld",(long)model.code);
        
        
        NSLog(@" 数据访问成功");
        
        [userDefault setObject:model.bak forKey:@"bak"];
        
        if (index == 100) {
            InsuredInfoViewController* vc = [InsuredInfoViewController new];
            vc.title = @"参保信息";
            vc.paramSModel = model_2;
            vc.ValidationName = [self.nameText.text stringByReplacingOccurrencesOfString:@" " withString:@""];
            vc.ValidationIdNumber = [self.IDText.text stringByReplacingOccurrencesOfString:@" " withString:@""];
            vc.bak = model.bak;
            if (MHSafeStrings(wself.paramSModel.provinceName)) {
               [getPeopleID getprovinceNightSix:MHSafeStrings(wself.paramSModel.provinceName)];
            }
            [self.navigationController pushViewController:vc animated:YES];
        }else if (index == 101){
            
            quickInsuredInfoViewController *vc = [[quickInsuredInfoViewController alloc]init];
            vc.title = @"参保信息";
            vc.paramSModel = model_2;
            vc.ValidationName = [self->userModel.name stringByReplacingOccurrencesOfString:@" " withString:@""];
            vc.ValidationIdNumber = [self->userModel.idNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
            vc.bak = model.bak;
            if (MHSafeStrings(wself.paramSModel.provinceName)) {
               [getPeopleID getprovinceNightSix:MHSafeStrings(wself.paramSModel.provinceName)];
            }
            [self.navigationController pushViewController:vc animated:YES];
            
            
        }
        
       
        
        
    /*
        UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        ShowPicker *receive = [sb instantiateViewControllerWithIdentifier:@"ShowPicker"];
        receive.address_relation =wself.paramSModel.verify_type;
        receive.city =MHSafeStrings(wself.paramSModel.countryName);
        receive.province =MHSafeStrings(wself.paramSModel.provinceName);
        receive.county =MHSafeStrings(wself.paramSModel.cityName);
        receive.companyNew =MHSafeStrings(model_2.companyName);
        receive.photosModel = self;
        if (MHSafeStrings(wself.paramSModel.provinceName)) {
            [getPeopleID getprovinceNightSix:MHSafeStrings(wself.paramSModel.provinceName)];
        }
        
        
        receive.ValidationName = self.nameText.text;
        receive.ValidationIdNumber = self.IDText.text;
        receive.bak = model.bak;
        
        
        
        
        
        
        
        
        [self.navigationController pushViewController:receive animated:YES];
         
        
         */
         
         [[NSUserDefaults standardUserDefaults] setObject:MHSafeStrings(model_2.provinceName) forKey:@"successProvinceKankan"];
         [[NSUserDefaults standardUserDefaults] setObject:MHSafeStrings(model_2.cityName) forKey:@"successareaKankan"];
         [[NSUserDefaults standardUserDefaults] setObject:MHSafeStrings(model_2.countryName) forKey:@"successdowntownKankan"];
         [[NSUserDefaults standardUserDefaults] setObject:MHSafeStrings(model_2.townName) forKey:@"successTownKankan"];
         [[NSUserDefaults standardUserDefaults] setObject:MHSafeStrings(model_2.villageName) forKey:@"successDowntownKankan"];

        
        [getPeopleID socialSate:1];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"ZLAuthenticationAssistant" object:nil userInfo:nil];
     
    }];



}



-(void)qitalaojiLAOZUO:(CityModel*)model andName:(NSString*)name{
      __weak __typeof(self)weakSelf = self;
    UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:@"请检查姓名是否正确!" message:nil preferredStyle:UIAlertControllerStyleAlert];
  
    [alertCon addAction:[UIAlertAction actionWithTitle:@"正确" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }]];
    [alertCon addAction:[UIAlertAction actionWithTitle:@"修改" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        
        weakSelf.nameText.text = MHSafeStrings(name);
        /*
        dispatch_async(dispatch_get_main_queue(), ^{
            UIAlertController *alertCons =[UIAlertController alertControllerWithTitle:@"是否重新录入个人信息" message:nil preferredStyle:UIAlertControllerStyleAlert];
            
            [alertCons addAction:[UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                weakSelf.nameText.text = MHSafeStrings(name);
            }]];
            [alertCons addAction:[UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    
                    if ([getPeopleID getpeopleLimited]  ==YES){
                        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                        socialOnceViewController *once  = [sb instantiateViewControllerWithIdentifier:@"socialOnceViewController"];
                        once.personPrivate =1;
                        once.offLineGather =@"";
                        once.name_xin = weakSelf.nameText.text;
                        once.id_xin =weakSelf.IDText.text;
                        once.CAOCAOCAO =@"我是皮卡丘";
                        once.hidesBottomBarWhenPushed =YES;
                        [weakSelf.navigationController pushViewController:once animated:NO];
                    }else{
                        [SVProgressHUD showErrorWithStatus:@"请联系当地社保局"];
                    }
                    
                    
                });
            }]];
              [weakSelf presentViewController:alertCons animated:YES completion:nil];
            
            
            
            
        });
         */
    }]];
    [self presentViewController:alertCon animated:YES completion:nil];
    
}

#pragma mark - 非授权用户code == 2
- (void)showCode2AlertView
{
    UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:@"请检查姓名是否正确!" message:nil preferredStyle:UIAlertControllerStyleAlert];
  
    [alertCon addAction:[UIAlertAction actionWithTitle:@"正确" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }]];
    [self presentViewController:alertCon animated:YES completion:nil];
}


#pragma mark - 判断账户是否已实名
- (NSDictionary *)judgeAccountAuthRequestParams {
    NSString*tel =  [getPeopleID PeopleIphoneNmber];
    
    tel = [EnercryTool AES256Encrypt:tel key:DESKEY];
    NSDictionary *dic = @{
           @"tel":tel
       };
    
    return dic;
}

- (void)judgeAccountAuthStateRequest {
    
    NSString *urlString = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipESSCConfig],KKCheckAccountStateRequest];
    NSLog(@"判断账户是否已实名url:%@",urlString);
    NSLog(@"params:%@",[self judgeAccountAuthRequestParams]);
    [KKLoadingAnimationView show];
    [NetworkRequest SBAuthPost:urlString Params:[self judgeAccountAuthRequestParams] Success:^(id _Nonnull objc) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"objc:%@",objc);
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString* code = [NSString stringWithFormat:@"%@",objc[@"state"]];
            NSString* describe = [NSString stringWithFormat:@"%@",objc[@"describe"]];
            if ([code isEqualToString:@"200"]) {
                
                [getPeopleID saveAccountAuthWithState:YES];
                
                //[self alertShowMessage:@"该账户当天认证人数已达上限"];
                
                [self numberUpperLimitAlert];
                
            }else if ([code isEqualToString:@"204"]) {
                [getPeopleID saveAccountAuthWithState:NO];
                [self makeAccountAuthAlert];
            }else {
                [self alertShowMessage:describe];
            }
        }else{
            [self alertShowMessage:@"服务器异常"];
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        [self alertShowMessage:@"网络异常"];
        
    }];
}

#pragma mark - 跳转到实名认证页面
- (void)goToAuthVC {
    NSString*nameText = [self.nameText.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSString*idText = [self.IDText.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    
    KKUserAuthViewController* vc = [KKUserAuthViewController new];
    vc.title = @"实名认证";
    vc.nameTT = nameText;
    vc.numTT = idText;
    vc.type = KKUserAuthFromVCTypeSBAuth;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}



#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (_IDText.text.length == 0 || [_IDText.text isEqualToString:@""]) {
        if (_isEnter == YES   ) {


        }else{

//            [self alertSHOW:@"请拍身份证正面"];
//
//            return NO;
        }
    }
    
    return YES;
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    
    NSCharacterSet *_set = [NSCharacterSet characterSetWithCharactersInString:@"0123456789xX"];;
    
    [self refreshBtnState];
    
    if (textField == self.IDText) {
        if ([string isEqualToString:@""]) { // 删除字符
            return YES;
        } else {
            
            if (textField.text.length   == 6 || textField.text.length   == 11 || textField.text.length   == 16 ) {
                  textField.text = [NSString stringWithFormat:@"%@ ", textField.text];

                    }
            }

            
             if (textField.text.length >= 21)
             {//大于18位无法再继续输入
                               return NO;
             }
                           
            NSRange range = [string rangeOfCharacterFromSet:_set];
            //判断输入的内容是否是规定的内容范围内 如果不是不做更改 如果是才输入
           if (range.length == 0) {
               return NO;
           }else{
               return YES;
           }
        return YES;
    }
    return YES;
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    
    [self refreshBtnState];
    return YES;
}



#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    if (collectionView == self.collectionView) {
        return 3;
    }
    
    return self.dataArray.count;
}

// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if (collectionView == self.collectionView) {
         RZBottomCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"userCell" forIndexPath:indexPath];
         if (indexPath.item == 0){
            cell.lb_title.text = @"电子社保卡";
            cell.img.image = [UIImage imageNamed:@"bottom_sscard"];
        }else if (indexPath.item == 1){
            cell.lb_title.text = @"养老钱包";
            cell.img.image = [UIImage imageNamed:@"bottom_ylqb"];
        }else if (indexPath.item == 2){
            cell.lb_title.text = @"健康";
            cell.img.image = [UIImage imageNamed:@"life_unselect"];
        }
        return cell;
    }
    
    RZUserCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"userCell" forIndexPath:indexPath];
    
    rzUserModel* model = self.dataArray[indexPath.item];

    cell.lb_firstName.text = [NSString stringWithFormat:@"%@",[model.name substringToIndex:1]];
    cell.lb_name.text = model.name;
   // cell.backgroundColor = [UIColor colorWithRed:(arc4random()%256)/256.0 green:(arc4random()%256)/256.0 blue:(arc4random()%256)/256.0 alpha:1.0];
    return cell;
}

/**
 cell的大小
 */
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    if (self.collectionView == collectionView) {
        CGFloat width =  CGRectGetWidth(collectionView.bounds)  /3 ;
         CGFloat realWidth = CGRectGetWidth(collectionView.bounds)   - floor(width)*(3 - 1);
         // CGFloat itemW = K_ScreenWidth/array.count;
         if (indexPath.item == 0) {
             return CGSizeMake(realWidth, 49);
         }

        return CGSizeMake(floor(width), 49);
    }
    
    CGFloat width =  CGRectGetWidth(collectionView.bounds)  / self.dataArray.count ;
        CGFloat realWidth = CGRectGetWidth(collectionView.bounds)   - floor(width)*(self.dataArray.count - 1);
        // CGFloat itemW = K_ScreenWidth/array.count;
        if (indexPath.item == 0) {
            return CGSizeMake(realWidth, 61);
        }

       return CGSizeMake(floor(width), 61);
    
   
}

/**
 每个分区的内边距（上左下右）
 */
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    
    return UIEdgeInsetsMake(0, 0, 0, 0);
}
/**
 分区内cell之间的最小行间距
 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{

    return 0;
}
/**
 分区内cell之间的最小列间距
 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    
    return 0;
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    return nil;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
   
        return CGSizeZero;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    if (self.collectionView == collectionView) {
        if (indexPath.item == 2) {
            self.tabBarController.selectedIndex = 3;
            [self.navigationController popToRootViewControllerAnimated:YES];
        }else if (indexPath.item == 0){
            BOOL success  = NO;
            for (UIViewController*vc in self.navigationController.viewControllers) {
                if ([vc isKindOfClass:[SSTerminationViewController class]]) {
                    success = YES;
                    [self.navigationController popToViewController:vc animated:YES];
                    break;
                }
            }
            if (success) {
                return;
            }
            SSTerminationViewController *vc = [[SSTerminationViewController alloc]init];
            vc.title = @"电子社保卡";
            //vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:YES];
        }else if (indexPath.item == 1){
//            NSString*city = [[NSUserDefaults standardUserDefaults]objectForKey:@"locationCity"];
//            if ([NSString blankString:city]) {
//                       city = @"北京市";
//            }
//                WebViewController *tc=[WebViewController new];
//                NSString*url = [NSString stringWithFormat:@"http://nginx.weface.com.cn/appH5/government/lib/ssi.html?city=%@",city];
//                url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
//                tc.URL =[NSURL URLWithString:url];
//                        tc.hidesBottomBarWhenPushed =YES;
//                tc.janalytics = @"社保机构";
//                [self.navigationController pushViewController:tc animated:YES];
            [[clickEvent instance]clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/common/forward/KK_WALLET" menuName:@""];
        }
        
        return;
    }
    userModel = self.dataArray[indexPath.item];
    if (userModel.timeStamp && [self isSameDay:[self UTCDateFromTimeStamap:userModel.timeStamp] date2:[NSDate date]]) {
        [self alertSHOW:@"该用户当天已认证成功"];
    }else{
        NSString* alreadyCount = [UserDefault objectForKey:@"alreadyCount"];
        NSString* maxcount = [UserDefault objectForKey:@"maxcount"];
    
        if (alreadyCount.integerValue >= maxcount.integerValue) {
            [self judgeAccountAuthStateRequest];
        }else {
            [self getDataCompleteHandle:101];
        }
    }
}

#pragma mark - 通知绑定方法
- (void)jiePing {
    [self alertShowMessage:@"[安全提醒]内含身份信息，只适合当面使用。不要截图或分享给他人以保障信息安全。"];
}


#pragma mark - 提示
- (void)alertShowMessage:(NSString *)msg
{
    if (@available(iOS 9.0,*)) {
        
        UIAlertController * alertV = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        [alertV addAction:confirm];
        
        [self presentViewController:alertV animated:YES completion:nil];
        
    }else{
        UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alertV show];
    }
}

-(void)alertSHOW:(NSString*)str{
    
    __weak __typeof(self)weakSelf = self;
    UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:str message:nil preferredStyle:UIAlertControllerStyleAlert];
    if ([str isEqualToString:@"请拍身份证正面"]) {
        [alertCon addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
              
        }]];
        [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [weakSelf explainIdentifly:nil];
        }]];
        
    }else if ([str isEqualToString:@"该用户未在社保系统中,是否新增用户?"]){
        [alertCon addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
              
        }]];
        [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            if ([getPeopleID getpeopleLimited]  ==YES){
                UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                socialOnceViewController *once  = [sb instantiateViewControllerWithIdentifier:@"socialOnceViewController"];
                once.personPrivate =1;
                once.offLineGather =@"";
                once.name_xin = self.nameText.text;
                once.id_xin =self.IDText.text;
                once.ocrBase64 = self.ocrBase64;
                once.ocrBase64_ = self.ocrBase64_;
                once.CAOCAOCAO =@"我是皮卡丘";
                once.hidesBottomBarWhenPushed =YES;
                [weakSelf.navigationController pushViewController:once animated:NO];
            }else{
                  [SVProgressHUD showErrorWithStatus:@"请联系当地社保局"];
            }
        }]];
    }else if ([str isEqualToString:@"信息未采集,请采集"]){
        [alertCon addAction:[UIAlertAction actionWithTitle:@"下次再说" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
              
        }]];
        [alertCon addAction:[UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                socialOnceViewController *once  = [sb instantiateViewControllerWithIdentifier:@"socialOnceViewController"];
                once.personPrivate =1;
                once.offLineGather =@"";
                once.name_xin = self.nameText.text;
                once.id_xin =self.IDText.text;
                once.ocrBase64 = self.ocrBase64;
                once.ocrBase64_ = self.ocrBase64_;
                once.CAOCAOCAO =@"我是皮卡丘";
                once.hidesBottomBarWhenPushed =YES;
                [weakSelf.navigationController pushViewController:once animated:NO];
            
        }]];
    }else if ([str isEqualToString:@"该用户当天已认证成功"]) {
        [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }]];
        
    }
     [self presentViewController:alertCon animated:YES completion:nil];
    
   
    
}
//国家认证平台
- (void)showThirdAuthTip{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"跳转国家认证平台" message:@"" preferredStyle: UIAlertControllerStyleAlert];
    UIAlertAction *OKAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"跳转认证" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action){
    
        WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
        launchMiniProgramReq.userName = @"gh_dca9a59780cf";  //拉起的小程序的username
        launchMiniProgramReq.path = @"pages/nhsa-code/index/index?channel=AAEKTLpkFoE88Zic8BqWR87_&cityCode=440300";    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
        launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
        [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {}];
    }];
    //[alertController addChildViewController:image];
    [alertController addAction:OKAction];
    [alertController addAction:cancleAction];
//    UIImage *image = [[UIImage imageNamed:@"国家认证平台"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIAlertAction *imageAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil];
//    [imageAction setValue:image forKey:@"image"];
//    [alert addAction:imageAction];
    [self presentViewController:alertController animated:YES completion:nil];
    
}

#pragma mark - 认证人数已达上限提示
- (void)numberUpperLimitAlert {
    [KKAuthWhiteAlertView showAlertViewWithVC:self type:KKAuthWhiteAlertViewTypeUpper  title:@"人数已达上限" message:@"为补贴发放更安全，您今日认证人数已达上限，请明天再试" block:nil];
}

#pragma mark - 做实名认证提示
- (void)makeAccountAuthAlert {
    [KKAuthWhiteAlertView showAlertViewWithVC:self type:KKAuthWhiteAlertViewTypeAuth title:@"人数已达上限" message:@"为补贴发放更安全，同一账户认证多人需实名认证" block:^{
        [self goToAuthVC];
    }];
}


#pragma mark - SCNavigationControllerDelegate
- (void)sendIDCValue:(NSString *)name SEX:(NSString *)sex FOLK:(NSString *)folk BIRTHDAY:(NSString *)birthday ADDRESS:(NSString *) address NUM:(NSString *)num
{
    self.nameText.text =name;
   
    if (![IDCardNumber_Validate isValidateIDCardString:num]) {
        [SVProgressHUD showInfoWithStatus:@"身份证识别错误,请重新拍摄"];
        return;
    }else{
        self.nameText.userInteractionEnabled = YES;
    }
    NSString *st1 =[num substringWithRange:NSMakeRange(0, 6)];
    NSString *st2 =[num substringWithRange:NSMakeRange(6, 4)];
    NSString *st3 =[num substringWithRange:NSMakeRange(10, 4)];
    NSString *st4 =[num substringFromIndex:14];
    self.IDText.text =  [NSString stringWithFormat:@"%@ %@ %@ %@",st1,st2,st3,st4];
    self.IDText.enabled = NO;//(扫描完身份证之后身份证号码不让修改,19年5月16号改...)
    if (![name isEqualToString:@""]) {
        self.isEnter = YES;
    }
    [self refreshBtnState];
}

- (void)sendAllValue:(NSString *)text
{
    NSLog(@"all  = %@",text);
    
}
- (void)sendIDCBackValue:(NSString *)issue PERIOD:(NSString *) period
{
    NSLog(@"idcback  = %@\n%@\n",issue,period);
}
- (void)sendCardFaceImage:(UIImage *)image
{
    if (image != NULL) {

        NSData *small = UIImagePNGRepresentation(image);
        
        self.ocrBase64_ = [small base64EncodedStringWithOptions:0];
    }

}
- (void)sendFieldImage:(TFIELDID) filed  image:(UIImage *)fieldimage
{
    
    NSLog(@"sendFieldImage = %d %@\n",filed,fieldimage);

}
- (void)sendTakeImage:(TCARD_TYPE) iCardType image:(UIImage *)cardImage
{
    NSLog(@"sendTakeImage = %d %@\n",iCardType,cardImage);


  NSData *small =UIImageJPEGRepresentation([self imageByScalingAndCroppingForSize:CGSizeMake(667, 375) and:cardImage], 1.0);
  self.ocrBase64 = [small base64EncodedStringWithOptions:0];

}
- (void)sendIDCARDBackAction
{
    
}


#pragma mark - 清除输入框
- (void)clearText
{
    self.nameText.text = @"";
    self.IDText.text = @"";
    self.IDText.enabled = YES;
    [self refreshBtnState];
}

#pragma mark - 创建本地数据库
- (void)creatTable{
    //1.获得数据库文件的路径
    NSLog(@"表格路径:%@",[self getDBPath]);
     //2.获得数据库
    FMDatabase *db=[FMDatabase databaseWithPath:[self getDBPath]];
    if ([db open]) {
         //4.创表
        NSString* sql = @"CREATE TABLE IF NOT EXISTS t_rzUserNew (id integer PRIMARY KEY AUTOINCREMENT, name text NOT NULL, idNumber text NOT NULL, userid text NOT NULL,timeSp text);";
         BOOL result=[db executeUpdate:sql];
        if (result) {
            NSLog(@"创表成功");
            if (![db columnExists:@"timeSp" inTableWithName:@"t_rzUserNew"]){
                NSString *alertStr = [NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ text",@"t_rzUserNew",@"timeSp"];
                BOOL worked = [db executeUpdate:alertStr];
                if(worked){
                    NSLog(@"插入成功");
                }else{
                    NSLog(@"插入失败");
                }
            }
            
        }else{
            NSLog(@"创表失败");
        }
        
        [db close];
    }
    [self queryData];
}

- (void)queryData{
    //1.获得数据库文件的路径
   NSLog(@"表格路径:%@",[self getDBPath]);
    NSMutableArray * array = [NSMutableArray array];
    //2.获得数据库
   FMDatabase *db=[FMDatabase databaseWithPath:[self getDBPath]];
    if ([db open]) {
        // 1.执行查询语句
        NSString * sql = [NSString stringWithFormat:@"SELECT * FROM t_rzUserNew where userid = '%ld'",[getPeopleID PeopleID]];
        FMResultSet *resultSet = [db executeQuery:sql];
        // 2.遍历结果
        while ([resultSet next]){
            int ID = [resultSet intForColumn:@"id"];
            NSString *name = [resultSet stringForColumn:@"name"];
            NSString *idNumber = [resultSet stringForColumn:@"idNumber"];
            NSString *userid = [resultSet stringForColumn:@"userid"];
            NSString *timeStamp = [resultSet stringForColumn:@"timeSp"];
            NSLog(@"ID:%d,name:%@,idNumber:%@,userid:%@",ID,name,idNumber,userid);
            rzUserModel*model = [[rzUserModel alloc]init];
            model.name = name;
            model.idNumber = idNumber;
            model.timeStamp = timeStamp;
            [array addObject:model];
        }
    }
    [db close];
    [self.dataArray removeAllObjects];
    [array.reverseObjectEnumerator.allObjects enumerateObjectsUsingBlock:^(rzUserModel* obj, NSUInteger idx, BOOL * _Nonnull stop) {
      [self.dataArray addObject:obj];
    }];
    
    if (self.dataArray.count == 0) {
        [self removeUserListUI];
    }else{
        [self hiddenCollection:NO];
        [_mainCollectionView reloadData];
    }
}


- (NSString *)getDBPath
{
     NSString *doc= [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        return [doc stringByAppendingPathComponent:@"rzUserlist.sqlite"];

}




#pragma mark - 移除用户列表
-(void)removeUserListUI
{
    
    [self hiddenCollection:YES];
    
}

#pragma mark - 隐藏或显示collectionview
- (void)hiddenCollection:(BOOL)hidden
{
   
    _mainCollectionView.hidden = hidden;
    _lb_message.hidden = hidden;
    _rightLine.hidden = hidden;
    _leftLine.hidden = hidden;
//    self.whiteView.hidden = !hidden;
//    self.topCircleImg.hidden = !hidden;
    
    if (hidden) {
        CGRect nameImgFrame = self.nameImg.frame;
        CGFloat nameImgMinY =  22 * WIDTHRADIU;
        nameImgFrame.origin.y = nameImgMinY;
        self.nameImg.frame = nameImgFrame;
        
        CGRect topBackImgFrame = self.backImgView.frame;
        topBackImgFrame.size.height = 345 * WIDTHRADIU;
        self.backImgView.frame = topBackImgFrame;
        self.topBg.image = [UIImage imageNamed:@"社保认证弧度"];
        
    }else{
        CGRect nameImgFrame = self.nameImg.frame;
        CGFloat nameImgMinY =  22 * WIDTHRADIU;
        nameImgFrame.origin.y = nameImgMinY;
        self.nameImg.frame = nameImgFrame;
        
        CGRect topBackImgFrame = self.backImgView.frame;
        topBackImgFrame.size.height = 275 * WIDTHRADIU;
        self.backImgView.frame = topBackImgFrame;
        
        self.topBg.image = [UIImage imageNamed:@"社保认证弧度_s"];
        
        self.videoImage.hidden = YES;
        self.clearView.hidden = YES;
        
        [self.agressBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self->_mainCollectionView.mas_bottom).offset(17 * WIDTHRADIU);
            make.left.offset(27 * WIDTHRADIU);
            make.width.height.offset(15);
        }];
        
        
        [self.cardImage mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(65 * WIDTHRADIU);
            make.top.equalTo(self.IDText.mas_bottom).offset(24 * WIDTHRADIU);
            make.width.offset(114 * WIDTHRADIU);
            make.height.offset(71 * WIDTHRADIU);
        }];
        
        [self.cardBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cardImage.mas_right).offset(53 * WIDTHRADIU);
            make.centerY.equalTo(self.cardImage);
            make.width.offset(114 * WIDTHRADIU);
            make.height.offset(40 * WIDTHRADIU);
        }];

    }
    
//    CGFloat y = hidden ? 390 * WIDTHRADIU :CGRectGetMaxY(self.backImgView.frame) + 58 * WIDTHRADIU + 62;
//    CGRect frame = self.agressBtn.frame;
//    frame.origin.y = y;
//    self.agressBtn.frame = frame;
    //self.scrollView.contentSize = CGSizeMake(ScreenWidth,self.agressBtn.maxY + 83 + 45 * WIDTHRADIU);
    
        
}

#pragma mark - 刷新按钮状态
- (void)refreshBtnState
{
    if (self.nameText.text.length == 0 || self.IDText.text.length <= 3 ||self.button_xieyi.selected == NO) {
        self.PhotoBtn.backgroundColor =[UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0];
        self.PhotoBtn.userInteractionEnabled =NO;
    }else{
       self.PhotoBtn.backgroundColor =[UIColor colorWithRed:25/255.0 green:149/255.0 blue:109/255.0 alpha:1.0];
       self.PhotoBtn.userInteractionEnabled =YES;
    }
}


#pragma mark - event response
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [self.view endEditing:YES];

}
 WEBS
-(void)buttonClick_1{
    //ZHINENGKEFU
    [[clickEvent instance] clickEventRooterVC:self Content:@"weChatService" menuName:@"客服"];
}

- (void)explainIdentifly:(UIButton *)sender
{
    SCCaptureCameraController *con = [[SCCaptureCameraController alloc] init];
    con.scNaigationDelegate = self;
    con.iCardType = TIDCARD2;
    con.isDisPlayTxt = NO;
    //con.TimeKey = TimeKeyS;
    con.ScanMode = TIDC_SCAN_MODE;
    [self presentViewController:con animated:YES completion:NULL];
}

- (void)KankanXieYi:(UIButton *)sender
{
    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    kankanshebaoxieyi *kankan = [sb instantiateViewControllerWithIdentifier:@"kankanshebaoxieyi"];
    kankan.title = @"用户服务协议";
    kankan.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:kankan animated:YES];
}

- (void)ssssselfe:(UIButton *)sender
{
    self.button_xieyi.selected = !self.button_xieyi.selected;
    [self refreshBtnState];
}

- (void)watchClick:(UITapGestureRecognizer *)ges {
    WebVC *vc = [[WebVC alloc]init];
    
    vc.title = @"教学视频";
    vc.url = @"http://nginx.weface.com.cn/appH5/Mp4/kksbVideo.html";
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 国家人社平台
- (void)essphoto:(UIButton *)sender{
    NSLog(@"%@",@"111111");
    if ([self.nameText.text length] <=0) {
        [SVProgressHUD showInfoWithStatus:@"请输入您的姓名!"];
        return;
    }
    NSString *newStr = [self.IDText.text  stringByReplacingOccurrencesOfString:@" " withString:@""];
    BOOL IDCardInjudicious = [IDCardNumber_Validate isValidateIDCardString:newStr];
    if (!IDCardInjudicious) {
         [SVProgressHUD showErrorWithStatus:@"身份证上有格式上的错误"];
        return;
    }
    [self getSSCardSign];
}

- (void)getSSCardSign{
    NSString *url = [[NSString stringWithFormat:@"%@/electronic/social/issuance/jbxSign",CSL_url]  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
       NSString *newStr = [self.IDText.text  stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSString *name=[GMSm4Utils ecbEncryptText:self.nameText.text key:SMKey].lowercaseString;
    NSString *idNum=[GMSm4Utils ecbEncryptText:newStr key:SMKey].lowercaseString;
    NSString *phone=[GMSm4Utils ecbEncryptText:[getPeopleID PeopleIphoneNmber] key:SMKey].lowercaseString;
    NSDictionary *params = @{
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"name":name,
                             @"idCard":idNum,
                             @"phone":phone
                             };
    [[NSUserDefaults standardUserDefaults]setObject:name forKey:@"essCardName"];//保存name
    [[NSUserDefaults standardUserDefaults]setObject:idNum forKey:@"essCardIdNum"];//保存id
    [SVProgressHUD show];
    [NetworkRequest PostNomal:url Params:params Success:^(id _Nonnull objc) {
        NSString* state = [NSString stringWithFormat:@"%@",objc[@"state"]];
        if ([state isEqualToString:@"200"]) {
            NSDictionary *result=objc[@"result"];
            NSString* token = [NSString stringWithFormat:@"%@",result[@"token"]];//获取token
            [[NSUserDefaults standardUserDefaults]setObject:token forKey:@"essCardToken"];//保存token
            NSDictionary *data=result[@"data"];
            NSString* bindStatus = [NSString stringWithFormat:@"%@",data[@"bindStatus"]];//状态
            if([bindStatus isEqualToString:@"UNBIND"]||[bindStatus isEqualToString:@"BIND"]){//可申领
                NSString* returnUrl = [NSString stringWithFormat:@"%@",data[@"returnUrl"]];//社保卡url
                NSString *ess_token=[GMSm4Utils ecbDecryptText:returnUrl key:SMKey];
                NSString *url = [[SSCPublicHeader sharedSSCTool] webUrlWith:SSCServiceType_Main
                signStr:ess_token];
                [[SSCPublicHeader sharedSSCTool] presentWebVCFrom:self esscUrl:url
                esscDelegate:self];
            }else{//不可申领
                if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"alipays://"]]) {
                        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"alipays://platformapi/startapp?appId=20000067&url=https%3A%2F%2Frender.alipay.com%2Fp%2Fs%2Fmedical-card-online%2Fwww%2Findex.html%3FchInfo%3DPDA01B01C01D00%26__webview_options__%3D"] options:nil completionHandler:nil];
                    return;
                }
                if (![WXApi isWXAppInstalled]){
                    [Tools showMessage:@"请安装支付宝APP后重试"];
                    return;
                }
                WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                launchMiniProgramReq.userName = @"gh_c02ba94d95e2";  //拉起的小程序的username
                launchMiniProgramReq.path = @"pages/activity2/index/main?channel=AAEa8uDL_CLi4rjQ2mxeJFys";    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                }];
            }
        }
        [SVProgressHUD dismiss];
    } Failure:^(NSError* error) {
        [SVProgressHUD dismiss];
        NSLog(@"error:%@",error);
    }];
}

- (void)backResponseResult:(NSString *)responseResult{
    NSLog(@"%@",responseResult);
    NSDictionary *dic = [NSDictionary dictionaryWithJsonString:responseResult];
    NSString *actionType = dic[@"actionType"];
    NSString *signNo=[GMSm4Utils ecbEncryptText:dic[@"signNo"] key:SMKey].lowercaseString;
    NSString *busiSeq=[GMSm4Utils ecbEncryptText:dic[@"busiSeq"] key:SMKey].lowercaseString;
    if ([actionType isEqualToString:@"001"]||[actionType isEqualToString:@"002"]) {//申领 和 当前渠道签发状态更新
        [self essUpdateStatus:@"BIND" signNo:signNo busiSeq:busiSeq type:@"3"];
    }else if([actionType isEqualToString:@"003"]){//解绑
        [self essUpdateStatus:@"UNBIND" signNo:signNo busiSeq:busiSeq type:@"3"];
    }else if([actionType isEqualToString:@"014"]){//待遇认证
        [self essAuthResult];
    }
}

-(void) essAuthResult {
    NSString *url = [[NSString stringWithFormat:@"%@/electronic/social/certification/saveCertification",CSL_url] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString * phone=[GMSm4Utils ecbEncryptText:[getPeopleID PeopleIphoneNmber] key:SMKey].lowercaseString;
    NSString *name=[[NSUserDefaults standardUserDefaults]stringForKey:@"essCardName"];//name
    NSString *idNum=[[NSUserDefaults standardUserDefaults]stringForKey:@"essCardIdNum"];//id
    NSDictionary *params = @{
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"name":name,
                             @"idCard":idNum,
                             @"phone":phone
                             };
    [NetworkRequest PostEssResult:url Params:params Success:^(id _Nonnull objc) {
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
            if ([state isEqualToString:@"200"]) {
                NSLog(@"%@",@"电子认证状态:更新成功!");
            }else if ([state isEqualToString:@"50009"]){//token过期
                NSString *refreshToken = [[NSString stringWithFormat:@"%@/electronic/social/issuance/refreshToken",CSL_url] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                [NetworkRequest PostEssResult:refreshToken Params:params Success:^(id _Nonnull obj){
                    if ([obj isKindOfClass:[NSDictionary class]]) {
                        NSString *tokenstate = [NSString stringWithFormat:@"%@",obj[@"state"]];
                        if ([tokenstate isEqualToString:@"200"]) {
                            NSString *newToken=obj[@"result"];
                            [[NSUserDefaults standardUserDefaults]setObject:newToken forKey:@"essCardToken"];//保存token
                            [self essAuthResult];
                        }
                    }
                } Failure:^(NSError *error) {
                    NSLog(@"error:%@",error);
                }];
            }
            
        }
    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
}

-(void) essUpdateStatus:(NSString *)status signNo:(NSString *)signNo  busiSeq:(NSString *)busiSeq type:(NSString *)type {
    NSString *url = [[NSString stringWithFormat:@"%@/electronic/social/issuance/updateSign",CSL_url] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString * phone=[GMSm4Utils ecbEncryptText:[getPeopleID PeopleIphoneNmber] key:SMKey].lowercaseString;
    NSString *name=[[NSUserDefaults standardUserDefaults]stringForKey:@"essCardName"];//name
    NSString *idNum=[[NSUserDefaults standardUserDefaults]stringForKey:@"essCardIdNum"];//id
    NSDictionary *params = @{
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"name":name,
                             @"idCard":idNum,
                             @"phone":phone,
                             @"status":status,
                             @"signNo":signNo,
                             @"busiSeq":busiSeq,
                             @"type": type
                             };
    [NetworkRequest PostEssResult:url Params:params Success:^(id _Nonnull objc) {
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
            if ([state isEqualToString:@"200"]) {
                NSLog(@"%@",@"签发状态:更新成功!");
            }else if ([state isEqualToString:@"50009"]){//token过期
                NSString *refreshToken = [[NSString stringWithFormat:@"%@/electronic/social/issuance/refreshToken",CSL_url] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                [NetworkRequest PostEssResult:refreshToken Params:params Success:^(id _Nonnull obj){
                    if ([obj isKindOfClass:[NSDictionary class]]) {
                        NSString *tokenstate = [NSString stringWithFormat:@"%@",obj[@"state"]];
                        if ([tokenstate isEqualToString:@"200"]) {
                            NSString *newToken=obj[@"result"];
                            [[NSUserDefaults standardUserDefaults]setObject:newToken forKey:@"essCardToken"];//保存token
                            [self essUpdateStatus:status signNo:signNo busiSeq:busiSeq type:type];
                        }
                    }
                } Failure:^(NSError *error) {
                    NSLog(@"error:%@",error);
                }];
            }
        }
    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
    
}

#pragma mark - 下一步操作
- (void)photo:(UIButton *)sender
{
    timeForButtonCount *times=[[timeForButtonCount alloc]initMustTakeReturn:nil];
    [times methodWithTimeCount:sender];
    
//    WeakSelf;
    NSString* alreadyCount = [UserDefault objectForKey:@"alreadyCount"];
    
    NSString* maxcount = [UserDefault objectForKey:@"maxcount"];
    
    if (alreadyCount.integerValue >= maxcount.integerValue) {
        
        [self judgeAccountAuthStateRequest];
    }else {
        [self getDataCompleteHandle:100];
    }
    
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"GCDSegue"])  {
        
        
        pickerViewController *blueVC = segue.destinationViewController;
        blueVC.OCRData =self.ocrBase64;
        blueVC.OCRData_ =self.ocrBase64_;
        for (int i = 0; i < 31; i++) {
            blueVC.array2[i] =self.baochunShuZu[i];
    
        }
    }
    if ([segue.identifier isEqualToString:@"successSegueTwo"])  {
        
        
        successViewController *blueVC = segue.destinationViewController;
        blueVC.numberInr =153;
        blueVC.GGtime =ggtime;
        blueVC.GGaddress =ggaddress;
        blueVC.GGImage =ggimage;
        blueVC.name = [name stringByReplacingOccurrencesOfString:@" " withString:@""];
        blueVC.idNumber = [idNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
        blueVC.bak = [bak stringByReplacingOccurrencesOfString:@" " withString:@""];
        
        blueVC.province = province;
        blueVC.city = city;
        blueVC.county = county;

    }
}



#pragma mark - private methods

// 判断是否是同一天
- (BOOL)isSameDay:(NSDate*)date1 date2:(NSDate*)date2
{
    NSCalendar* calendar = [NSCalendar currentCalendar];
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
    NSDateComponents* comp1 = [calendar components:unitFlags fromDate:date1];
    NSDateComponents* comp2 = [calendar components:unitFlags fromDate:date2];
    return [comp1 day] == [comp2 day] &&
    [comp1 month] == [comp2 month] &&
    [comp1 year] == [comp2 year];
}
//时间戳转UTCDate
-(NSDate *)UTCDateFromTimeStamap:(NSString *)timeStamap
{
    NSTimeInterval timeInterval=[timeStamap doubleValue]/1000;
    //  /1000;传入的时间戳timeStamap如果是精确到毫秒的记得要/1000
    NSDate *UTCDate=[NSDate dateWithTimeIntervalSince1970:timeInterval];
    return UTCDate;
}

- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize and:(UIImage*)imageKs
{
    UIImage *sourceImage = imageKs;
    UIImage *newImage = nil;
    CGSize imageSize = sourceImage.size;
    CGFloat width = imageSize.width;
    CGFloat height = imageSize.height;
    CGFloat targetWidth = targetSize.width;
    CGFloat targetHeight = targetSize.height;
    CGFloat scaleFactor = 0.0;
    CGFloat scaledWidth = targetWidth;
    CGFloat scaledHeight = targetHeight;
    CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
    
    if (CGSizeEqualToSize(imageSize, targetSize) == NO)
    {
        CGFloat widthFactor = targetWidth / width;
        CGFloat heightFactor = targetHeight / height;
        
        if (widthFactor > heightFactor)
            scaleFactor = widthFactor;
        else
            scaleFactor = heightFactor;
        scaledWidth= width * scaleFactor;
        scaledHeight = height * scaleFactor;
        
      
        if (widthFactor > heightFactor)
        {
            thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
        }
        else if (widthFactor < heightFactor)
        {
            thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
        }
    }
    
    //UIGraphicsBeginImageContext(targetSize);
    UIGraphicsImageRenderer*re=[[UIGraphicsImageRenderer alloc] initWithSize:targetSize];
    CGRect thumbnailRect = CGRectZero;
    thumbnailRect.origin = thumbnailPoint;
    thumbnailRect.size.width= scaledWidth;
    thumbnailRect.size.height = scaledHeight;
    
    [sourceImage drawInRect:thumbnailRect];
    
    newImage = UIGraphicsGetImageFromCurrentImageContext();
    if(newImage == nil)
    
 
    UIGraphicsEndImageContext();
    return newImage;
}


#pragma mark - getters and setters
- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, cl_kNavigationBarHeight, SCREEN_WIDTH, ScreenHeight - cl_kNavigationBarHeight - 49)];
        _scrollView.contentSize = CGSizeMake(ScreenWidth, 0);
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
        _scrollView.delegate = self;
         _scrollView.contentOffset = CGPointMake(0,0);
        _scrollView.backgroundColor = [UIColor whiteColor];
        

        //背景图片
        UIView* topBackImg = [[UIView alloc]initWithFrame:CGRectMake(0, 0 *ScreenWidth, ScreenWidth, 345 * WIDTHRADIU)];
        topBackImg.backgroundColor = [UIColor clearColor];
        topBackImg.userInteractionEnabled = YES;
        self.backImgView = topBackImg;
        [_scrollView addSubview:topBackImg];
        
        UIImageView* bgImg = [UIImageView new];
        bgImg.image = [UIImage imageNamed:@"社保认证弧度"];
        [topBackImg addSubview:bgImg];
        self.topBg = bgImg;
        [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.offset(0);
        }];

//        //顶部圆弧
//       UIImageView* topCircleImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 55 * WIDTHRADIU)];
//       topCircleImg.image = [UIImage imageNamed:@"certificationBg"];
//       [topBackImg addSubview:topCircleImg];
//        self.topCircleImg = topCircleImg;
//
//       //白色悬浮块
//        UIView* whiteView = [[UIView alloc]initWithFrame:CGRectMake((ScreenWidth - 340 * WIDTHRADIU)/2, 0, 340 * WIDTHRADIU, 71 * WIDTHRADIU)];
//        whiteView.backgroundColor = [UIColor whiteColor];
//        whiteView.layer.cornerRadius = 10 * WIDTHRADIU;
//        whiteView.layer.shadowColor = [UIColor colorWithHex:0xe4eef6].CGColor;
//        whiteView.layer.shadowOpacity = 0.8;
//        whiteView.layer.shadowRadius = 2 * WIDTHRADIU;
//        whiteView.layer.shadowOffset = CGSizeMake(0, 0);
//        [topBackImg addSubview:whiteView];
//        self.whiteView = whiteView;
//
//        //流程进度条
//        UIView*progressLine = [[UIView alloc]initWithFrame:CGRectMake(43 * WIDTHRADIU, 25 * WIDTHRADIU, 244 * WIDTHRADIU, 4 * WIDTHRADIU)];
//        progressLine.backgroundColor = [UIColor colorWithHex:0xfdc1a0];
//        [whiteView addSubview:progressLine];
//        NSArray*progressArray = @[@"拍身份证",@"信息核对",@"人脸识别"];
//        for (int i = 0; i < 3; i++) {
//            UIImageView*imageView = [[UIImageView alloc]init];
//            imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"rz_0%d",i+1]];
//            imageView.frame = CGRectMake(31* WIDTHRADIU + (34 * WIDTHRADIU + 88*WIDTHRADIU)*i, 10 * WIDTHRADIU, 34 * WIDTHRADIU, 34* WIDTHRADIU);
//            [whiteView addSubview:imageView];
//            UILabel*lb = [[UILabel alloc]init];
//            lb.textColor = [UIColor colorWithHex:0x808080];
//            lb.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
//            lb.textAlignment = NSTextAlignmentCenter;
//            lb.text = progressArray[i];
//            [whiteView addSubview:lb];
//            [lb mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(imageView.mas_bottom).offset(2 * WIDTHRADIU);
//                make.centerX.equalTo(imageView);
//            }];
//
//        }
        
        
        //姓名
        UIImageView*nameImg = [[UIImageView alloc]initWithFrame:CGRectMake(11 * WIDTHRADIU, 22 * WIDTHRADIU, ScreenWidth - 22 * WIDTHRADIU, (ScreenWidth - 22 * WIDTHRADIU) * 58/353.0)];
        nameImg.image = [UIImage imageNamed:@"社保认证姓名"];
        [topBackImg addSubview:nameImg];
        self.nameImg = nameImg;
        
        UITextField*tf_name = [[UITextField alloc]init];
        tf_name.textColor = [UIColor colorWithHex:0x4d4d4d];
        tf_name.font = [UIFont systemFontOfSize:15* WIDTHRADIU];
        tf_name.placeholder = @"请输入姓名";
        tf_name.delegate = self;
        self.nameText = tf_name;
        [topBackImg addSubview:tf_name];
        
        [tf_name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(nameImg);
            make.right.equalTo(nameImg.mas_right).offset(-20 * WIDTHRADIU);
            make.left.equalTo(nameImg.mas_left).offset(85 * WIDTHRADIU);
            make.height.equalTo(nameImg.mas_height).multipliedBy(0.85);
        }];
        
        
        //身份证号码
        UIImageView*idImg = [[UIImageView alloc]init];
        idImg.image = [UIImage imageNamed:@"社保认证身份证"];
        [topBackImg addSubview:idImg];
        
        
        [idImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(nameImg.mas_bottom);
            make.left.right.height.equalTo(nameImg);
        }];
        
        KKBanCopyPasteTextField*tf_id = [[KKBanCopyPasteTextField alloc]init];
        tf_id.textColor = [UIColor colorWithHex:0x4d4d4d];
        tf_id.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        tf_id.placeholder = @"请输入身份证信息";
        tf_id.delegate = self;
        self.IDText = tf_id;
        [topBackImg addSubview:tf_id];
        
        [tf_id mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(idImg);
            make.right.equalTo(idImg.mas_right).offset(-20 * WIDTHRADIU);
            make.left.equalTo(idImg.mas_left).offset(85 * WIDTHRADIU);
            make.height.equalTo(idImg.mas_height).multipliedBy(0.85);
        }];
        
        

        
        
//        CGFloat wordWidth = 25;
//        CGFloat leftPadding = 28 * WIDTHRADIU;
        CGFloat cardWidth = 114 * WIDTHRADIU;
        CGFloat buttonWidth = 114 * WIDTHRADIU;
        
        
        //身份证图片
        UIImageView*IdCardView = [[UIImageView alloc]init];
        IdCardView.image = [UIImage imageNamed:@"身份证图"];
        [topBackImg addSubview:IdCardView];
        self.cardImage = IdCardView;
        [IdCardView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(65 * WIDTHRADIU);
            make.top.equalTo(tf_id.mas_bottom).offset(24 * WIDTHRADIU);
            make.width.offset(cardWidth);
            make.height.offset(71 * WIDTHRADIU);
        }];
        
     
        
        UIView* clearView = [UIView new];
        [topBackImg addSubview:clearView];
        self.clearView = clearView;
        [clearView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(65 * WIDTHRADIU);
            make.top.equalTo(IdCardView.mas_bottom);
            make.width.offset(cardWidth);
            make.height.offset(17 * WIDTHRADIU);
        }];
        
        //视频图片
        UIImageView*videoView = [[UIImageView alloc]init];
        videoView.image = [UIImage imageNamed:@"authVideo"];
        [topBackImg addSubview:videoView];
        videoView.userInteractionEnabled = YES;
        UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(watchClick:)];
        [videoView addGestureRecognizer:tap];
        self.videoImage = videoView;
        [videoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(65 * WIDTHRADIU);
            make.top.equalTo(clearView.mas_bottom);
            make.width.offset(cardWidth);
            make.height.offset(62.5 * WIDTHRADIU);
        }];
        
        //例
//        UILabel* lb_li = [[UILabel alloc]init];
//        lb_li.text = @"例:";
//        lb_li.textColor = [UIColor colorWithHex:0x7b7b7b];
//        lb_li.font = [UIFont systemFontOfSize:19];
//        [topBackImg addSubview:lb_li];
//
//        [lb_li mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.offset(28 * WIDTHRADIU);
//            make.centerY.equalTo(IdCardView);
//            make.width.offset(25);
//            make.height.offset(42);
//        }];
        
        
        //button
        UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setTitle:@"拍身份证识别" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        btn.backgroundColor = [UIColor colorWithHex:0x239DED];
        btn.layer.cornerRadius = 4;
        [btn addTarget:self action:@selector(explainIdentifly:) forControlEvents:UIControlEventTouchUpInside];
        [topBackImg addSubview:btn];
        self.cardBtn = btn;
        
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(IdCardView.mas_right).offset(53 * WIDTHRADIU);
            make.centerY.equalTo(clearView);
            make.width.offset(buttonWidth);
            make.height.offset(40 * WIDTHRADIU);
        }];
        
        //分割线
        UILabel*lb_message = [[UILabel alloc]init];
        lb_message.text = @"选择姓名，快速认证";
        lb_message.textAlignment = NSTextAlignmentCenter;
        lb_message.textColor = [UIColor colorWithHex:0x808080];
        lb_message.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        [_scrollView addSubview:lb_message];
        [lb_message setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [lb_message setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [lb_message setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];

        [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self->_scrollView);
            make.top.equalTo(topBackImg.mas_bottom).offset(23 * WIDTHRADIU);
        }];
        
        
        //左边分割线
        UIView* leftLine = [[UIView alloc]init];
        leftLine.backgroundColor = [UIColor colorWithHex:0xcccccc];
        [_scrollView addSubview:leftLine];
        [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(lb_message);
            make.left.offset(18 * WIDTHRADIU);
            make.right.equalTo(lb_message.mas_left).offset(- 8 * WIDTHRADIU);
            make.height.offset(0.5);
        }];
        
     
        //右边分割线
        UIView* rightLine = [[UIView alloc]init];
        rightLine.backgroundColor = [UIColor colorWithHex:0xcccccc];
        [_scrollView addSubview:rightLine];
        
        [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(lb_message.mas_centerY);
            make.left.equalTo(lb_message.mas_right).offset(8 * WIDTHRADIU);
            make.right.equalTo(self->_scrollView.mas_right).offset(-18 * WIDTHRADIU);
            make.width.equalTo(leftLine);
            make.height.offset(0.5);
        }];
        
        _lb_message = lb_message;
        _leftLine = leftLine;
        _rightLine = rightLine;
        
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
         // 设置item的行间距和列间距
        layout.minimumInteritemSpacing = 0;
        layout.minimumLineSpacing = 0;
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        
        UICollectionView*collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        collectionView.backgroundColor = [UIColor whiteColor];
        collectionView.showsVerticalScrollIndicator = NO;   //是否显示滚动条
        collectionView.scrollEnabled = YES;  //滚动使能
        collectionView.delegate = self;
        collectionView.dataSource = self;
        [collectionView registerNib:[UINib nibWithNibName:@"RZUserCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"userCell"];
        [_scrollView addSubview:collectionView];
        _mainCollectionView = collectionView;
        
        [_mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lb_message.mas_bottom).offset(8 * WIDTHRADIU);
            make.left.right.offset(0);
            make.height.offset(62);
        }];
        
        UIButton* agressBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [agressBtn setImage:[UIImage imageNamed:@"check_unselected"] forState:UIControlStateNormal];
        [agressBtn setImage:[UIImage imageNamed:@"check_selected"] forState:UIControlStateSelected];
        self.button_xieyi = agressBtn;
        self.button_xieyi.selected = YES;
        [agressBtn addTarget:self action:@selector(ssssselfe:) forControlEvents:UIControlEventTouchUpInside];
        [_scrollView addSubview:agressBtn];
        
        //agressBtn.frame = CGRectMake(27 * WIDTHRADIU, 390* WIDTHRADIU, 30, 30);
        
        [agressBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(27 * WIDTHRADIU);
            make.top.equalTo(topBackImg.mas_bottom).offset(25 * WIDTHRADIU);
            make.width.height.offset(15);
        }];
        self.agressBtn = agressBtn;
        
        
        //hiddenView
        UIView* hiddenView = [[UIView alloc]init];
        hiddenView.backgroundColor = [UIColor clearColor];
        //hiddenView.hidden = YES;
        self.hideView = hiddenView;
        [topBackImg addSubview:hiddenView];

        [hiddenView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(agressBtn.mas_bottom).offset(10 * WIDTHRADIU);
            make.left.offset(25 * WIDTHRADIU);
            make.right.offset(-33 * WIDTHRADIU);
            make.height.offset(24 * WIDTHRADIU);
        }];

        //提示message
        UILabel* lb_tip = [UILabel new];
        lb_tip.text = @"养老金、退休金、补贴金等领钱认证";
        lb_tip.textColor = [UIColor colorWithHex:0x808080];
        lb_tip.font = [UIFont fontWithName:@"PingFang SC" size:14* WIDTHRADIU];
        [hiddenView addSubview:lb_tip];


//        UIButton* messageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [messageBtn setTitle:@"社保认证领取养老金" forState:UIControlStateNormal];
//        [messageBtn setTitleColor:[UIColor colorWithHex:0x808080] forState:UIControlStateNormal];
//        messageBtn.titleLabel.font = [UIFont fontWithName:@"PingFang SC" size:14* WIDTHRADIU];
//        [messageBtn setImage:[UIImage imageNamed:@"椭圆-12"] forState:UIControlStateNormal];
        [hiddenView addSubview:lb_tip];
        [lb_tip mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.offset(0);
        }];
        
        
        
       
        
        //协议button
        UIButton* xieyiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [xieyiBtn setTitle:@"同意  <<用户服务协议>>" forState:UIControlStateNormal];
        [xieyiBtn setTitleColor:[UIColor colorWithHex:0x333333] forState:UIControlStateNormal];
        xieyiBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        [xieyiBtn addTarget:self action:@selector(KankanXieYi:) forControlEvents:UIControlEventTouchUpInside];
        [_scrollView addSubview:xieyiBtn];
        
        [xieyiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(agressBtn);
            make.left.equalTo(agressBtn.mas_right).offset(0);
            make.width.offset(120);
            make.height.offset(25);
        }];
        
        NSString *provice=[[NSUserDefaults standardUserDefaults]stringForKey:@"chooseProvince"];//选择的省份
        NSString *locationProvince=[[NSUserDefaults standardUserDefaults]stringForKey:@"locationProvince"];//定位的省份
        NSString *essCardProvince=[[NSUserDefaults standardUserDefaults]stringForKey:@"EssCardProvince"];//支持的省份
        if(locationProvince!=nil){
            int i=locationProvince.length;
            if (i>2) {
                locationProvince=[locationProvince substringToIndex:2];//取省份前两位
                provice=locationProvince;
            }
        }
        if(provice!=nil){
            int i=provice.length;
            if (i>2) {
                provice=[provice substringToIndex:2];//取省份前两位
            }
            if([essCardProvince containsString:provice]){
                UIButton* nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
                [nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                nextBtn.backgroundColor = [UIColor colorWithHex:0xc5c5c5];
                nextBtn.titleLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
                nextBtn.layer.cornerRadius = 5 * WIDTHRADIU;
                nextBtn.userInteractionEnabled = NO;
                self.PhotoBtn = nextBtn;
                [self.PhotoBtn addTarget:self action:@selector(photo:) forControlEvents:UIControlEventTouchUpInside];
                
               [_scrollView addSubview:nextBtn];
                
                [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(hiddenView.mas_bottom).offset(13 * WIDTHRADIU);
                    make.left.offset(20 * WIDTHRADIU);
                    make.right.offset(-200 * WIDTHRADIU);
                    make.height .offset(45 * WIDTHRADIU);
                }];
                
                UIButton* essBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                [essBtn setTitle:@"国家认证平台" forState:UIControlStateNormal];
                [essBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                essBtn.backgroundColor = [UIColor colorWithHex:0x2F72FA];
                essBtn.titleLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
                essBtn.layer.cornerRadius = 5 * WIDTHRADIU;
                [essBtn addTarget:self action:@selector(essphoto:) forControlEvents:UIControlEventTouchUpInside];
                [_scrollView addSubview:essBtn];
                
                [essBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(hiddenView.mas_bottom).offset(13 * WIDTHRADIU);
                    make.left.equalTo(nextBtn.mas_right).offset(20 * WIDTHRADIU);
                    make.right.offset(-20 * WIDTHRADIU);
                    make.height .offset(45 * WIDTHRADIU);
                }];
            }else{
                //uibutton
                UIButton* nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
                [nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                nextBtn.backgroundColor = [UIColor colorWithHex:0xc5c5c5];
                nextBtn.titleLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
                nextBtn.layer.cornerRadius = 5 * WIDTHRADIU;
                nextBtn.userInteractionEnabled = NO;
                self.PhotoBtn = nextBtn;
                [self.PhotoBtn addTarget:self action:@selector(photo:) forControlEvents:UIControlEventTouchUpInside];
        
               [_scrollView addSubview:nextBtn];
        
                [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(hiddenView.mas_bottom).offset(13 * WIDTHRADIU);
                    make.left.offset(27 * WIDTHRADIU);
                    make.right.offset(-27 * WIDTHRADIU);
                    make.height .offset(45 * WIDTHRADIU);
                }];
            }
        }else{
            //uibutton
            UIButton* nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
            [nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            nextBtn.backgroundColor = [UIColor colorWithHex:0xc5c5c5];
            nextBtn.titleLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
            nextBtn.layer.cornerRadius = 5 * WIDTHRADIU;
            nextBtn.userInteractionEnabled = NO;
            self.PhotoBtn = nextBtn;
            [self.PhotoBtn addTarget:self action:@selector(photo:) forControlEvents:UIControlEventTouchUpInside];
    
           [_scrollView addSubview:nextBtn];
    
            [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(hiddenView.mas_bottom).offset(13 * WIDTHRADIU);
                make.left.offset(27 * WIDTHRADIU);
                make.right.offset(-27 * WIDTHRADIU);
                make.height .offset(45 * WIDTHRADIU);
            }];
        }

        
        
        
        
        
//        //协议button
//
//         [agressBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//             make.centerY.equalTo(xieyiBtn);
//             make.right.equalTo(xieyiBtn.mas_left).offset(-10);
//             make.height.offset(30);
//         }];
        
        
        UILabel*lb_shengming = [[UILabel alloc]init];
        lb_shengming.text = @"在此声明,此app内发生的所有事件与Apple Inc. 无关";
        lb_shengming.textColor = [UIColor colorWithHex:0x828282];
        lb_shengming.font = [UIFont systemFontOfSize:13];
        lb_shengming.textAlignment = NSTextAlignmentCenter;
        [_scrollView addSubview:lb_shengming];
        [lb_shengming mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.PhotoBtn.mas_bottom).offset(20);
            make.centerX.offset(0);
            make.height.mas_greaterThanOrEqualTo(10);
            make.bottom.mas_equalTo( - 10 );
        }];
 
        
    }
    return _scrollView;
}

- (NSMutableArray *)dataArray
{
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

-(NSMutableArray *)array
{
    if (!_array) {
        _array =[NSMutableArray new];
      
    }
    return _array;
    
}
-(NSMutableArray *)baochunShuZu
{

    if (!_baochunShuZu) {
        _baochunShuZu =[NSMutableArray new];
      
    }
    return _baochunShuZu;


}
-(NSMutableArray *)dataArr
{
    if (!_dataArr) {
        _dataArr =[NSMutableArray new];
    }
    return _dataArr;
}

@end
