mixin.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var prefix = 'jp_xqjy_' + 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. getConfig : () => {
  8. var config = uni.getStorageSync(prefix + '_config_$')
  9. var configure={}
  10. if(config){
  11. for(var i in config){
  12. var con=config[i];
  13. configure[con.key]=con.value
  14. }
  15. }
  16. return configure;
  17. },
  18. setConfig : (value) => uni.setStorageSync(prefix + '_config_$', value),
  19. getPersonInfoPlus : () => {
  20. return uni.getStorageSync(prefix + 'personInfoPlus')
  21. },
  22. getPersonInfo : () => {
  23. return uni.getStorageSync(prefix + 'personInfo')
  24. },
  25. logoff:()=>{
  26. uni.removeStorageSync(prefix + 'token_tdate')
  27. uni.removeStorageSync(prefix + 'token')
  28. uni.removeStorageSync(prefix + 'personInfo');
  29. uni.removeStorageSync(prefix + 'personInfoPlus');
  30. //uni.removeStorageSync(prefix+'wx_openId');
  31. },
  32. signOut:()=> uni.removeStorageSync(prefix + 'personInfo'),
  33. getOpenId : () => uni.getStorageSync(prefix + 'wx_openId'),
  34. setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId', value),
  35. setPersonInfo : (value) => uni.setStorageSync(prefix + 'personInfo', value),
  36. setPersonInfoPlus : (value) => uni.setStorageSync(prefix + 'personInfoPlus', value),
  37. getToken : () => uni.getStorageSync(prefix + 'token'),
  38. setToken : (value) => {
  39. uni.setStorageSync(prefix + 'token', value)
  40. if(value){
  41. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  42. uni.setStorageSync(prefix + 'token_tdate', tdate)
  43. }
  44. }
  45. ,
  46. }
  47. module.exports = app