//
//  getPeopleID.m
//  Open
//
//  Created by 看看智能 on 2017/2/22.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "getPeopleID.h"

#import "SDImageCache.h"
#import "SDWebImageManager.h"
#import "UIImageView+WebCache.h"
#import <MobPush/MobPush.h>
@implementation getPeopleID
/**
 得到人的id
 */

+(void)getPeopleID:(NSInteger)ID{
 [[NSUserDefaults standardUserDefaults]setInteger:ID forKey:@"IDHJT"];
    //设置mob别名
    NSString *alias=[NSString stringWithFormat:@"iOSkksh_%ld",(long)ID];
    [MobPush setAlias:alias result:^(NSError *error) {
      }];
}
+(void)socialSate:(NSInteger)ID{
 [[NSUserDefaults standardUserDefaults]setInteger:ID forKey:@"socialState"];
}
+(void)getPeopletitle:(NSString *)title
{
    [[NSUserDefaults standardUserDefaults]setValue:title forKey:@"titleHJT"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
+(void)getPeoplePhoto:(NSString *)photo
{
[[NSUserDefaults standardUserDefaults]setValue:photo forKey:@"ImageHJT"];
    [[NSUserDefaults standardUserDefaults]synchronize];

}
+(void)getPeopleIphoneNmber:(NSString*)iphone{
        [[NSUserDefaults standardUserDefaults]setValue:iphone forKey:@"iphoneHJT"];
}
+(void)getAppleyPay:(NSString*)city{
     [[NSUserDefaults standardUserDefaults]setValue:city forKey:@"applePaycity"];
}
//推送,未登录,登陆成功后,自动到推送目的地
+(void)goToMobPush:(UIViewController*)vc{
    
    NSString *url=[[NSUserDefaults standardUserDefaults]objectForKey:@"mob_pushUrl"];
    NSString *type=[[NSUserDefaults standardUserDefaults]objectForKey:@"mob_pushType"];
    if(url!=nil&&type!=nil){
        if([type isEqualToString:@"0"]){//url
            WebVC *webvc = [[WebVC alloc]init];
            webvc.url = url;
            webvc.title = @"";
            webvc.hidesBottomBarWhenPushed = YES;
            [vc.navigationController pushViewController:webvc animated:YES];
        }else if([type isEqualToString:@"2"]){//原生
            [[clickEvent instance] clickEventRooterVC:vc Content:url menuName:url];
        }else if([type isEqualToString:@"3"]){//联合登录
            [[clickEvent instance]clickEventRooterVC:vc getFederatedLoginRequestWithUrl:url menuName:@""];
        
        }
        [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"mob_pushUrl"];
        [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"mob_pushType"];
    }
}


+(NSInteger)PeopleID
{
return [[NSUserDefaults standardUserDefaults] integerForKey:@"IDHJT"];
}
+(NSInteger)socialSate
{
return [[NSUserDefaults standardUserDefaults] integerForKey:@"socialState"];
}
+(NSURL *)PeoplePhoto
{
 NSString *str1 =   [[NSUserDefaults standardUserDefaults] valueForKey:@"ImageHJT"];
  return [NSURL URLWithString:str1];
}
+(NSString *)Peopletitle
{
  
   return [EnercryTool decryptUseDES:[[NSUserDefaults standardUserDefaults]valueForKey:@"titleHJT"] key:DESKEY];
}
+(void)getpeopleLimitedAuthority:(BOOL)jurisdiction
{
return [[NSUserDefaults standardUserDefaults] setBool:jurisdiction forKey:@"jurisdiction"];

}

+(void)getSocialSecurityProvinceData:(NSString *)province andCountry:(NSString *)country andOther:(NSString *)other
{
  [[NSUserDefaults standardUserDefaults]setValue:province forKey:@"province_1"];
      [[NSUserDefaults standardUserDefaults]setValue:country forKey:@"country_1"];
      [[NSUserDefaults standardUserDefaults]setValue:other forKey:@"other_1"];
}
+(NSString *)province
{
return [[NSUserDefaults standardUserDefaults]valueForKey:@"province_1"];
}
+(NSString *)country
{
return [[NSUserDefaults standardUserDefaults]valueForKey:@"country_1"];
}

+(NSString*)applePaycity{
    
    return [[NSUserDefaults standardUserDefaults]valueForKey:@"applePaycity"];
    
    
}
+(NSString *)other
{
return [[NSUserDefaults standardUserDefaults]valueForKey:@"other_1"];
}
+(NSString *)PeopleIphoneNmber
{
    return[EnercryTool decryptUseDES:[[NSUserDefaults standardUserDefaults]valueForKey:@"iphoneHJT"] key:DESKEY];
}

+(NSString *)PeopleUnPhoneNmber
{
    return[[NSUserDefaults standardUserDefaults]valueForKey:@"iphoneHJT"];
}
+(void)getprovinceNightSix:(NSString*)city{
     [[NSUserDefaults standardUserDefaults]setValue:city forKey:@"provinceNightSix"];
}
+(NSString*)getprovinceNightSix{
     return [[NSUserDefaults standardUserDefaults]valueForKey:@"provinceNightSix"];
    
}




+(void)getoldPassword:(NSString *)old
{
    [[NSUserDefaults standardUserDefaults]setValue:old forKey:@"oldPassHJT"];
    [[NSUserDefaults standardUserDefaults]synchronize];

}
+(NSString *)getoldPassword
{
    return [[NSUserDefaults standardUserDefaults]valueForKey:@"oldPassHJT"];}

+(void)getNewPassword:(NSString *)newW
{
    [[NSUserDefaults standardUserDefaults]setValue:newW forKey:@"newPassHJT"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
+(NSString*)getNewPassword
{
return [[NSUserDefaults standardUserDefaults]valueForKey:@"NewPassHJT"];

}
+(void)getPeopleFilePhoto:(NSData *)image
{
[[NSUserDefaults standardUserDefaults]setValue:image forKey:@"ImageFileHJT"];
}
+(NSData *)getFileImage
{
    return  [[NSUserDefaults standardUserDefaults] valueForKey:@"ImageFileHJT"];
}
//账户权限
+(BOOL)getpeopleLimited
{
return [[NSUserDefaults standardUserDefaults] boolForKey:@"jurisdiction"];
}
+(NSString *)getProvince
{
  return  [[NSUserDefaults standardUserDefaults] valueForKey:@"provinceKK"];
}
+(void)getProvince:(NSString *)peopleProvince
{
  [[NSUserDefaults standardUserDefaults]setValue:peopleProvince forKey:@"provinceKK"];
}




+(void)getLimmitedToBanbana:(BOOL)jurisdiction
{
    return [[NSUserDefaults standardUserDefaults] setBool:jurisdiction forKey:@"banbanaIosLimited"];
    
}
+(BOOL)LimmitedToBanbana
{
    return [[NSUserDefaults standardUserDefaults] boolForKey:@"banbanaIosLimited"];
}

+(void)deletePlist{
    
    NSString *docPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES).firstObject;
    NSString *plistPath=[docPath stringByAppendingPathComponent:@"users.plist"];

    NSFileManager *fileManager = [NSFileManager defaultManager];
        [fileManager removeItemAtPath:plistPath error:nil];
}


+(void)createPlistByCode{

    NSString *docPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES).firstObject;
    NSString *plistPath=[docPath stringByAppendingPathComponent:@"users.plist"];
    NSDictionary *userDic=SUOYOUDE

    [userDic writeToFile:plistPath atomically:YES];
    NSLog(@"list Path %@", plistPath);
}

+(void)changePlistContentand:(NSString*)name{
    NSString *docPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES).firstObject;
    NSString *path=[docPath stringByAppendingPathComponent:@"users.plist"];
    NSMutableDictionary *userDics=[NSMutableDictionary dictionaryWithContentsOfFile:path];
    NSString *increatenumber =   [userDics objectForKey:name];
      NSLog(@"%@",increatenumber);
    
    
    NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:name];
    NSString * strUrl = [[increatenumber componentsSeparatedByCharactersInSet: doNotWant]componentsJoinedByString: @""];
    
    int sss = [strUrl intValue] ;
    int ggg = sss;
    ggg += 1;
    NSLog(@"%d",ggg);
    NSString * str2 =[NSString stringWithFormat:@"%d%@",ggg,name];
    NSLog(@"%@",str2);
    [userDics setObject:str2 forKey:name];
    [userDics writeToFile:path atomically:YES];
    NSLog(@"地址%@",path);
    NSInteger ingss =  [[NSUserDefaults standardUserDefaults] integerForKey:@"fucck"];
    ingss ++;
    [[NSUserDefaults standardUserDefaults] setInteger:ingss forKey:@"fucck"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    
}
-(NSMutableArray*)readPlist{
    
    NSString *docPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES).firstObject;
    NSString *path=[docPath stringByAppendingPathComponent:@"users.plist"];
    NSMutableDictionary *userDic=[NSMutableDictionary dictionaryWithContentsOfFile:path];

    NSArray   * charArray = [userDic allValues];
  
    for (NSString  * str in charArray) {
        NSLog(@"字符串数组排序结果%@",str);
    }

    NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch|NSNumericSearch|
    NSWidthInsensitiveSearch|NSForcedOrderingSearch;
    NSComparator sort = ^(NSString *obj1,NSString *obj2){
        NSRange range = NSMakeRange(0,obj1.length);
        return [obj1 compare:obj2 options:comparisonOptions range:range];
    };
    NSArray *resultArray2 = [[[charArray sortedArrayUsingComparator:sort] reverseObjectEnumerator]allObjects];
 
    
    for (NSString  * str in resultArray2) {
           NSLog(@"字符串数组排序结果%@",str);
    }
    
    
 
 

     NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"1234567890"];
     NSString * str____0 = [[resultArray2[0] componentsSeparatedByCharactersInSet: doNotWant]componentsJoinedByString: @""];

    NSLog(@"%@", str____0);
 NSString * str____1 = [[resultArray2[1] componentsSeparatedByCharactersInSet: doNotWant]componentsJoinedByString: @""];
    NSLog(@"%@", str____1);
 NSString * str____2 = [[resultArray2[2] componentsSeparatedByCharactersInSet: doNotWant]componentsJoinedByString: @""];
    NSLog(@"%@", str____2);
  NSString * str____3 = [[resultArray2[3] componentsSeparatedByCharactersInSet: doNotWant]componentsJoinedByString: @""];
    NSLog(@"%@", str____3);

    


    if (!str____0) {
           self.arrm = [NSMutableArray array];
    
    }else{
        self.arrm = [NSMutableArray array];
        [self.arrm addObject:str____0];
        [self.arrm addObject:str____1];
        [self.arrm addObject:str____2];
        [self.arrm addObject:str____3];
    
    }

    if ( [[NSUserDefaults standardUserDefaults] integerForKey:@"fucck"]  % 80 == 0) {
        
      
        
       [ [NSUserDefaults standardUserDefaults] setObject:self.arrm forKey:@"shuju_paixu"];
            return self.arrm;
    }else{
    return  [ [NSUserDefaults standardUserDefaults] objectForKey:@"shuju_paixu"];
    }
    
    

    
    
}


//leijunbo
+ (void)getLoginType:(NSString *)type
{
    [[NSUserDefaults standardUserDefaults]setValue:type forKey:@"loginType"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

//存储登录时间
+ (void)saveLoginTime:(NSDate *)time
{
    [[NSUserDefaults standardUserDefaults]setValue:time forKey:@"loginTime"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

//存储默认登录账户,每次都默认登录
+ (void)saveDefaultLoginAccount:(NSString *)account
{
    [[NSUserDefaults standardUserDefaults]setValue:account forKey:@"defaultLoginAccount"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

+ (void)saveDefaultLoginPassword:(NSString *)password
{
   [[NSUserDefaults standardUserDefaults]setValue:password forKey:@"defaultLoginPassword"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

+ (void)getLoginAccount:(NSString *)loginAccount
{
    [[NSUserDefaults standardUserDefaults]setValue:loginAccount forKey:@"loginAccount"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
+ (void)getLoginPassword:(NSString *)loginPassword
{
    [[NSUserDefaults standardUserDefaults]setValue:loginPassword forKey:@"loginPassword"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
//存储金币数据
+ (void)getTotalCoins:(NSDictionary *)dic
{
    
    
    if (dic) {
        NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
        [[NSUserDefaults standardUserDefaults]setValue:data forKey:@"totalCoins"];
        [[NSUserDefaults standardUserDefaults]synchronize];
    }else{
        [[NSUserDefaults standardUserDefaults]setValue:nil forKey:@"totalCoins"];
        [[NSUserDefaults standardUserDefaults]synchronize];
    }
}


+ (void)setOnFootCoinsDate:(NSDate *)currentDate
{
    [[NSUserDefaults standardUserDefaults]setValue:currentDate forKey:@"onFootCoinsDate"];
       [[NSUserDefaults standardUserDefaults]synchronize];
}



//存储选择默认省份
+ (void)getDefaultProvince:(NSString *)provinceName
{
    [[NSUserDefaults standardUserDefaults]setValue:provinceName forKey:@"defalutProvince"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

//删除存储金币数据
+ (void)clearTotalCoins
{
    [[NSUserDefaults standardUserDefaults]setValue:nil forKey:@"totalCoins"];
       [[NSUserDefaults standardUserDefaults]synchronize];
}
//删除存储默认省份
+ (void)clearDefaultProvince
{
    [[NSUserDefaults standardUserDefaults]setValue:nil forKey:@"defalutProvince"];
       [[NSUserDefaults standardUserDefaults]synchronize];
}


//存储
+ (void)saveAccountAuthWithState:(BOOL)state {
    
    [UserDefault setBool:state forKey:@"accountState"];
    [UserDefault synchronize];
}




+ (NSString *)loginType
{
    return  [[NSUserDefaults standardUserDefaults]objectForKey:@"loginType"];
}

//获取登录时间
+ (NSDate *)getLoginTime
{
    return  [[NSUserDefaults standardUserDefaults]objectForKey:@"loginTime"];
}

//获取默认登录账户
+ (NSString *)getDefaultLoginAccount
{
    return  [[NSUserDefaults standardUserDefaults]objectForKey:@"defaultLoginAccount"];
}
+ (NSString *)getDefaultLoginPassword
{
    return  [[NSUserDefaults standardUserDefaults]objectForKey:@"defaultLoginPassword"];
}

+ (NSString *)loginAccount
{
     return  [[NSUserDefaults standardUserDefaults]objectForKey:@"loginAccount"];
}
+ (NSString *)loginPassword
{
     return  [[NSUserDefaults standardUserDefaults]objectForKey:@"loginPassword"];
}

+ (NSDictionary *)totalCoins
{
    NSData *data = [[NSUserDefaults standardUserDefaults]objectForKey:@"totalCoins"];
    if ([data isKindOfClass:[NSData class]]) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
        
        return dic;
    }else if ([data isKindOfClass:[NSDictionary class]]){
        NSDictionary *dic = (NSDictionary *)data;
        return dic;
    } else{
        return nil;
    }
}

+ (NSString *)defaultProvince
{
    return  [[NSUserDefaults standardUserDefaults]objectForKey:@"defalutProvince"];
}


+ (NSDate *)getOnFootCoinsDate
{
   return  [[NSUserDefaults standardUserDefaults]objectForKey:@"onFootCoinsDate"];
}


+ (BOOL)accountState {
    return [UserDefault boolForKey:@"accountState"];
}






-(void)dealloc
{


}
@end
