From 4313d9ccea6534b1da71baa1bf499f045d3c1f0b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 08 七月 2022 00:57:55 +0800 Subject: [PATCH] 2022-07-08 --- src/api/index.js | 46 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 66895b6..10a19bd 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -29,7 +29,7 @@ axios.interceptors.request.use((config) => { if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) { config.data = qs.stringify(config.data) - } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) { + } else if (config.url.includes('doupload') || config.url.includes('dopreload')) { config.headers = { 'Content-Type': 'multipart/form-data' } } else if (config.method === 'post' && config.data) { config.data = JSON.stringify(config.data) @@ -111,9 +111,32 @@ * @description 寰俊涓氬姟璇锋眰 */ wxRequest (url, method, param) { - let _url = window.GLOB.location + ':8080/' + window.GLOB.service + url + let _url = document.location.origin + '/' + window.GLOB.service + url + if (process.env.NODE_ENV !== 'production') { + _url = document.location.origin + '/' + url + } + + if (param) { + return axios({ + url: _url, + method, + data: param + }) + } + + return axios({ + url: _url, + method + }) + } + + /** + * @description 寰俊涓氬姟璇锋眰 + */ + wxNginxRequest (url, method, param) { + let _url = window.GLOB.location + ':8080/' + url if (process.env.NODE_ENV === 'production') { - _url = document.location.origin + ':8080/' + window.GLOB.service + url + _url = document.location.origin + ':8080/' + url } if (param) { @@ -122,12 +145,12 @@ method, data: param }) - } else { - return axios({ - url: _url, - method - }) } + + return axios({ + url: _url, + method + }) } /** @@ -895,8 +918,13 @@ * @description 鑾峰彇寰俊鏀粯浜岀淮鐮� */ getWxNativePay (param) { + let _url = document.location.origin + '/' + window.GLOB.service + 'wxpay/wxNativePay' + if (process.env.NODE_ENV !== 'production') { + _url = document.location.origin + '/wxpay/wxNativePay' + } + return axios({ - url: '/wxpay/wxNativePay', + url: _url, method: 'post', data: param }) -- Gitblit v1.8.0