| | |
| | | } else if (error.response.status == 401) { |
| | | if (!MessageBox_401_show) { |
| | | MessageBox_401_show = true |
| | | ElMessageBox.confirm('当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。', '无权限访问', { |
| | | ElMessageBox.confirm(`${error?.response?.data?.msg || '当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。'}`, '无权限访问', { |
| | | type: 'error', |
| | | closeOnClickModal: false, |
| | | center: true, |
| | |
| | | // }); |
| | | } |
| | | } else { |
| | | ElNotification.error({ |
| | | title: '请求错误', |
| | | message: "请求服务器无响应!" |
| | | }); |
| | | // ElNotification.error({ |
| | | // title: '请求错误', |
| | | // message: "请求服务器无响应!" |
| | | // }); |
| | | } |
| | | |
| | | return Promise.reject(error.response); |
| | |
| | | }).then((response) => { |
| | | resolve(response.data); |
| | | }).catch((error) => { |
| | | if (error?.status == 400) { |
| | | ElMessage({ |
| | | message: error.data.msg, |
| | | type: 'warning', |
| | | }) |
| | | } else { |
| | | reject(error); |
| | | } |
| | | }) |
| | | }) |
| | | }, |
| | | /** post 请求 query string parameters |
| | | * @param {string} url 接口地址 |
| | | * @param {object} data 请求参数 |
| | | * @param {object} config 参数 |
| | | */ |
| | | getJ: function (url, params = {}, config = {}) { |
| | | return new Promise((resolve, reject) => { |
| | | axios({ |
| | | method: 'post', |
| | | url: url, |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, |
| | | params: params, |
| | | ...config |
| | | }).then((response) => { |
| | | resolve(response.data); |
| | | }).catch((error) => { |
| | | resolve(error.data); |
| | | reject(error); |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | /** post 请求 request payload |
| | | * @param {string} url 接口地址 |
| | | * @param {object} data 请求参数 |
| | |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | /** put 请求 |
| | | * @param {string} url 接口地址 |
| | | * @param {object} data 请求参数 |