index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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://cgst.liuniu946.com', //请求地址配置
  7. // baseURL: 'http://cgst.frp.liuniu946.com', //请求地址配置
  8. urlFile: '/index', //项目部署所在文件夹
  9. hasLogin: false, //是否登录
  10. userInfo: {}, //登录信息
  11. loginInterceptor: false, //是否打开强制登录
  12. orderInfo: {}, //订单信息
  13. token: '',
  14. // #ifdef H5
  15. setWeiChatInfo: '',
  16. weichatInfo: {}, //保存微信注册信息
  17. weichatObj: '', //微信对象
  18. weichatBrowser: '', //当前是否为微信内置浏览器
  19. // #endif
  20. // shareData:'',//分享信息
  21. },
  22. mutations: {
  23. // 登录
  24. login(state) {
  25. state.hasLogin = true;
  26. console.log(state.hasLogin, '123456');
  27. },
  28. // 退出登录
  29. logout(state) {
  30. state.hasLogin = false;
  31. state.userInfo = {};
  32. uni.removeStorage({
  33. key: 'userInfo'
  34. })
  35. // uni.removeStorage({
  36. // key: 'mystore'
  37. // })
  38. },
  39. // 保存用户信息
  40. setUserInfo(state, provider) {
  41. state.userInfo = provider;
  42. uni.setStorageSync('userInfo', provider)
  43. // if(provider.store_info){
  44. console.log(provider.store_info && !(uni.getStorageSync('mystore') || false));
  45. // uni.showModal({
  46. // title: '打印',
  47. // // content: !(uni.getStorageSync('mystore')||false)+'box:'+JSON.stringify(provider)
  48. // content: (uni.getStorageSync('mystore'))
  49. // });
  50. if (provider.store_info && !(uni.getStorageSync('mystore') || false)) {
  51. uni.setStorageSync('mystore', provider.store_info.id);
  52. } else {
  53. let value = uni.getStorageSync('mystore');
  54. console.log('---mystore-8-8-', value);
  55. }
  56. },
  57. // #ifdef H5
  58. //保存微信信息
  59. setWeiChatInfo(state, provider) {
  60. state.weichatInfo = provider;
  61. },
  62. //保存微信对象
  63. setWeiChatObj(state, provider) {
  64. state.weichatObj = provider;
  65. console.log('保存微信对象', state.weichatObj)
  66. }
  67. // #endif
  68. },
  69. actions: {
  70. }
  71. })
  72. export default store