mixin.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 : (jp_identity) => {
  8. if(jp_identity){
  9. return uni.getStorageSync(prefix +jp_identity+ '_personInfo')
  10. }else{
  11. return uni.getStorageSync(prefix + 'personInfo')
  12. }
  13. },
  14. signOut:()=> uni.removeStorageSync(prefix + 'personInfo'),
  15. getOpenId : () => uni.getStorageSync(prefix + 'wx_openId'),
  16. setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId', value),
  17. setPersonInfo : (value,jp_identity) =>{
  18. if(jp_identity){
  19. uni.setStorageSync(prefix + jp_identity+'_personInfo', value)
  20. }else{
  21. uni.setStorageSync(prefix + 'personInfo', value)
  22. }
  23. },
  24. getToken : (options) => {
  25. //不同权限 ,不同token
  26. if(options&&options.jp_identity){
  27. return uni.getStorageSync(prefix+options.jp_identity+ '_token')
  28. }else{
  29. return uni.getStorageSync(prefix + 'token')
  30. }
  31. },
  32. setToken : (value,jp_identity) => {
  33. if(jp_identity){
  34. uni.setStorageSync(prefix +jp_identity + '_token', value)
  35. if(value){
  36. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  37. uni.setStorageSync(prefix + jp_identity+'_token_tdate', tdate)
  38. }
  39. }else{
  40. uni.setStorageSync(prefix + 'token', value)
  41. if(value){
  42. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  43. uni.setStorageSync(prefix + 'token_tdate', tdate)
  44. }
  45. }
  46. }
  47. ,
  48. }
  49. module.exports = app