From 3d048c6bbb3a5bd96fc231212f005b42e93233a7 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 18 三月 2021 09:19:30 +0800
Subject: [PATCH] 2021-03-18

---
 src/api/index.js |  154 ++++++++++++++++++++-------------------------------
 1 files changed, 61 insertions(+), 93 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index eaa86c6..68cdff5 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -24,7 +24,7 @@
 
 axios.defaults.crossDomain = true
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
-axios.defaults.withCredentials = true
+axios.defaults.withCredentials = false
 
 axios.interceptors.request.use((config) => {
   if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) {
@@ -83,7 +83,7 @@
     if (process.env.NODE_ENV === 'production') {
       axios.defaults.baseURL = document.location.origin + '/' + window.GLOB.service
     } else {
-      // axios.defaults.baseURL = 'http://127.0.0.1:8888'
+      axios.defaults.baseURL = window.GLOB.location + '/' + window.GLOB.service
     }
   }
   
@@ -105,7 +105,15 @@
    * @description 鐩存帴璇锋眰
    * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁�
    */
-  directRequest (url, method = 'post', param) {
+  directRequest (url, method = 'post', param, cross) {
+    if (cross === 'true') {
+      return axios({
+        url,
+        method,
+        data: param
+      })
+    }
+
     let params = { method: 'post' }
     let _url = url
 
@@ -120,27 +128,9 @@
     }
 
     _url = _url.replace(/&/ig, '%26')
-    // _url = window.btoa(_url)
     params.url = '/trans/redirect?rd=' + _url + '&method=' + method
 
     return axios(params)
-  }
-
-  /**
-   * @description 浣跨敤dostar鎺ュ彛锛岃烦杞嚦dostars
-   * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁�
-   */
-  dostarToDostars (param) {
-    param.userid = param.userid || sessionStorage.getItem('UserID') || ''
-    param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || ''
-
-    param = this.encryptParam(param)
-
-    return axios({
-      url: '/webapi/dostar',
-      method: 'post',
-      data: param
-    })
   }
 
   /**
@@ -166,12 +156,13 @@
 
     param.appkey = window.GLOB.appkey || ''
 
+    let url = '/webapi/dologon/s_visitor_login'
     if (window.GLOB.mainSystemApi) {
-      param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
+      url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon/s_visitor_login')
     }
 
     return axios({
-      url: '/webapi/dologon',
+      url: url,
       method: 'post',
       data: param
     })
@@ -193,20 +184,21 @@
 
     param.appkey = window.GLOB.appkey || ''
 
+    let url = '/webapi/dologon'
     if (isCloud) {
       param.debug = 'Y'
       if (options.cloudServiceApi) {
-        param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon')
+        url = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon')
       }
     } else if (window.GLOB.mainSystemApi) {
       if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
         param.linkurl = window.GLOB.linkurl
       }
-      param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
+      url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
     }
 
     return axios({
-      url: '/webapi/dologon',
+      url,
       method: 'post',
       data: param
     })
@@ -216,7 +208,6 @@
    * @description 鐧诲綍绯荤粺, 鑾峰彇鐢ㄦ埛淇℃伅
    */
   getusermsg (username, password, isCloud = false) {
-    
     let param = {
       // func: 'webapi_login',
       UserName: username,
@@ -234,21 +225,22 @@
     // Type: 'X' 鏃�
     // param.Password = Utils.formatOptions(password)
     param.appkey = window.GLOB.appkey || ''
+    let url = '/webapi/dologon'
 
     if (isCloud) {
       param.debug = 'Y'
       if (options.cloudServiceApi) {
-        param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon')
+        url = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon')
       }
     } else if (window.GLOB.mainSystemApi) {
       if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
         param.linkurl = window.GLOB.linkurl
       }
-      param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
+      url = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon')
     }
 
     return axios({
-      url: '/webapi/dologon',
+      url,
       method: 'post',
       data: param
     })
@@ -391,61 +383,21 @@
     param.lang = param.lang || sessionStorage.getItem('lang') || ''
     param.appkey = window.GLOB.appkey || ''
     param.SessionUid = localStorage.getItem('SessionUid') || ''
-    param.rduri = options.cloudServiceApi || ''
     param.userid = sessionStorage.getItem('CloudUserID') || ''
     param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
 
     param = this.encryptParam(param)
 
+    let url = options.cloudServiceApi ? options.cloudServiceApi : '/webapi/dostars'
+    if (param.func) {
+      url = url + '/' + param.func
+    }
+
     return axios({
-      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+      url,
       method: 'post',
       data: param
     })
-  }
-
-  /**
-   * @description 鑾峰彇浜戠閰嶇疆锛屽苟缂撳瓨淇℃伅
-   */
-  getCloudCacheConfig (param) {
-    param.lang = param.lang || sessionStorage.getItem('lang') || ''
-    param.appkey = window.GLOB.appkey || ''
-    param.SessionUid = localStorage.getItem('SessionUid') || ''
-
-    if (options.cloudServiceApi) { // 闈炰簯绔姹�
-      param.rduri = options.cloudServiceApi
-      param.userid = sessionStorage.getItem('CloudUserID') || ''
-      param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
-    } else {                       // 浜戠璇锋眰
-      param.userid = sessionStorage.getItem('UserID')
-      param.LoginUID = sessionStorage.getItem('LoginUID') || ''
-    }
-
-    let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃
-    delete _param.timestamp
-    delete _param.secretkey
-    delete _param.open_key
-    _param = JSON.stringify(_param)
-    _param  = md5(_param)
-    
-    if (window.GLOB.CacheMap.has(_param)) {
-      return Promise.resolve(window.GLOB.CacheMap.get(_param))
-    } else {
-      param = this.encryptParam(param)
-
-      return new Promise(resolve => {
-        axios({
-          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
-          method: 'post',
-          data: param
-        }).then(res => {
-          if (res.status) {
-            window.GLOB.CacheMap.set(_param, res)
-          }
-          resolve(res)
-        })
-      })
-    }
   }
 
   /**
@@ -458,18 +410,19 @@
     param.LoginUID = sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
 
+    let url = '/webapi/dostars'
     if (sessionStorage.getItem('isEditState') === 'true' && options.cloudServiceApi) { // 缂栬緫鐘舵�侊紝涓斿瓨鍦ㄤ簯绔湴鍧�
-      param.rduri = options.cloudServiceApi
+      url = options.cloudServiceApi
       param.userid = sessionStorage.getItem('CloudUserID') || ''
       param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
     } else if (window.GLOB.mainSystemApi) {
-      param.rduri = window.GLOB.mainSystemApi
+      url = window.GLOB.mainSystemApi
     }
 
     param = this.encryptParam(param)
 
     return axios({
-      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+      url: `${url}${param.func ? '/' + param.func : ''}`,
       method: 'post',
       data: param
     })
@@ -485,10 +438,16 @@
     param.LoginUID = sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
 
+    let url = '/webapi/dostars'
+    if (param.rduri) {
+      url = param.rduri
+      delete param.rduri
+    }
+
     param = this.encryptParam(param)
 
     return axios({
-      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+      url: `${url}${param.func ? '/' + param.func : ''}`,
       method: 'post',
       data: param
     })
@@ -505,14 +464,15 @@
     param.LoginUID = sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
 
+    let url = '/webapi/dostars'
     if (sessionStorage.getItem('isEditState') === 'true') { // 缂栬緫鐘舵�侊紝鍗曠偣鐧诲綍鏈嶅姟鍣ㄤ负浜戠
       if (options.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟
-        param.rduri = options.cloudServiceApi
+        url = options.cloudServiceApi
         param.userid = sessionStorage.getItem('CloudUserID') || ''
         param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
       }
     } else if (window.GLOB.mainSystemApi) {
-      param.rduri = window.GLOB.mainSystemApi
+      url = window.GLOB.mainSystemApi
     }
 
     let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃
@@ -529,7 +489,7 @@
         }, () => {
           param = this.encryptParam(param)
           axios({
-            url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+            url: `${url}${param.func ? '/' + param.func : ''}`,
             method: 'post',
             data: param
           }).then(res => {
@@ -549,7 +509,7 @@
         }, () => {
           param = this.encryptParam(param)
           axios({
-            url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+            url: `${url}${param.func ? '/' + param.func : ''}`,
             method: 'post',
             data: param
           }).then(res => {
@@ -575,7 +535,7 @@
 
       return new Promise(resolve => {
         axios({
-          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+          url: `${url}${param.func ? '/' + param.func : ''}`,
           method: 'post',
           data: param
         }).then(res => {
@@ -598,10 +558,6 @@
     param.SessionUid = localStorage.getItem('SessionUid') || ''
     param.LoginUID = sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
-
-    if (window.GLOB.mainSystemApi) {
-      param.rduri = window.GLOB.mainSystemApi
-    }
 
     let _param  = md5(JSON.stringify(param))
     
@@ -656,6 +612,12 @@
     param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
 
+    let url = '/webapi/dostars'
+    if (param.rduri) {
+      url = param.rduri
+      delete param.rduri
+    }
+
     let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃
     delete _param.timestamp
     delete _param.secretkey
@@ -670,7 +632,7 @@
 
       return new Promise(resolve => {
         axios({
-          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+          url: `${url}${param.func ? '/' + param.func : ''}`,
           method: 'post',
           data: param
         }).then(res => {
@@ -697,11 +659,16 @@
       param.userid = sessionStorage.getItem('CloudUserID') || param.userid || ''
       param.LoginUID = sessionStorage.getItem('CloudLoginUID') || param.LoginUID || ''
     }
+    let url = '/webapi/dostars'
+    if (param.rduri) {
+      url = param.rduri
+      delete param.rduri
+    }
 
     param = this.encryptParam(param)
 
     return axios({
-      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
+      url: `${url}${param.func ? '/' + param.func : ''}`,
       method: 'post',
       data: param
     })
@@ -775,10 +742,11 @@
     param = this.encryptParam(param)
 
     if (param.rduri) {
-      param.rduri = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image')
+      let url = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image')
+      delete param.rduri
 
       return axios({
-        url: '/webapi/dostars',
+        url,
         method: 'post',
         data: param
       })

--
Gitblit v1.8.0