mixin.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. var prefix = 'jp_charging2_' + process.car.NODE_ENV+process.car.envjs + '_';
  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 : (jp_identity) => {
  8. if(jp_identity){
  9. return uni.getStorageSync(prefix +jp_identity+ '_personInfoPlus')
  10. }else{
  11. return uni.getStorageSync(prefix + 'personInfoPlus')
  12. }
  13. },
  14. getPersonInfo : (jp_identity) => {
  15. if(jp_identity){
  16. return uni.getStorageSync(prefix +jp_identity+ '_personInfo')
  17. }else{
  18. return uni.getStorageSync(prefix + 'personInfo')
  19. }
  20. },
  21. signOut:()=> uni.removeStorageSync(prefix + 'personInfo'),
  22. getOpenId : () => uni.getStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID),
  23. setOpenId: (value) => uni.setStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID, value),
  24. setPersonInfo : (value,jp_identity) =>{
  25. if(jp_identity){
  26. uni.setStorageSync(prefix + jp_identity+'_personInfo', value)
  27. }else{
  28. uni.setStorageSync(prefix + 'personInfo', value)
  29. }
  30. },
  31. setPersonInfoPlus : (value,jp_identity) =>{
  32. if(jp_identity){
  33. uni.setStorageSync(prefix + jp_identity+'_personInfoPlus', value)
  34. }else{
  35. uni.setStorageSync(prefix + 'personInfoPlus', value)
  36. }
  37. },
  38. getToken : (options) => {
  39. //不同权限 ,不同token
  40. if(options&&options.jp_identity){
  41. return uni.getStorageSync(prefix+options.jp_identity+ '_token')
  42. }else{
  43. return uni.getStorageSync(prefix + 'token')
  44. }
  45. },
  46. setToken : (value,jp_identity) => {
  47. if(jp_identity){
  48. uni.setStorageSync(prefix +jp_identity + '_token', value)
  49. if(value){
  50. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  51. uni.setStorageSync(prefix + jp_identity+'_token_tdate', tdate)
  52. }
  53. }else{
  54. uni.setStorageSync(prefix + 'token', value)
  55. if(value){
  56. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  57. uni.setStorageSync(prefix + 'token_tdate', tdate)
  58. }
  59. }
  60. }
  61. ,
  62. }
  63. module.exports = app