vuex模块化
This commit is contained in:
@@ -3,7 +3,7 @@ import instance from './http'
|
|||||||
|
|
||||||
instance.interceptors.request.use(config => {
|
instance.interceptors.request.use(config => {
|
||||||
store.commit('initWaterMarker')
|
store.commit('initWaterMarker')
|
||||||
config.baseURL = "/lan"
|
|
||||||
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') {
|
||||||
@@ -16,7 +16,8 @@ instance.interceptors.request.use(config => {
|
|||||||
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") {
|
||||||
config.baseURL = '/online'
|
config.baseURL = '/online'
|
||||||
}
|
} else config.baseURL = "/lan"
|
||||||
|
console.log(config)
|
||||||
return config
|
return config
|
||||||
}, err => {
|
}, err => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import http from "./http";
|
import http from "./http";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录信息
|
||||||
|
*/
|
||||||
export const user = {
|
export const user = {
|
||||||
state: () => ({}),
|
state: () => ({}),
|
||||||
mutations: {
|
mutations: {
|
||||||
@@ -16,13 +19,13 @@ export const user = {
|
|||||||
return http.post("/admin/user/detail-phone", null, config).then(res => {
|
return http.post("/admin/user/detail-phone", null, config).then(res => {
|
||||||
if (res?.code == 0) {
|
if (res?.code == 0) {
|
||||||
commit('setUser', res.data)
|
commit('setUser', res.data)
|
||||||
return Promise.all([dispatch('getGridInfo')])
|
return Promise.all([dispatch('getGridInfo', config)])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getGridInfo({commit}) {
|
getGridInfo({commit}, config) {
|
||||||
//获取登录着网格员信息
|
//获取登录着网格员信息
|
||||||
return http.post("/app/appgirdmemberinfo/checkLogOnUser").then(res => {
|
return http.post("/app/appgirdmemberinfo/checkLogOnUser", null, config).then(res => {
|
||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
let {girdId, girdMemberId, girdName, checkType: girdCheckType, appGirdInfo: gridInfo} = res.data
|
let {girdId, girdMemberId, girdName, checkType: girdCheckType, appGirdInfo: gridInfo} = res.data
|
||||||
return commit("setUser", {girdId, girdMemberId, girdName, girdCheckType, gridInfo})
|
return commit("setUser", {girdId, girdMemberId, girdName, girdCheckType, gridInfo})
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleLogout() {
|
handleLogout() {
|
||||||
this.logout()
|
this.$http.delete("/auth/token/logout").finally(() => this.logout())
|
||||||
this.$http.delete("/auth/token/logout")
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
|||||||
@@ -46,19 +46,6 @@ const store = new Vuex.Store({
|
|||||||
} else alert(res)
|
} else alert(res)
|
||||||
}).catch(err => alert(err))
|
}).catch(err => alert(err))
|
||||||
},
|
},
|
||||||
setDicts(state, payload) {
|
|
||||||
if (payload) {
|
|
||||||
payload.map(p => {
|
|
||||||
if (state.dicts.some(d => d.key == p.key)) {
|
|
||||||
const index = state.dicts.findIndex(d => d.key == p.key)
|
|
||||||
state.dicts.splice(index, 1)
|
|
||||||
state.dicts.push(p)
|
|
||||||
} else {
|
|
||||||
state.dicts.push(p)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
redirectCode(state, url = location.href) {
|
redirectCode(state, url = location.href) {
|
||||||
let REDIRECT_URI = encodeURIComponent(url),
|
let REDIRECT_URI = encodeURIComponent(url),
|
||||||
corpid = state.config.corpid
|
corpid = state.config.corpid
|
||||||
@@ -286,14 +273,6 @@ const store = new Vuex.Store({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getters: {
|
|
||||||
getDict: state => key => {
|
|
||||||
if (key && state.dicts.length > 0) {
|
|
||||||
return state.dicts.find(e => e.key == key)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modules: {user, waterMarker},
|
modules: {user, waterMarker},
|
||||||
plugins: [perState({
|
plugins: [perState({
|
||||||
storage: {
|
storage: {
|
||||||
|
|||||||
Reference in New Issue
Block a user