index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)
  4. const store = new Vuex.Store({
  5. state: {
  6. baseURL: 'https://sos.liuniu946.com', //请求地址配置
  7. urlFile: '/index', //项目部署所在文件夹
  8. hasLogin: false, //是否登录
  9. userInfo: {}, //登录信息
  10. loginInterceptor: false, //是否打开强制登录
  11. orderInfo: {}, //订单信息
  12. token:'',
  13. // #ifdef H5
  14. setWeiChatInfo:'',
  15. Lat:'',
  16. Lng:'',
  17. weichatInfo: {}, //保存微信注册信息
  18. weichatObj: '', //微信对象
  19. weichatBrowser: '' ,//当前是否为微信内置浏览器
  20. // #endif
  21. // shareData:'',//分享信息
  22. },
  23. mutations: {
  24. // 登录
  25. login(state) {
  26. state.hasLogin = true;
  27. },
  28. // 退出登录
  29. logout(state) {
  30. state.hasLogin = false;
  31. state.userInfo = {};
  32. uni.removeStorage({
  33. key: 'userInfo'
  34. })
  35. },
  36. // 保存用户信息
  37. setUserInfo(state, provider) {
  38. state.userInfo = provider;
  39. uni.setStorage({ //缓存用户登陆状态
  40. key: 'userInfo',
  41. data: provider
  42. })
  43. },
  44. // #ifdef H5
  45. //保存微信信息
  46. setWeiChatInfo(state, provider) {
  47. state.weichatInfo = provider;
  48. },
  49. //保存微信对象
  50. setWeiChatObj(state, provider) {
  51. state.weichatObj = provider;
  52. }
  53. // #endif
  54. },
  55. actions: {
  56. }
  57. })
  58. export default store