mixin.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var prefix = 'jp_charging_merchantUser_ud_' + 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. getPersonInfoPlus : () => {
  8. return uni.getStorageSync(prefix + 'personInfoPlus')
  9. },
  10. getPersonInfo : () => {
  11. return uni.getStorageSync(prefix + 'personInfo')
  12. },
  13. signOut:()=> uni.removeStorageSync(prefix + 'personInfo'),
  14. getOpenId : () => uni.getStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID),
  15. setOpenId: (value) => uni.setStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID, value),
  16. setPersonInfo : (value) =>{
  17. uni.setStorageSync(prefix + 'personInfo', value)
  18. },
  19. setPersonInfoPlus : (value) =>{
  20. uni.setStorageSync(prefix + 'personInfoPlus', value)
  21. },
  22. getToken : (options) => {
  23. //不同权限 ,不同token
  24. return uni.getStorageSync(prefix + 'token')
  25. },
  26. setToken : (value) => {
  27. uni.setStorageSync(prefix + 'token', value)
  28. if(value){
  29. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  30. uni.setStorageSync(prefix + 'token_tdate', tdate)
  31. }
  32. }
  33. ,
  34. }
  35. module.exports = app