This commit is contained in:
duanxiaohai 2024-07-17 16:46:45 +08:00
commit dc41019941
5 changed files with 120 additions and 112 deletions

View File

@ -1,132 +1,134 @@
import axios from 'axios';
import { ElMessage } from 'element-plus'
import tools from '@/utils/tools'
import router from '../router';
import axios from "axios";
import { ElMessage } from "element-plus";
import tools from "@/utils/tools";
import router from "../router";
// axios.defaults.baseURL = '/api'
axios.defaults.timeout = 120000
axios.defaults.timeout = 120000;
// HTTP request 拦截器
axios.interceptors.request.use(
(config) => {
let token = tools.data.get('token');
if (token) {
config.headers['x-token'] = token
}
return config;
},
(error) => {
return Promise.reject(error);
(config) => {
let token = tools.data.get("token");
if (token) {
config.headers["x-token"] = token;
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
// HTTP response 拦截器
axios.interceptors.response.use(
(response) => {
return response;
},
(error) => {
if (error.response) {
if (error.response.status == 401) {
ElMessage.error("请重新登录!");
// window.location.href = '/#/login?returnURL=' + window.location.href
window.location.href =
'http://220.191.238.50:996/api/login?returnURL=' +
window.location.href
} else if (error.response.status == 404) {
ElMessage.error("Status:404正在请求不存在的服务器记录");
} else if (error.response.status == 500) {
ElMessage.error({
title: '请求错误',
message: "Status:500服务器发生错误"
});
} else {
ElMessage.error(`Status:${error.response.status},未知错误!`);
}
} else {
ElMessage.error("请求服务器无响应!");
}
return Promise.reject(error.response);
(response) => {
return response;
},
(error) => {
if (error.response) {
if (error.response.status == 401) {
ElMessage.error("请重新登录!");
// window.location.href = '/#/login?returnURL=' + window.location.href
window.location.href =
"http://220.191.238.50:996/api/login?returnURL=" +
window.location.href;
} else if (error.response.status == 404) {
ElMessage.error("Status:404正在请求不存在的服务器记录");
} else if (error.response.status == 500) {
ElMessage.error({
title: "请求错误",
message: "Status:500服务器发生错误",
});
} else {
ElMessage.error(`Status:${error.response.status},未知错误!`);
}
} else {
ElMessage.error("请求服务器无响应!");
}
return Promise.reject(error.response);
}
);
var http = {
/** get
* @param {接口地址} url
* @param {请求参数} params
*/
get: function (url, params) {
return new Promise((resolve, reject) => {
axios.get(url, {
params: params
})
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
.catch((error) => {
reject(error);
});
/** get
* @param {接口地址} url
* @param {请求参数} params
*/
get: function (url, params) {
return new Promise((resolve, reject) => {
axios
.get(url, {
params: params,
})
},
/** post
* @param {接口地址} url
* @param {请求参数} params
*/
post: function (url, params) {
return new Promise((resolve, reject) => {
axios.post(url, params)
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
.catch((error) => {
reject(error);
});
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
},
.catch((error) => {
reject(error);
});
});
},
put: function (url, params) {
return new Promise((resolve, reject) => {
axios.put(url, params)
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
.catch((error) => {
reject(error);
});
/** post
* @param {接口地址} url
* @param {请求参数} params
*/
post: function (url, params) {
return new Promise((resolve, reject) => {
axios
.post(url, params)
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
},
.catch((error) => {
reject(error);
});
});
},
delete: function (url, params) {
return new Promise((resolve, reject) => {
axios.delete(url, params)
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
.catch((error) => {
reject(error);
});
put: function (url, params) {
return new Promise((resolve, reject) => {
axios
.put(url, params)
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
},
download: function (url) {
let user = tools.data.get('user');
let token = "x-token=" + user.token;
url = url + (url.indexOf("?") > 0 ? "&" : "?") + token;
window.open(url);
}
}
.catch((error) => {
reject(error);
});
});
},
delete: function (url, params) {
return new Promise((resolve, reject) => {
axios
.delete(url, params)
.then((response) => {
if (response.data.code == 400 && response.data.msg) {
ElMessage.error(response.data.msg);
}
resolve(response.data);
})
.catch((error) => {
reject(error);
});
});
},
download: function (url) {
let user = tools.data.get("user");
let token = "x-token=" + user.token;
url = url + (url.indexOf("?") > 0 ? "&" : "?") + token;
window.open(url);
},
};
export default http;

View File

@ -864,6 +864,7 @@ onBeforeUnmount(() => {
}
.left_1 {
cursor: pointer;
background-image: url(@/assets/images/sjfx/lnsjfx.png);
background-repeat: no-repeat;
background-size: 100% 100%;

View File

@ -561,7 +561,7 @@ const selectChange2 = () => {
setTimeout(() => {
showR.value = true;
}, 300);
}, 100);
};
// const ratingBtn = (item) => {
@ -1568,6 +1568,7 @@ onMounted(() => {
.schoolbs {
// width: 128px;
cursor: pointer;
height: 41px;
padding: 0px 20px 0 30px;
background-image: url(@/assets/eduImg/jyImg1.png);

View File

@ -413,6 +413,7 @@
class="ylws_item"
v-for="(item, index) in data.ylwsList"
:key="index"
:style="{'cursor': item.name=='医院卫生院' ? 'pointer' : ''}"
@click="showDialog2(item.name, '/api/ggfwyth/yywsyList')"
>
<div class="name">{{ item.name }}</div>
@ -2507,6 +2508,7 @@ onBeforeMount(async () => {
justify-content: space-around;
&_item {
cursor: pointer;
box-sizing: border-box;
width: 160px;
height: 112px;
@ -3184,6 +3186,7 @@ table {
margin-bottom: 15px;
padding-top: 20px;
.jtsyBoxtop1 {
cursor: pointer;
position: relative;
display: flex;
overflow: hidden;

View File

@ -1087,6 +1087,7 @@ const getData = () => {
align-items: center;
.history1 {
cursor: pointer;
font-size: 26px;
color: #ffffff;
line-height: 30px;