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