From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 02 八月 2022 11:42:43 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/api/index.js |   75 +++++++++++++++++++++++++++++++++++--
 1 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index bdaed71..74c1c5b 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)
@@ -108,6 +108,69 @@
   }
 
   /**
+   * @description 寰俊涓氬姟璇锋眰
+   */
+  wxAccessToken () {
+    let _url = document.location.origin + '/' + window.GLOB.service + 'wxpay/getaccesstoken'
+    if (process.env.NODE_ENV !== 'production') {
+      _url = document.location.origin + '/wxpay/getaccesstoken'
+    }
+
+    return new Promise(resolve => {
+      if (window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) {
+        resolve(window.GLOB.accessToken)
+      } else {
+        window.GLOB.accessToken = {}
+        axios({
+          url: _url,
+          method: 'get'
+        }).then(res => {
+          if (res.oa_access_token || res.mini_access_token) {
+            window.GLOB.accessToken.accessTime = parseInt(new Date().getTime() / 1000)
+            window.GLOB.accessToken.oa_access_token = res.oa_access_token
+            window.GLOB.accessToken.mini_access_token = res.mini_access_token
+          }
+          resolve(res)
+        })
+      }
+    })
+  }
+
+  /**
+   * @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
+      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
+      }
+    }
+    
+    if (param) {
+      return axios({
+        url: _url,
+        method,
+        data: param
+      })
+    }
+
+    return axios({
+      url: _url,
+      method
+    })
+  }
+
+  /**
    * @description 鐩存帴璇锋眰
    * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁�
    */
@@ -178,7 +241,6 @@
 
     let url = '/webapi/dologon/s_visitor_login'
     if (window.GLOB.mainSystemApi) {
-      // url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon/s_visitor_login')
       param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon/s_visitor_login')
     }
 
@@ -213,14 +275,12 @@
     if (isCloud) {
       param.debug = 'Y'
       if (options.cloudServiceApi) {
-        // url = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon')
         param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon')
       }
     } else if (window.GLOB.mainSystemApi) {
       if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
         param.linkurl = window.GLOB.linkurl
       }
-      // url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
       param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
     }
 
@@ -872,8 +932,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