From e8b8c6418c393341da52f66ed47d735fa8f41ea3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 23 七月 2024 15:53:33 +0800 Subject: [PATCH] 2024-07-23 --- src/api/index.js | 64 +++++++++++++++++++------------ 1 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index d700941..0dca831 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -100,18 +100,18 @@ /** * @description 寰俊涓氬姟璇锋眰 鍘熸帴鍙� 'wxpay/getaccesstoken' */ - wxAccessToken (domain = '') { + wxAccessToken (appId, domain = '') { let _url = domain || window.GLOB.baseurl return new Promise(resolve => { - if (window.GLOB.accessToken.domain === domain && window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) { + if (window.GLOB.accessToken.appId === appId && window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) { resolve(window.GLOB.accessToken) } else { - window.GLOB.accessToken = {domain} + window.GLOB.accessToken = {appId} axios({ url: _url + 'wechat/getaccesstoken', method: 'post', - data: JSON.stringify({app_id: domain === '' ? window.GLOB.WXAppID : 'wx4d8a34c8d4494872'}) + data: JSON.stringify({app_id: appId}) }).then(res => { if (res.access_token) { window.GLOB.accessToken.accessTime = parseInt(new Date().getTime() / 1000) @@ -135,12 +135,12 @@ if (process.env.NODE_ENV === 'production') { _url = document.location.origin + '/' + url } - if (/qingqiumarket.cn|cloud.mk9h.cn/.test(_url)) { - _url = _url.replace('http://qingqiumarket.cn/', 'http://qingqiumarket.cn:8080/') - _url = _url.replace('http://cloud.mk9h.cn/', 'http://cloud.mk9h.cn:8080/') - _url = _url.replace('https://qingqiumarket.cn/', 'https://qingqiumarket.cn:8443/') - _url = _url.replace('https://cloud.mk9h.cn/', 'https://cloud.mk9h.cn:8443/') - } + } + if (/qingqiumarket.cn|cloud.mk9h.cn/.test(_url)) { + _url = _url.replace('http://qingqiumarket.cn/', 'http://qingqiumarket.cn:8080/') + _url = _url.replace('http://cloud.mk9h.cn/', 'http://cloud.mk9h.cn:8080/') + _url = _url.replace('https://qingqiumarket.cn/', 'https://qingqiumarket.cn:8443/') + _url = _url.replace('https://cloud.mk9h.cn/', 'https://cloud.mk9h.cn:8443/') } if (param) { @@ -160,7 +160,27 @@ /** * @description 鐩存帴璇锋眰 */ - directRequest (params) { + directRequest (params, script, position) { + if (script) { + try { + // eslint-disable-next-line + let func = new Function('axios', 'Api', 'param', 'position', 'systemType', 'notification', script) + let promise = func(axios, this, params, position, window.GLOB.systemType, notification) + + if (promise instanceof Promise) { + return promise + } + } catch (e) { + console.warn(e) + } + + return Promise.resolve({ + status: false, + message: '鑷畾涔夎剼鏈墽琛岄敊璇�', + ErrCode: 'E' + }) + } + return axios(params) } @@ -933,7 +953,7 @@ }) } else { let url = '/webapi/dostars' - if (param.rduri && !window.GLOB.transfer && /\/dostars/.test(param.rduri) && param.func !== 'webapi_ChangeUser') { + if (param.rduri && (!window.GLOB.transfer || /https:\/\/sso.mk9h.cn/.test(param.rduri)) && /\/dostars/.test(param.rduri) && param.func !== 'webapi_ChangeUser') { url = param.rduri delete param.rduri } @@ -1037,30 +1057,24 @@ } /** - * @description 鑾峰彇寰俊鏀粯浜岀淮鐮� + * @description 鑾峰彇寰俊鏀粯浜岀淮鐮� 鍘熸帴鍙xpay/wxNativePay */ getWxNativePay (param) { - let _url = window.GLOB.baseurl + 'wxpay/wxNativePay' - return axios({ - url: _url, + url: window.GLOB.baseurl + 'wechat/native', method: 'post', - data: qs.stringify(param) + data: JSON.stringify(param) }) } /** - * @description 寰俊鏀粯閫�娆� + * @description 寰俊鏀粯閫�娆� 鍘熸帴鍙xpay/wxRefund */ - setRefund (orderId) { - let _param = new FormData() - _param.append('out_biz_no', orderId) - + setRefund (param) { return axios({ - url: '/wxpay/wxRefund', - headers: { 'Content-Type': 'multipart/form-data' }, + url: window.GLOB.baseurl + 'wechat/wxRefund', method: 'post', - data: _param + data: JSON.stringify(param) }) } -- Gitblit v1.8.0