index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 H5
  9. baseURL:window.location.protocol + "//" + window.location.host,//请求地址配置
  10. // #endif
  11. // #ifndef H5
  12. baseURL: 'https://xinkong.vwetdd.cn', //正式地址配置
  13. // #endif
  14. urlFile: '/index', //项目部署所在文件夹
  15. loginInterceptor: false, //是否打开强制登录
  16. // #ifdef H5 || MP-WEIXIN
  17. weichatInfo: {}, //保存微信注册信息
  18. weichatObj: '', //微信对象
  19. isShowIllegality:true,
  20. // #endif
  21. // #ifdef APP
  22. isShowIllegality:false,
  23. // #endif
  24. langList: [
  25. {
  26. value: 'en',
  27. label: 'English'
  28. },
  29. {
  30. value: 'cn',
  31. label: '简体中文'
  32. },
  33. {
  34. value: 'tw',
  35. label: '繁體中文'
  36. }
  37. ],
  38. lang:uni.getStorageSync('lang')||'cn',
  39. },
  40. mutations: {
  41. // #ifdef APP
  42. // 设置http
  43. setHttp(state, provider){
  44. state.baseURL = provider
  45. },
  46. // #endif
  47. //保存微信信息
  48. setWeiChatInfo(state, provider) {
  49. state.weichatInfo = provider;
  50. },
  51. //保存微信对象
  52. setWeiChatObj(state, provider) {
  53. state.weichatObj = provider;
  54. },
  55. LANG(state, data) {
  56. uni.setStorageSync('lang', data)
  57. i18n.locale = data
  58. state.lang = data
  59. },
  60. // 修改显示隐藏ios审核不允许显示的功能
  61. changeState(state, provider){
  62. console.log(provider,'provider');
  63. state.isShowIllegality = provider;
  64. }
  65. },
  66. modules: {
  67. user
  68. },
  69. actions: {
  70. // 设置当前语言
  71. setLang({ commit }, data) {
  72. commit('LANG', data)
  73. // commit('VANTLANG', data)
  74. },
  75. }
  76. })
  77. export default store