//
//  logNSObject.m
//  Open
//
//  Created by 看看智能 on 2018/3/30.
//  Copyright © 2018年 黄江涛 . All rights reserved.
//

#import "logNSObject.h"

@implementation logNSObject
+ (NSString *)primaryKey {
    return @"LogId";
}
-(void)zhiwenHadnle:(zhiwen)zhiwengJieSuo
{
    
//    __weak typeof(self) weakSelf = self;
    
    LAContext *myContext = [[LAContext alloc] init];
    myContext.localizedFallbackTitle = @"验证失败,请手动登入";
    
    NSError *authError = nil;
    NSString *myLocalizedReasonString = @"请按住Home键完成验证";
    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError])
    {
        [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:myLocalizedReasonString reply:^(BOOL success, NSError * _Nullable error) {
            if(success)
            {
   
                
                NSArray * arrayHjt =  [HJTsqlite selectData:2 andModel:[logNSObject class] andName:@"LogId"];
                if (arrayHjt.count>0) {
                    for (logNSObject * models in arrayHjt) {
                        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstlog"];
                        [getPeopleID getPeopletitle:models.cusName];
                        [getPeopleID getPeoplePhoto:models.photo];
                        [getPeopleID getPeopleID:models.ID];
                        [getPeopleID getPeopleIphoneNmber:models.teltphone];
                        if (models.account_type == 0) {
                            [getPeopleID getpeopleLimitedAuthority:YES];
                        }else
                        {
                            [getPeopleID getpeopleLimitedAuthority:NO];
                        }

                    }
                       }
               zhiwengJieSuo(@"成功",error);
                
                
            }
            else
            {
                
             
                switch (error.code)
                {
                    case LAErrorAuthenticationFailed: // Authentication was not successful, because user failed to provide valid credentials
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                    case LAErrorUserCancel:
                    {
                        zhiwengJieSuo(@"失败",error);
                        
                    }
                        break;
                    case LAErrorUserFallback:
                    {
                        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                            zhiwengJieSuo(@"失败",error);
                        }];
                        
                    }
                        break;
                    case LAErrorSystemCancel:
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                    case LAErrorPasscodeNotSet:
                        
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                    case LAErrorTouchIDNotAvailable:
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                    case LAErrorTouchIDNotEnrolled:
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                        
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0
                    case LAErrorTouchIDLockout:
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                    case LAErrorAppCancel:
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
                    case LAErrorInvalidContext:
                    {
                        zhiwengJieSuo(@"失败",error);
                    }
                        break;
#else
#endif
                    default:
                    {
                        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                            zhiwengJieSuo(@"失败",error);
                        }];
                        break;
                    }
                }
            }
        }];
    }
    else
    {
        zhiwengJieSuo(@"失败",nil);
        switch (authError.code)
        {
            case LAErrorTouchIDNotEnrolled:
            {
                break;
            }
            case LAErrorPasscodeNotSet:
            {
                break;
            }
            default:
            {
                break;
            }
        }
    }
    
}
-(void)zhiwen{
 
    
    
    
    
}




@end
