mixin.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var prefix = 'jp_charging_' + process.car.NODE_ENV + '_';
  2. var app = {
  3. getPrefix:()=> prefix,
  4. get : key => uni.getStorageSync(prefix + key),
  5. set : (key, value) => uni.setStorageSync(prefix + key, value),
  6. remove: key => uni.removeStorageSync(prefix + key),
  7. getPersonInfo : () => {
  8. return uni.getStorageSync(prefix + 'personInfo')
  9. },
  10. signOut:()=> uni.removeStorageSync(prefix + 'personInfo'),
  11. getOpenId : () => uni.getStorageSync(prefix + 'wx_openId'),
  12. setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId', value),
  13. setPersonInfo : (value) => uni.setStorageSync(prefix + 'personInfo', value),
  14. getToken : (options) => {
  15. //不同权限 ,不同token
  16. if(options&&options.jp_identity){
  17. return uni.getStorageSync(prefix+options.jp_identity+ '_token')
  18. }else{
  19. return uni.getStorageSync(prefix + 'token')
  20. }
  21. },
  22. setToken : (value) => {
  23. uni.setStorageSync(prefix + 'token', value)
  24. if(value){
  25. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  26. uni.setStorageSync(prefix + 'token_tdate', tdate)
  27. }
  28. }
  29. ,
  30. }
  31. module.exports = app