退出功能
This commit is contained in:
@@ -23,7 +23,7 @@ instance.interceptors.response.use(
|
||||
(response) => {
|
||||
if (response.data.code === 401 || response.data.code === 403) {
|
||||
Message.error('登录失效,请重新登录')
|
||||
store.commit('SignOut', true)
|
||||
store.dispatch('SignOut', true)
|
||||
|
||||
return response.data
|
||||
} else if (response.data.code === 1 && response.data.msg) {
|
||||
|
||||
@@ -13,9 +13,7 @@ export default new Vuex.Store({
|
||||
mallName: '',
|
||||
mallList: [],
|
||||
activeDlgShow: false,
|
||||
userInfo: {},
|
||||
routes: [],
|
||||
addRoutes: []
|
||||
userInfo: {}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@@ -31,13 +29,16 @@ export default new Vuex.Store({
|
||||
setMallList (state, mallList) {
|
||||
state.mallList = mallList
|
||||
},
|
||||
SignOut (state) {
|
||||
logout (state) {
|
||||
state.token = ''
|
||||
state.userInfo = {}
|
||||
state.userInfo = {}
|
||||
state.mallList = []
|
||||
state.mallName = ''
|
||||
state.mallId = ''
|
||||
|
||||
setTimeout(() => {
|
||||
router.push('/login')
|
||||
}, 600)
|
||||
}, 200)
|
||||
},
|
||||
|
||||
setUserInfo (state, userInfo) {
|
||||
@@ -58,7 +59,20 @@ export default new Vuex.Store({
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
SignOut (store, isClear) {
|
||||
if (isClear) {
|
||||
store.commit('logout')
|
||||
return false
|
||||
}
|
||||
|
||||
request.post('/api/token/logout').then(res => {
|
||||
if (res.code === 0) {
|
||||
store.commit('logout')
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getters: {
|
||||
|
||||
@@ -148,14 +148,12 @@
|
||||
|
||||
methods: {
|
||||
handleClick (e) {
|
||||
if (e === 'phone') {
|
||||
this.$router.push('changePhone')
|
||||
if (e === 'logout') {
|
||||
this.$store.dispatch('SignOut', false)
|
||||
} else if (e === 'pwd') {
|
||||
this.$router.push('changePwd')
|
||||
} else if (e === 'message') {
|
||||
this.$router.push('message')
|
||||
} else {
|
||||
this.$store.commit('SignOut', true)
|
||||
}
|
||||
},
|
||||
handleClose() {
|
||||
|
||||
Reference in New Issue
Block a user