diff --git a/src/common/axios.js b/src/common/axios.js index 2d12bba7..78b032fa 100644 --- a/src/common/axios.js +++ b/src/common/axios.js @@ -3,18 +3,18 @@ import instance from './http' instance.interceptors.request.use(config => { store.commit('initWaterMarker') - + let {module} = store.state if (/\/node\//.test(config.url)) { config.baseURL = '/ns' - } else if (/AppCountryAlbum/.test(location.pathname) || config.module == 'AppCountryAlbum') { + } else if (/AppCountryAlbum/.test(location.pathname) || config.module == 'AppCountryAlbum' || module == "AppCountryAlbum") { config.baseURL = '/aca' config.url = config.url.replace(/(app|auth|admin)\//, "api/") - } else if (/\/project\/beta\//.test(location.pathname) || config.module == 'wangge' || store.state.config.corpid == 'ww2a667717a70164f1') { + } else if (/\/project\/beta\//.test(location.pathname) || config.module == 'wangge' || module == "wangge") { config.baseURL = '/wangge' - } else if (/\/project\/police\//.test(location.pathname) || config.module == 'hnjc') { + } else if (/\/project\/police\//.test(location.pathname) || config.module == 'hnjc' || module == "hnjc") { config.baseURL = '/hnjc' config.url = config.url.replace(/(app|auth|admin)\//, "api/") - } else if (sessionStorage.getItem("prj") == "saas") { + } else if (sessionStorage.getItem("prj") == "saas" || module == "saas") { config.baseURL = '/online' } else config.baseURL = "/lan" return config diff --git a/src/pages/login.vue b/src/pages/login.vue index acd17344..f0a59b7f 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -47,7 +47,7 @@ export default { }, methods: { ...mapActions(['getToken', 'getAccount', 'getCode']), - ...mapMutations(['login', 'logout']), + ...mapMutations(['login', 'logout', 'setModule']), handleLogin() { this.$refs.loginForm.validate(v => { if (v) { @@ -62,7 +62,7 @@ export default { this.getToken({...this.form, module, corpId}).then(token => { this.login(token) if (module != 'AppCountryAlbum') { - this.getAccount({module}) + this.getAccount({module}).then(() => this.setModule(module)) } this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) }).catch(() => 0) diff --git a/src/store/index.js b/src/store/index.js index 387440bd..2fced777 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -9,12 +9,16 @@ const store = new Vuex.Store({ state: { token: "", openUser: {}, - apps: [] + apps: [], + module: "" }, mutations: { setApps(state, apps) { state.apps = apps }, + setModule(state, mod) { + state.module = mod + }, login(state, token) { state.token = token },