index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import user from './model/user'
  4. import i18n from '../libs/i18n/index.js'
  5. Vue.use(Vuex)
  6. const store = new Vuex.Store({
  7. state: {
  8. // #ifdef APP || MP
  9. baseURL: 'http://andreessens.com', //测试请求地址配置
  10. // baseURL: 'http://wap.vgst168.com', //请求地址配置
  11. // #endif
  12. // #ifdef H5
  13. baseURL:window.location.protocol + "//" + window.location.host, //请求地址配置
  14. // #endif
  15. urlFile: '/index', //项目部署所在文件夹
  16. loginInterceptor: false, //是否打开强制登录
  17. // #ifdef H5 || MP-WEIXIN
  18. weichatInfo: {}, //保存微信注册信息
  19. weichatObj: '', //微信对象
  20. // #endif
  21. langList: [
  22. {
  23. value: 'EN',
  24. label: 'English'
  25. },
  26. {
  27. value: 'CN',
  28. label: '简体中文'
  29. },
  30. {
  31. value: 'TW',
  32. label: '繁體中文'
  33. }
  34. ],
  35. lang:uni.getStorageSync('lang')||'TW',
  36. },
  37. mutations: {
  38. //保存微信信息
  39. setWeiChatInfo(state, provider) {
  40. state.weichatInfo = provider;
  41. },
  42. //保存微信对象
  43. setWeiChatObj(state, provider) {
  44. state.weichatObj = provider;
  45. },
  46. LANG(state, data) {
  47. uni.setStorageSync('lang', data)
  48. i18n.locale = data
  49. state.lang = data
  50. },
  51. },
  52. modules: {
  53. user
  54. },
  55. actions: {
  56. // 设置当前语言
  57. setLang({ commit }, data) {
  58. commit('LANG', data)
  59. // commit('VANTLANG', data)
  60. },
  61. }
  62. })
  63. export default store