支持组件自适应项目
This commit is contained in:
@@ -3,18 +3,18 @@ import instance from './http'
|
|||||||
|
|
||||||
instance.interceptors.request.use(config => {
|
instance.interceptors.request.use(config => {
|
||||||
store.commit('initWaterMarker')
|
store.commit('initWaterMarker')
|
||||||
|
let {module} = store.state
|
||||||
if (/\/node\//.test(config.url)) {
|
if (/\/node\//.test(config.url)) {
|
||||||
config.baseURL = '/ns'
|
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.baseURL = '/aca'
|
||||||
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
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'
|
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.baseURL = '/hnjc'
|
||||||
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
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'
|
config.baseURL = '/online'
|
||||||
} else config.baseURL = "/lan"
|
} else config.baseURL = "/lan"
|
||||||
return config
|
return config
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['getToken', 'getAccount', 'getCode']),
|
...mapActions(['getToken', 'getAccount', 'getCode']),
|
||||||
...mapMutations(['login', 'logout']),
|
...mapMutations(['login', 'logout', 'setModule']),
|
||||||
handleLogin() {
|
handleLogin() {
|
||||||
this.$refs.loginForm.validate(v => {
|
this.$refs.loginForm.validate(v => {
|
||||||
if (v) {
|
if (v) {
|
||||||
@@ -62,7 +62,7 @@ export default {
|
|||||||
this.getToken({...this.form, module, corpId}).then(token => {
|
this.getToken({...this.form, module, corpId}).then(token => {
|
||||||
this.login(token)
|
this.login(token)
|
||||||
if (module != 'AppCountryAlbum') {
|
if (module != 'AppCountryAlbum') {
|
||||||
this.getAccount({module})
|
this.getAccount({module}).then(() => this.setModule(module))
|
||||||
}
|
}
|
||||||
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
|
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
|
||||||
}).catch(() => 0)
|
}).catch(() => 0)
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ const store = new Vuex.Store({
|
|||||||
state: {
|
state: {
|
||||||
token: "",
|
token: "",
|
||||||
openUser: {},
|
openUser: {},
|
||||||
apps: []
|
apps: [],
|
||||||
|
module: ""
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setApps(state, apps) {
|
setApps(state, apps) {
|
||||||
state.apps = apps
|
state.apps = apps
|
||||||
},
|
},
|
||||||
|
setModule(state, mod) {
|
||||||
|
state.module = mod
|
||||||
|
},
|
||||||
login(state, token) {
|
login(state, token) {
|
||||||
state.token = token
|
state.token = token
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user