index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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://mmz.liuniu946.com', //请求地址配置
  7. // baseURL: 'https://xipintest.liuniu946.com', //请求地址配置http://mmz.liuniu946.com
  8. // baseURL: 'http://yrh.liuniu946.com', //请求地址配置
  9. urlFile: '/index', //项目部署所在文件夹
  10. hasLogin: false, //是否登录
  11. userInfo: {}, //登录信息
  12. loginInterceptor: false, //是否打开强制登录
  13. orderInfo: {}, //订单信息
  14. token: '',
  15. homeActive: false,
  16. // #ifdef H5
  17. setWeiChatInfo:'',
  18. weichatInfo: {}, //保存微信注册信息
  19. weichatObj: '', //微信对象
  20. weichatBrowser: '' ,//当前是否为微信内置浏览器
  21. // #endif
  22. // shareData:'',//分享信息
  23. },
  24. mutations: {
  25. // 登录
  26. login(state) {
  27. state.hasLogin = true;
  28. },
  29. // 退出登录
  30. logout(state) {
  31. state.hasLogin = false;
  32. state.userInfo = {};
  33. uni.removeStorage({
  34. key: 'userInfo'
  35. })
  36. },
  37. // 保存用户信息
  38. setUserInfo(state, provider) {
  39. state.userInfo = provider;
  40. uni.setStorage({ //缓存用户登陆状态
  41. key: 'userInfo',
  42. data: provider
  43. })
  44. },
  45. // #ifdef H5
  46. //保存微信信息
  47. setWeiChatInfo(state, provider) {
  48. state.weichatInfo = provider;
  49. },
  50. //保存微信对象
  51. setWeiChatObj(state, provider) {
  52. state.weichatObj = provider;
  53. },
  54. // #endif
  55. OPEN_HOME(state) {
  56. state.homeActive = true;
  57. },
  58. CLOSE_HOME(state) {
  59. state.homeActive = false;
  60. },
  61. },
  62. actions: {
  63. }
  64. })
  65. export default store