index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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://js.frp.liuniu946.com',
  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. // 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. // 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. }
  53. else {
  54. let value = uni.getStorageSync('mystore');
  55. console.log('---mystore-8-8-',value);
  56. }
  57. },
  58. // #ifdef H5
  59. //保存微信信息
  60. setWeiChatInfo(state, provider) {
  61. state.weichatInfo = provider;
  62. },
  63. //保存微信对象
  64. setWeiChatObj(state, provider) {
  65. state.weichatObj = provider;
  66. console.log('保存微信对象',state.weichatObj)
  67. }
  68. // #endif
  69. },
  70. modules:{
  71. user
  72. },
  73. actions: {
  74. }
  75. })
  76. export default store