//
//  HTHttpConfig.m
//  SQlDemo
//
//  Created by xiejiangbo on 2017/11/20.
//  Copyright © 2017年 yin chen. All rights reserved.
//

#import "HTHttpConfig.h"
static NSString const * kPVHttpConfig_AccessToken = @"kPVHttpConfig_AccessToken";
static NSString const *kRegisterKey = @"HTHttpConfig";

//static NSString const *kServiceAddressURL = @"http://10.1.225.45:8020";
///正式版
static NSString const *kServiceAddressURL1 = @"http://mobileportal.shaphar.com:8020/basservice";
static NSString const *imageURL1 = @"http://mobileportal.shaphar.com:8020";
///测试版
static NSString const *kServiceAddressURL = @"http://222.66.127.246:8020";
static NSString const *imageURL = @"http://222.66.127.246:8021";
///体验版
static NSString const *kServiceAddressURL2 = @"https://mobileportal.shaphar.com:8443/basservicenew";
static NSString const *imageURL2 = @"https://mobileportal.shaphar.com:8443";
//static NSString const *kServiceAddressURL2 = @"http://192.168.3.9:8028";
//static NSString const *kServiceAddressURL = @"http://192.168.1.166:8020";

@implementation HTHttpConfig
+(HTHttpConfig *)sharedInstance{
    static HTHttpConfig *_sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken,^{
        _sharedInstance = [[HTHttpConfig alloc] init];
    });
    return _sharedInstance;
}

-(NSString const *)getServerAddress:(NSString *)addressKey{
    if ([[[AccountInfo sharedInstance] isTest] isEqualToString:@"1"]) {
        return kServiceAddressURL;
    } else if ([[[AccountInfo sharedInstance] isTest] isEqualToString:@"2"]) {
        return kServiceAddressURL2;
    }
    return kServiceAddressURL1;
}
-(NSString const *)getImageAddress{
    if ([[[AccountInfo sharedInstance] isTest] isEqualToString:@"1"]) {
        return imageURL;
    } else if ([[[AccountInfo sharedInstance] isTest] isEqualToString:@"2"]) {
        return imageURL2;
    }
    return imageURL1;
}
+(const NSString *)registerKey{
    return kRegisterKey;
}

-(NSString *)accessToken
{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    return [userDefaults stringForKey:(NSString *)kPVHttpConfig_AccessToken];
}

-(void)setAccessToken:(NSString *)accessToken
{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:accessToken forKey:(NSString *)kPVHttpConfig_AccessToken];
}
@end
