Commit f9adf94c authored by 13841799530's avatar 13841799530

token接口联调

解润东
20211021
parent 79930953
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
* 版权所有,侵权必究! * 版权所有,侵权必究!
*/ */
import axios from 'axios' import axios from 'axios'
import { Toast } from 'vant'
import router from '../router' import router from '../router'
import { Notify } from 'vant';
import { getToken } from '@/utils/auth' // get token from cookie import { getToken } from '@/utils/auth' // get token from cookie
const service = axios.create({ const service = axios.create({
baseURL: '/hse/app-api', //前缀路径 baseURL: '/hse/app-api', //前缀路径
...@@ -21,7 +22,7 @@ const service = axios.create({ ...@@ -21,7 +22,7 @@ const service = axios.create({
//拦截接口请求 //拦截接口请求
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
if (getToken()) { if (getToken()) {
config.headers['X-Token'] = getToken() config.headers['token'] = getToken()
} }
return config return config
},error => { },error => {
...@@ -34,27 +35,15 @@ service.interceptors.response.use(response => { ...@@ -34,27 +35,15 @@ service.interceptors.response.use(response => {
if(code == 200) {//请求响应码200 代表已经请求到接口 if(code == 200) {//请求响应码200 代表已经请求到接口
if(res.code === 0) {//接口响应码0 代表接口代码运行正常 if(res.code === 0) {//接口响应码0 代表接口代码运行正常
return res return res
}else{ }else if(res.code === 301){
this.$notify({ Notify({ type: 'danger', message: res.msg});
message:'失败',
background:'red',
duration: 1000
})
} }
}else{ }else{
this.$notify({ Notify({ type: 'danger', message: '失败' });
message:'失败',
background:'red',
duration: 1000
})
Promise.reject(new Error('Error')) Promise.reject(new Error('Error'))
} }
},err=>{ },err=>{
this.$notify({ Notify({ type: 'danger', message: '失败' });
message:'失败',
background:'red',
duration: 1000
})
return Promise.reject(err) return Promise.reject(err)
}) })
......
...@@ -65,8 +65,7 @@ export default { ...@@ -65,8 +65,7 @@ export default {
}, },
methods: { methods: {
onSubmit(values) { onSubmit(values) {
if(values.username=='admin'&&values.password=='123456'){ getFun('check/token',values).then((Response)=>{
getFun('check/token',{a:122}).then((Response)=>{
if(Response.code==0){ if(Response.code==0){
this.$notify({ this.$notify({
message:'登录成功', message:'登录成功',
...@@ -77,17 +76,6 @@ export default { ...@@ -77,17 +76,6 @@ export default {
this.$router.push('/message-center') this.$router.push('/message-center')
} }
}) })
// localStorage.setItem('admin_token','2dsfewr')
// this.$router.push('/MessageCenter')
// location.reload();
}else{
this.$notify({
message:'账号或密码不正确',
background:'red',
duration: 1000
})
}
} }
} }
}; };
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<script> <script>
import LHeader from '@/components/header.vue' import LHeader from '@/components/header.vue'
import { getFun,postFun } from '@/service/table'
export default { export default {
name: 'checked', name: 'checked',
components: { components: {
...@@ -50,9 +51,15 @@ export default { ...@@ -50,9 +51,15 @@ export default {
} }
}, },
mounted() { mounted() {
this.list()
}, },
methods: { methods: {
list(){
getFun('check/carry/user/list').then((Response)=>{
console.log(Response)
})
},
onSearch(){ onSearch(){
this.$toast('提示内容') this.$toast('提示内容')
}, },
......
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