index.js 1.2 KB

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