From be22457344d6d3fc079de2a4f0a1e06e4c0f85c3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 06 七月 2022 22:55:14 +0800 Subject: [PATCH] 2022-07-06 --- src/api/index.js | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index a542dfc..66895b6 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -66,16 +66,22 @@ return Promise.resolve(response.data) } }, (error) => { - if (error && error.response) { - notification.error({ - className: 'notification-custom-error', - bottom: 0, - message: '鐘舵�佺爜-' + error.response.status + '锛岃鑱旂郴绠$悊鍛�', - placement: 'bottomRight', - duration: 15 - }) + let response = error.response + + if (response) { + if (!response.data || !response.data.errors) { // 杩囨护鏃疯鎶ラ敊淇℃伅 + notification.error({ + className: 'notification-custom-error', + bottom: 0, + message: '鐘舵�佺爜-' + response.status + '锛岃鑱旂郴绠$悊鍛�', + placement: 'bottomRight', + duration: 15 + }) + } + return Promise.reject(response) + } else { + return Promise.reject() } - return Promise.reject(error.response) }) class Api { @@ -102,6 +108,29 @@ } /** + * @description 寰俊涓氬姟璇锋眰 + */ + wxRequest (url, method, param) { + let _url = window.GLOB.location + ':8080/' + window.GLOB.service + url + if (process.env.NODE_ENV === 'production') { + _url = document.location.origin + ':8080/' + window.GLOB.service + url + } + + if (param) { + return axios({ + url: _url, + method, + data: param + }) + } else { + return axios({ + url: _url, + method + }) + } + } + + /** * @description 鐩存帴璇锋眰 * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁� */ -- Gitblit v1.8.0