var prefix = 'jp_charging_' + process.car.NODE_ENV + '_';

var app = {
	
	getPrefix:()=> prefix,
	get : key =>  uni.getStorageSync(prefix + key),

	set : (key, value) => uni.setStorageSync(prefix + key, value),
	remove: key =>  uni.removeStorageSync(prefix + key),
	
	getPersonInfo : () => {
		 return uni.getStorageSync(prefix + 'personInfo')
	},
	signOut:()=>  uni.removeStorageSync(prefix  + 'personInfo'),
	getOpenId : () =>   uni.getStorageSync(prefix + 'wx_openId'),

	setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId', value),
	setPersonInfo : (value) => uni.setStorageSync(prefix + 'personInfo', value),
	
	getToken : (options) => {
		//不同权限 ，不同token
		if(options&&options.jp_identity){
			return uni.getStorageSync(prefix+options.jp_identity+ '_token')
		}else{
			return uni.getStorageSync(prefix + 'token')
			
		}
	},
	setToken : (value) => {
		uni.setStorageSync(prefix + 'token', value)
		
		if(value){
			var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
			uni.setStorageSync(prefix + 'token_tdate', tdate)
		}
	}
	,
	
	
}

module.exports = app
