index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. baseURL: 'http://www.accle.shop', //请求地址配置
  9. urlFile: '/index', //项目部署所在文件夹
  10. loginInterceptor: false, //是否打开强制登录
  11. // #ifdef H5 || MP-WEIXIN
  12. weichatInfo: {}, //保存微信注册信息
  13. weichatObj: '', //微信对象
  14. // #endif
  15. langList: [
  16. {
  17. value: 'en',
  18. label: 'English'
  19. },
  20. {
  21. value: 'cn',
  22. label: '简体中文'
  23. },
  24. {
  25. value: 'tw',
  26. label: '繁體中文'
  27. }
  28. ],
  29. lang:uni.getStorageSync('lang')||'tw',
  30. },
  31. mutations: {
  32. //保存微信信息
  33. setWeiChatInfo(state, provider) {
  34. state.weichatInfo = provider;
  35. },
  36. //保存微信对象
  37. setWeiChatObj(state, provider) {
  38. state.weichatObj = provider;
  39. },
  40. LANG(state, data) {
  41. uni.setStorageSync('lang', data)
  42. i18n.locale = data
  43. state.lang = data
  44. },
  45. },
  46. modules: {
  47. user
  48. },
  49. actions: {
  50. // 设置当前语言
  51. setLang({ commit }, data) {
  52. commit('LANG', data)
  53. // commit('VANTLANG', data)
  54. },
  55. }
  56. })
  57. export default store