|
|
@ -1,26 +1,22 @@ |
|
|
//vxvdvdsvsdvvds3
|
|
|
//vxvdvdsvsdvvds3
|
|
|
import router from "@/router" |
|
|
import router from "@/router" |
|
|
import axios from "axios" |
|
|
import axios from "axios" |
|
|
|
|
|
// import Promise from 'promise'
|
|
|
|
|
|
import {yztoken} from "@/utlis/istoken" |
|
|
|
|
|
import mm from "@/utlis/mm"; |
|
|
|
|
|
|
|
|
import { Message } from 'element-ui'; |
|
|
import { Message } from 'element-ui'; |
|
|
const instance = axios.create({ |
|
|
const instance = axios.create({ |
|
|
// baseURL: "/api",
|
|
|
|
|
|
// baseURL: "http://192.168.1.108:9529",
|
|
|
|
|
|
// baseURL: "http://81.70.217.145:8081/",
|
|
|
|
|
|
baseURL: "http://81.70.217.145:9529", |
|
|
|
|
|
// timeout: 5000
|
|
|
|
|
|
// timeout:5000
|
|
|
|
|
|
}) |
|
|
|
|
|
//请求拦截 222244
|
|
|
|
|
|
// instance.interceptors.request.use((config)=>{
|
|
|
|
|
|
// let token = localStorage.getItem('token')
|
|
|
|
|
|
// let tokentype = localStorage.getItem('tokentype')
|
|
|
|
|
|
|
|
|
baseURL: mm.apiurl, |
|
|
|
|
|
timeout:5000 |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
//请求拦截
|
|
|
//请求拦截
|
|
|
instance.interceptors.request.use( |
|
|
instance.interceptors.request.use( |
|
|
|
|
|
|
|
|
function (config) { |
|
|
function (config) { |
|
|
// console.log(config, 'config====>>>');
|
|
|
|
|
|
|
|
|
yztoken() |
|
|
let token = localStorage.getItem('token') |
|
|
let token = localStorage.getItem('token') |
|
|
let tokentype = localStorage.getItem('tokentype') |
|
|
let tokentype = localStorage.getItem('tokentype') |
|
|
config.headers['Access-Control-Allow-Origin'] = '*' |
|
|
config.headers['Access-Control-Allow-Origin'] = '*' |
|
|
@ -29,16 +25,17 @@ instance.interceptors.request.use( |
|
|
return config |
|
|
return config |
|
|
}, |
|
|
}, |
|
|
function (err) { |
|
|
function (err) { |
|
|
|
|
|
console.log('666') |
|
|
return Promise.reject(err) |
|
|
return Promise.reject(err) |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
// let urls='http://81.70.217.145:9529'
|
|
|
// let urls='http://81.70.217.145:9529'
|
|
|
// const urls='http://81.70.217.145:9529'
|
|
|
// const urls='http://81.70.217.145:9529'
|
|
|
//axios中get的封装
|
|
|
//axios中get的封装
|
|
|
const toatalpath = 'http://81.70.217.145:9529' |
|
|
|
|
|
|
|
|
// const toatalpath = 'http://81.70.217.145:9529'
|
|
|
export function getapi(url, params = {}, config) { |
|
|
export function getapi(url, params = {}, config) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
axios.get(`${toatalpath}${url}`, { |
|
|
|
|
|
|
|
|
instance.get(`${mm.apiurl}${url}`, { |
|
|
params: params, |
|
|
params: params, |
|
|
...config |
|
|
...config |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
@ -52,7 +49,7 @@ export function getapi(url, params = {}, config) { |
|
|
//axios封装post
|
|
|
//axios封装post
|
|
|
export function postapi(url, paramsdata = {}, config) { |
|
|
export function postapi(url, paramsdata = {}, config) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
axios.post(`${toatalpath}${url}`, paramsdata, config).then(res => { |
|
|
|
|
|
|
|
|
instance.post(`${mm.apiurl}${url}`, paramsdata, config).then(res => { |
|
|
resolve(res.data) |
|
|
resolve(res.data) |
|
|
}, err => { |
|
|
}, err => { |
|
|
reject(err.data) |
|
|
reject(err.data) |
|
|
@ -62,7 +59,7 @@ export function postapi(url, paramsdata = {}, config) { |
|
|
//axios封装deleteapi
|
|
|
//axios封装deleteapi
|
|
|
export function deletapi(url, params = {}, config) { |
|
|
export function deletapi(url, params = {}, config) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
axios.delete(`${toatalpath}${url}`, { |
|
|
|
|
|
|
|
|
instance.delete(`${mm.apiurl}${url}`, { |
|
|
params: params, |
|
|
params: params, |
|
|
...config |
|
|
...config |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
@ -75,7 +72,7 @@ export function deletapi(url, params = {}, config) { |
|
|
//axios封装Put方法
|
|
|
//axios封装Put方法
|
|
|
export function putapi(url, params = {}, config) { |
|
|
export function putapi(url, params = {}, config) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
axios.put(`${toatalpath}${url}`, params, config).then(res => { |
|
|
|
|
|
|
|
|
instance.put(`${mm.apiurl}${url}`, params, config).then(res => { |
|
|
resolve(res.data) |
|
|
resolve(res.data) |
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
reject(err.data) |
|
|
reject(err.data) |
|
|
@ -87,8 +84,8 @@ instance.interceptors.response.use( |
|
|
(res) => { |
|
|
(res) => { |
|
|
//console.log(res);
|
|
|
//console.log(res);
|
|
|
if (res.data.code == 1) { |
|
|
if (res.data.code == 1) { |
|
|
const { data } = res; |
|
|
|
|
|
return data |
|
|
|
|
|
|
|
|
// const { data } = res;
|
|
|
|
|
|
return res |
|
|
} else if (res.Code == -1) { |
|
|
} else if (res.Code == -1) { |
|
|
// console.log(res.data.message);
|
|
|
// console.log(res.data.message);
|
|
|
// this.$message({
|
|
|
// this.$message({
|
|
|
@ -97,17 +94,6 @@ instance.interceptors.response.use( |
|
|
// });
|
|
|
// });
|
|
|
Message.error(res.Message); |
|
|
Message.error(res.Message); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// const { data } = res;
|
|
|
|
|
|
// if (res.response.status === 401) {
|
|
|
|
|
|
// console.log('401')
|
|
|
|
|
|
// window.location.href = '#/login'
|
|
|
|
|
|
// this.$message.error('状态失效');
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else if (res.response.status == '401') {
|
|
|
|
|
|
// window.location.href='#/login'
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return data
|
|
|
|
|
|
}, |
|
|
}, |
|
|
(err) => { |
|
|
(err) => { |
|
|
console.log(err); |
|
|
console.log(err); |
|
|
@ -140,35 +126,5 @@ instance.interceptors.response.use( |
|
|
// return err
|
|
|
// return err
|
|
|
// }
|
|
|
// }
|
|
|
) |
|
|
) |
|
|
// 判断token失效
|
|
|
|
|
|
// instance.interceptors.response.use(
|
|
|
|
|
|
// (response) => {
|
|
|
|
|
|
// let res = response.data
|
|
|
|
|
|
// if (res.status == 0) {
|
|
|
|
|
|
// return res.data
|
|
|
|
|
|
// } else if (res.status == 10) {
|
|
|
|
|
|
// window.location.href = '/#/login'
|
|
|
|
|
|
// return Promise.reject(res)
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// // Message.warning(res.msg)
|
|
|
|
|
|
// // return Promise.reject(res)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// )
|
|
|
|
|
|
//封装调用方法
|
|
|
|
|
|
// export function aa(url, pames) {
|
|
|
|
|
|
// return instance.get(url, {
|
|
|
|
|
|
// params
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }
|
|
|
|
|
|
// export function post(url, data) {
|
|
|
|
|
|
// return instance.post(url, data)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// export function zzz() {
|
|
|
|
|
|
// return ({
|
|
|
|
|
|
// method: 'get',
|
|
|
|
|
|
// url: '/api/app/book',
|
|
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
// } 1a2b3cD!
|
|
|
|
|
|
export default instance |
|
|
export default instance |