//
//  RDSDataManager.m
//  singleProduct
//
//  Created by coderYK on 2018/4/28.
//  Copyright © 2018年 RDIOT. All rights reserved.
//

#import "RDSDataManager.h"
#import "NSString+convert.h"


@implementation RDSDataManager
@synthesize phone = _phone;
@synthesize verifyCode = _verifyCode;
@synthesize isFirstTimeAgree = _isFirstTimeAgree;
@synthesize token = _token;
@synthesize isSetPassword = _isSetPassword;

DEF_SINGLETON(RDSDataManager)

- (void)rds_cacheClean {
    self.currentUser = nil;
    self.detailHome = nil;
    self.current_home_name = @"";
    self.current_home_id = @"";
}

- (void)setIsFirstTimeAgree:(BOOL)isFirstTimeAgree{
    _isFirstTimeAgree = isFirstTimeAgree;
    [kUserDefaults setBool:isFirstTimeAgree forKey:@"isFirstTimeAgree"];
    [kUserDefaults synchronize];
}

- (BOOL)isFirstTimeAgree{
    _isFirstTimeAgree = [kUserDefaults boolForKey:@"isFirstTimeAgree"];
    return _isFirstTimeAgree;
}

- (void)setIsTest:(BOOL)isTest{
    _isTest = isTest;
    [kUserDefaults setBool:isTest forKey:@"isTest"];
    TheApiHelper.isTest = @(isTest).integerValue;
}

- (void)setIsSetPassword:(BOOL)isSetPassword{
    _isSetPassword = isSetPassword;
    [kUserDefaults setBool:isSetPassword forKey:@"isSetPassword"];
}

- (BOOL)isSetPassword{
    _isSetPassword = [kUserDefaults boolForKey:@"isSetPassword"];
    return _isSetPassword;
}

- (void)setPhone:(NSString *)phone{
    _phone = phone;
    [kUserDefaults setObject:phone forKey:@"userPhone"];
    [kUserDefaults synchronize];
}

- (NSString *)phone{
    _phone = [kUserDefaults objectForKey:@"userPhone"];
    return _phone;
}


- (void)setVerifyCode:(NSString *)verifyCode{
    _verifyCode = verifyCode;
    [kUserDefaults setObject:verifyCode forKey:@"verifyCode"];
    [kUserDefaults synchronize];
}

- (NSString *)verifyCode{
    _verifyCode = [kUserDefaults objectForKey:@"verifyCode"];
    return _verifyCode;
}

- (void)setToken:(NSString *)token{
    _token = token;
    [kUserDefaults setObject:token forKey:@"token"];
}

- (NSString *)token{
    if(kNULLString(_token)){
        _token = [kUserDefaults objectForKey:@"token"];
    }
    if(kNULLString(_token)){
        _token = @"";
    }
    return _token;
}




- (RDSUserInfoModel *)currentUser{
    if(_currentUser == nil){
        _currentUser = [RDSUserInfoModel rds_allocInit];
    }
    return _currentUser;
}





@end




