Commit 61508a4d authored by 刘帅阳's avatar 刘帅阳

token问题

parent f501b97d
......@@ -21,6 +21,13 @@ export function login(username, password, code, uuid, type) {
headers: {}
})
}
export function handleLogout() {
return request({
url: '/auth/logout',
method: 'get'
})
}
// 手机登录方法
export function phoneLogin(phone, smsCode) {
const data = {
......
......@@ -6,7 +6,7 @@ import { getToken, setToken } from '@/utils/auth'
import SM4 from './gmUtil'
import errorCode from '@/utils/errorCode'
import { refreshToken } from '@/api/login.js'
import router from '../router'
axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'
// 创建axios实例
const service = axios.create({
......@@ -95,9 +95,18 @@ service.interceptors.response.use(
}
if (code === 401) {
Message({
message: '用户不存在或密码错误',
message: '当前登录无权限,请重新登录',
type: 'error'
})
console.log('401401')
store.dispatch('FedLogOut').then(() => {
router.push({
path: '/login/index'
})
setTimeout(() => {
location.reload()
}, 500)
})
} else if (code === 500 || code === 400) {
const errMsg = res.data.data || res.data.message || res.data.msg
Message({
......
......@@ -144,6 +144,7 @@
<script>
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
import {handleLogout} from "@/api/login";
export default {
name: 'NavList',
......@@ -221,13 +222,21 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$store.dispatch('FedLogOut').then(() => {
this.$router.push({
path: '/homePage/index'
})
setTimeout(() => {
location.reload()
}, 500)
handleLogout().then(res => {
if (res.code === 200) {
this.$message({
message: '退出成功',
type: 'success'
})
this.$store.dispatch('FedLogOut').then(() => {
this.$router.push({
path: '/homePage/index'
})
setTimeout(() => {
location.reload()
}, 500)
})
}
})
})
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment