let isDev = process.env.NODE_ENV === "development";

const UUID = isDev ? "uuid_key_dev" : "uuid_key";
const CURRENT_PLOT = isDev ? "current_plot_dev" : "current_plot";
const CURRENT_USER_PLOTS_LIST = isDev ? "user_plots_list_dev" : "user_plots_list";
const HAS_LOGIN = isDev ? "has_login_key_dev" : "has_login_key";
const ACCESS_TOKEN = isDev ? "access_token_key_dev" : "access_token_key";
const REFRESH_TOKEN = isDev ? "refresh_token_key_dev" : "refresh_token_key";
const USER_INFO = isDev ? "user_info_obj_dev" : "user_info_obj";
const AFTERSALE_DATA = isDev ? "aftersale_data_dev" : "aftersale_data";
const PRIVACY_AGREED = isDev ? "privacy_agreed_dev" : "privacy_agreed";
export default {
	setDict(type,val){
		uni.setStorageSync(type, val);
	},
	removeCurrentPlot(){
		uni.removeStorageSync(CURRENT_PLOT);
	},
	removeUserPlots(){
		uni.removeStorageSync(CURRENT_USER_PLOTS_LIST);
	},
	removeDict(type){
		uni.removeStorageSync(type);
	},
	setInviter(val) {
		uni.setStorageSync('inviter', val)
	},
	getInviter() {
		return uni.getStorageSync('inviter');
	},
	// 写入用户信息
	setUserInfo(val) {
		uni.setStorageSync(USER_INFO, val);
	},
	setCurrentUserPlotsList(val){
		uni.setStorageSync(CURRENT_USER_PLOTS_LIST,val)
	},
	getCurrentUserPlotsList(){
		return uni.getStorageSync(CURRENT_USER_PLOTS_LIST);
	},
	// 获取用户信息
	getUserInfo() {
		return uni.getStorageSync(USER_INFO);
	},
	// 写入uuid
	setUuid(val) {
		uni.setStorageSync(UUID, val);
	},
	// 获取uuid
	getUuid() {
		return uni.getStorageSync(UUID);
	},
	// 写入登录
	setHasLogin(val) {
		uni.setStorageSync(HAS_LOGIN, val);
	},
	// 获取是否登录
	getHasLogin() {
		return uni.getStorageSync(HAS_LOGIN);
	},
	// 删除uuid
	removeUuid() {
		uni.removeStorageSync(UUID);
	},
	// 写入accessToken
	setAccessToken(val) {
		uni.setStorageSync(ACCESS_TOKEN, val);
	},
	// 获取accessToken
	getAccessToken() {
		return uni.getStorageSync(ACCESS_TOKEN);
	},

	// 删除token
	removeAccessToken() {
		uni.removeStorageSync(ACCESS_TOKEN);
	},
	// 写入刷新token
	setRefreshToken(val) {
		uni.setStorageSync(REFRESH_TOKEN, val);
	},
	// 获取刷新token
	getRefreshToken() {
		return uni.getStorageSync(REFRESH_TOKEN);
	},
	// 删除token
	removeRefreshToken() {
		uni.removeStorageSync(REFRESH_TOKEN);
	},

	setPlots(val) {
		uni.setStorageSync(CURRENT_PLOT, val)
	},

	getPlots() {
		return uni.getStorageSync(CURRENT_PLOT)
	},
	// 删除token
	removeAfterSaleData() {
		uni.removeStorageSync(AFTERSALE_DATA);
	},
	// 是否登录检查
	isLoggedIn() {
		return !!this.getHasLogin() && !!this.getAccessToken();
	},
	setWvpAccessToken(val){
		uni.setStorageSync('wvp_access_token', val);
	},
	getWvpAccessToken() {
		return uni.getStorageSync('wvp_access_token');
	},
	// 设置隐私协议同意状态
	setPrivacyAgreed(val) {
		uni.setStorageSync(PRIVACY_AGREED, val);
	},
	// 获取隐私协议同意状态
	getPrivacyAgreed() {
		return uni.getStorageSync(PRIVACY_AGREED);
	},
	// 删除隐私协议同意状态
	removePrivacyAgreed() {
		uni.removeStorageSync(PRIVACY_AGREED);
	},
};