index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import user from './model/user'
  4. Vue.use(Vuex)
  5. const store = new Vuex.Store({
  6. state: {
  7. baseURL: 'http://www.babido.cn' ,
  8. // baseURL: 'https://zhibo.liuniu946.com', //请求地址配置
  9. urlFile:'/index',//项目部署所在文件夹
  10. hasLogin: false, //是否登录
  11. userInfo: {}, //登录信息
  12. loginInterceptor: false, //是否打开强制登录
  13. orderInfo: {}, //订单信息
  14. token:'',
  15. // #ifdef H5
  16. setWeiChatInfo:'',
  17. weichatInfo: {}, //保存微信注册信息
  18. weichatObj: '', //微信对象
  19. weichatBrowser: '' ,//当前是否为微信内置浏览器
  20. // #endif
  21. },
  22. mutations: {
  23. // 登录
  24. login(state) {
  25. state.hasLogin = true;
  26. },
  27. // 退出登录
  28. logout(state) {
  29. state.hasLogin = false;
  30. state.userInfo = {};
  31. uni.removeStorage({
  32. key: 'userInfo'
  33. })
  34. // uni.removeStorage({
  35. // key: 'mystore'
  36. // })
  37. },
  38. // 保存用户信息
  39. setUserInfo(state, provider) {
  40. state.userInfo = provider;
  41. uni.setStorageSync('userInfo',provider)
  42. // if(provider.store_info){
  43. console.log(provider.store_info && !(uni.getStorageSync('mystore')||false));
  44. // uni.showModal({
  45. // title: '打印',
  46. // // content: !(uni.getStorageSync('mystore')||false)+'box:'+JSON.stringify(provider)
  47. // content: (uni.getStorageSync('mystore'))
  48. // });
  49. if(provider.store_info && !(uni.getStorageSync('mystore')||false)){
  50. uni.setStorageSync('mystore',provider.store_info.id);
  51. }
  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. modules:{
  70. user
  71. },
  72. actions: {}
  73. })
  74. export default store