From 8562f0ce55386b26c30a76c5d17eb30b396f2ef5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 01 六月 2023 11:35:48 +0800 Subject: [PATCH] 2023-06-01 --- src/api/index.js | 46 ++++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index a4dd5b9..0e13380 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -48,7 +48,7 @@ axios.interceptors.response.use((response) => { if (response.data.ErrCode === 'LoginError') { - if (window.debugger === true) { + if (window.debugger === true || window.GLOB.saving) { response.data.ErrCode = 'E' return Promise.resolve(response.data) } else if (!sessionStorage.getItem('loginError')) { @@ -98,17 +98,18 @@ /** * @description 寰俊涓氬姟璇锋眰 */ - wxAccessToken () { + wxAccessToken (domain = '') { let _url = window.GLOB.baseurl + 'wxpay/getaccesstoken' - if (process.env.NODE_ENV !== 'production') { - _url = document.location.origin + '/wxpay/getaccesstoken' + + if (domain) { + _url = domain + 'wxpay/getaccesstoken' } return new Promise(resolve => { - if (window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) { + if (window.GLOB.accessToken.domain === domain && window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) { resolve(window.GLOB.accessToken) } else { - window.GLOB.accessToken = {} + window.GLOB.accessToken = {domain} axios({ url: _url, method: 'get' @@ -128,19 +129,23 @@ * @description 寰俊涓氬姟璇锋眰 */ wxNginxRequest (url, method, param) { - let _url = window.GLOB.location + '/' + url - if (process.env.NODE_ENV === 'production') { - _url = document.location.origin + '/' + url - } - if (/^http:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { - _url = window.GLOB.location + ':8080/' + url + let _url = url + + if (!/^http/.test(url)) { + _url = window.GLOB.location + '/' + url if (process.env.NODE_ENV === 'production') { - _url = document.location.origin + ':8080/' + url + _url = document.location.origin + '/' + url } - } else if (/^https:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { - _url = window.GLOB.location + ':8443/' + url - if (process.env.NODE_ENV === 'production') { - _url = document.location.origin + ':8443/' + url + if (/^http:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { + _url = window.GLOB.location + ':8080/' + url + if (process.env.NODE_ENV === 'production') { + _url = document.location.origin + ':8080/' + url + } + } else if (/^https:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) { + _url = window.GLOB.location + ':8443/' + url + if (process.env.NODE_ENV === 'production') { + _url = document.location.origin + ':8443/' + url + } } } @@ -751,7 +756,7 @@ token = JSON.parse(window.decodeURIComponent(window.atob(token))) } catch (e) { token = null - _resolve({status: false, ErrCode: 'E', message: '鎺ュ彛淇℃伅瑙f瀽澶辫触锛�'}) + _resolve({status: false, ErrCode: 'E', message: '鎺ュ彛淇℃伅瑙f瀽澶辫触锛�', ErrMesg: 'token_error'}) } if (!token) return @@ -854,7 +859,7 @@ param.appkey = window.GLOB.appkey || '' if (param.$token === '') { - return Promise.resolve({status: false, ErrCode: 'E', message: '鎺ュ彛鍦板潃灏氭湭璁剧疆锛�'}) + return Promise.resolve({status: false, ErrCode: 'E', message: '鎺ュ彛鍦板潃灏氭湭璁剧疆锛�', ErrMesg: 'token_error'}) } else if (param.$token) { return new Promise(resolve => this.visitOuterSystem(param, resolve)) } @@ -1026,9 +1031,6 @@ */ getWxNativePay (param) { let _url = window.GLOB.baseurl + 'wxpay/wxNativePay' - if (process.env.NODE_ENV !== 'production') { - _url = document.location.origin + '/wxpay/wxNativePay' - } return axios({ url: _url, -- Gitblit v1.8.0