From 07c005cf28acf74e3afde82122e4c53e1000d70c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 12 六月 2023 12:06:18 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 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 282f9fd..814b0dd 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
+        }
       }
     }
     
@@ -790,7 +795,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
@@ -893,7 +898,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))
     }
@@ -1065,9 +1070,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