From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 09 十二月 2022 15:53:32 +0800
Subject: [PATCH] 2022-12-09

---
 src/api/index.js |  764 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 564 insertions(+), 200 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 8afe7d9..52ef280 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -2,6 +2,7 @@
 import qs from 'qs'
 import { notification } from 'antd'
 import md5 from 'md5'
+import CryptoJS from 'crypto-js'
 import jsSHA from 'jssha'
 import moment from 'moment'
 import Utils from '@/utils/utils.js'
@@ -10,16 +11,20 @@
 
 window.GLOB.WebSql = null
 window.GLOB.IndexDB = null
-const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas,16044812935562g807p3p12huk8kokmb,
+window.GLOB.OuterToken = {}
+const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas,
   1585192949946f3et2ts8tn82krmumdf,15855615451212m12ip23vpcm79kloro,1587005717541lov40vg61q7l1rbveon,1590458676585agbbr63t6ihighg2i1g,1602315375262ikd33ii0nii34pt861o,1582771068837vsv54a089lgp45migbg,
   1582777675954ifu05upurs465omoth7,158294809668898cklbv6c5bou8e1fpu,1584676379094iktph45fb8imhg96bql,1584695125339vo5g7iqgfn01qmrd6s2,1584699661372vhmpp9dn9foo0eob722,15848421131551gg04ie8sitsd3f7467,
-  1589782279158ngr675kk3oksin35sul,1589788042787ffdt9hle4s45k9r1nvs,15900310928174dro07ihfckghpb5h13,1594095599055qicg2eb642v5qglhnuo,1599613340050c8nu6rbst9d4emnnbsq,1577972969199lei1g0qkvlh4tkc908m,
+  1589782279158ngr675kk3oksin35sul,1589788042787ffdt9hle4s45k9r1nvs,1594095599055qicg2eb642v5qglhnuo,1577972969199lei1g0qkvlh4tkc908m,16044812935562g807p3p12huk8kokmb,
   1578479100252lfbp29v1kafk4s4q4ig,1577971621421tg4v0i1ur8873k7e0ob,1577929944419lgc5h3hepum765e2k7u,1588493493409k9guqp067d31lu7blsv,15827879285193g85m3i2uprektpgmpf`
 
+let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : ''
+let db = `mkdb${service}`
+
 if (window.openDatabase) {
-  CacheUtils.openWebSql(options.sysType)
+  CacheUtils.openWebSql(db)
 } else if (window.indexedDB) {
-  CacheUtils.openIndexDB(options.sysType)
+  CacheUtils.openIndexDB(db)
 }
 
 axios.defaults.crossDomain = true
@@ -27,9 +32,9 @@
 axios.defaults.withCredentials = false
 
 axios.interceptors.request.use((config) => {
-  if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) {
+  if (/LoginAndRedirect|getjsonresult|wxNativePay|postek/ig.test(config.url)) {
     config.data = qs.stringify(config.data)
-  } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) {
+  } else if (/\/doupload|\/dopreload|\/upload/.test(config.url)) {
     config.headers = { 'Content-Type': 'multipart/form-data' }
   } else if (config.method === 'post' && config.data) {
     config.data = JSON.stringify(config.data)
@@ -55,6 +60,7 @@
     localStorage.removeItem('localDataM')
     localStorage.removeItem('debug')
     localStorage.removeItem('role_id')
+    localStorage.removeItem('mk_user_type')
     localStorage.removeItem('localRole_id')
 
     sessionStorage.clear()
@@ -76,25 +82,27 @@
     return Promise.resolve(response.data)
   }
 }, (error) => {
-  if (error && error.response) {
-    notification.error({
-      className: 'notification-custom-error',
-      bottom: 0,
-      message: '鐘舵�佺爜-' + error.response.status + '锛岃鑱旂郴绠$悊鍛�',
-      placement: 'bottomRight',
-      duration: 15
-    })
+  let response = error.response
+
+  if (response) {
+    if (!response.data || !response.data.errors) { // 杩囨护鏃疯鎶ラ敊淇℃伅
+      notification.error({
+        className: 'notification-custom-error',
+        bottom: 0,
+        message: '鐘舵�佺爜-' + response.status + '锛岃鑱旂郴绠$悊鍛�',
+        placement: 'bottomRight',
+        duration: 15
+      })
+    }
+    return Promise.reject(response)
+  } else {
+    return Promise.reject()
   }
-  return Promise.reject(error.response)
 })
 
 class Api {
   constructor() {
-    if (process.env.NODE_ENV === 'production') {
-      axios.defaults.baseURL = document.location.origin + '/' + window.GLOB.service
-    } else {
-      axios.defaults.baseURL = window.GLOB.location + '/' + window.GLOB.service
-    }
+    axios.defaults.baseURL = window.GLOB.baseurl
   }
   
   /**
@@ -105,13 +113,14 @@
     param.userid = param.userid || ''
 
     return axios({
-      url: '/webapi/dostar',
+      url: `/webapi/dostar${param.func ? '/' + param.func : ''}`,
       method: 'post',
       data: param
     })
   }
 
   /**
+<<<<<<< HEAD
    * @description 浣跨敤dostar鎺ュ彛锛岃烦杩囬獙璇�
    * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁�
    */
@@ -131,6 +140,72 @@
   }
 
   /* @description 鐩存帴璇锋眰
+=======
+   * @description 寰俊涓氬姟璇锋眰
+   */
+  wxAccessToken () {
+    let _url = window.GLOB.baseurl + '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 鐩存帴璇锋眰
+>>>>>>> positec
    * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁�
    */
   directRequest (url, method = 'post', param, cross) {
@@ -169,7 +244,7 @@
   /**
    * @description 娓稿鐧诲綍
    */
-  getTouristMsg (appid, openid, memberid, scanId) {
+  getTouristMsg (binding_type, appid, openid, memberid, scanId) {
     let _SessionUid = localStorage.getItem('SessionUid')
 
     if (!_SessionUid) { // 鎵嬪姩娓呴櫎SessionUid鏃讹紝瀹炴椂鐢熸垚
@@ -182,27 +257,40 @@
       timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
       SessionUid: _SessionUid,
       TypeCharOne: 'pc',
-      kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host))
+      kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)),
+      appkey: window.GLOB.appkey || ''
     }
-    
-    param.LText = md5(window.btoa(_SessionUid + param.timestamp))
-    param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
 
-    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/s_visitor_login')
+    }
 
-    if (appid) {
+    if (binding_type === 'mk') {
       param.binding_type = 'mk'
       param.thd_party_member_id = memberid
       param.thd_party_openid = openid
       param.thd_party_appid = appid
       param.id = scanId
-    }
+    } else if (binding_type === 'login_check') { // appid 姝ゆ椂涓虹洰鏍�
+      param.v_type = 'login_check'
+      param.LoginUID = sessionStorage.getItem('LoginUID') || ''
+      url = appid.replace(/\/webapi(.*)/, '/webapi/dologon/s_visitor_login')
 
-    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')
+      if (!param.rduri) {
+        param.rduri = window.GLOB.baseurl + 'webapi/dologon/s_visitor_login'
+      }
+
+      param.linkurl = appid.replace(/\/webapi(.*)/, '/index.html')
     }
+    
+    param.LText = md5(window.btoa(_SessionUid + param.timestamp + (param.linkurl || '')))
+
+    // param.secretkey = md5(param.LText + 'mingke' + param.timestamp) // v_type 涓虹┖鏃�
+    let solt = md5((window.GLOB.appkey + window.btoa(window.GLOB.appkey + 'mingke') + 'mingke').toLowerCase()).slice(-6).toUpperCase()
+
+    param.v_type = param.v_type || 'Y'
+    param.secretkey = md5(param.LText + solt + param.timestamp)
 
     return axios({
       url: url,
@@ -226,23 +314,20 @@
       login_city: city,
       login_id_address: ipAddress,
       kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)),
-      device_id: localStorage.getItem('SessionUid')
+      device_id: localStorage.getItem('SessionUid'),
+      appkey: window.GLOB.appkey || ''
     }
-
-    param.appkey = window.GLOB.appkey || ''
 
     let url = '/webapi/dologon'
     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')
     }
 
@@ -265,10 +350,10 @@
       login_city: city,
       login_id_address: ipAddress,
       kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)),
-      device_id: localStorage.getItem('SessionUid')
+      device_id: localStorage.getItem('SessionUid'),
+      timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
+      appkey: window.GLOB.appkey || ''
     }
-
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
 
     let sys_datetime = sessionStorage.getItem('sys_datetime')
     let app_datetime = sessionStorage.getItem('app_datetime')
@@ -293,20 +378,22 @@
     // Type: 'X' 鏃�
     // param.Password = Utils.formatOptions(password)
 
-    param.appkey = window.GLOB.appkey || ''
+    // positecgroup
+    if (window.GLOB.appkey === '202011021844144334E823A3011414082AD77') {
+      param.svccode = 'oms'
+    }
+
     let url = '/webapi/dologon'
 
     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')
     }
 
@@ -318,9 +405,39 @@
   }
 
   /**
+   * @description 鐧诲綍浜屾楠岃瘉 // positecgroup
+   */
+  verifycode (verify) {
+    let param = {
+      certificate: 'certificate',
+      captcha: verify.code,
+      token: verify.token,
+      ati: verify.ati,
+      vid: verify.vid,
+      uid: verify.uid,
+      shopId: verify.shopId,
+      loginId: verify.loginId,
+      phone: verify.phone,
+      sellerNick: verify.sellerNick,
+      isRisk: verify.isRisk,
+      requestId: verify.requestId,
+      riskNum: verify.riskNum,
+      username: verify.username
+    }
+
+    let url = '/webapi/dologon'
+
+    return axios({
+      url,
+      method: 'post',
+      data: param
+    })
+  }
+
+  /**
    * @description 鑾峰彇绯荤粺鐗堟湰淇℃伅锛屽惎鐢ㄦ垨鏇存柊websql
    */
-  getAppVersion (_resolve, _reject) {
+  getAppVersion (reload) {
     if (!window.GLOB.WebSql && !window.GLOB.IndexDB) {
       return Promise.reject()
     }
@@ -330,20 +447,38 @@
     let app_datetime = sessionStorage.getItem('app_datetime')
     if (sys_datetime && app_datetime) {
       let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000)
-      curTime = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + '.000'
+      let _curTime = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + '.000'
+      if (/^\d{4}-\d{2}-\d{2}/.test(_curTime)) {
+        curTime = _curTime
+      }
     }
 
     if (window.GLOB.WebSql) {
       return new Promise((resolve, reject) => {
         CacheUtils.getWebSqlVersion().then(msg => {
-          let modifydate = msg.createDate || curTime
-          if (modifydate.indexOf('Invalid date') > -1) {
-            modifydate = curTime
-          }
-
           let param = {
             func: 's_get_app_version',
-            modifydate
+            modifydate: msg.createDate
+          }
+
+          param.TypeCharOne = ''
+          param.typename = ''
+
+          if (!msg.createDate && !msg.menuids) {
+            CacheUtils.updateWebSqlversion('1.00', curTime)
+            resolve()
+            return
+          } else if (!msg.createDate || reload === true) {
+            param.modifydate = curTime
+            param.menuids = window.btoa(msg.menuids)
+          } else if (msg.menuids) {
+            let d = localStorage.getItem(db)
+
+            if (!d || curTime.indexOf(d) === -1) {
+              param.menuids = window.btoa(msg.menuids)
+            }
+
+            localStorage.setItem(db, curTime.substr(0, 10))
           }
   
           this.getSystemConfig(param).then(res => {
@@ -351,29 +486,35 @@
               reject()
               return
             }
-            let clear = false
-            let version = '1.00'
-  
-            if (res.menu_data && res.menu_data.length > 0) {
-              res.menu_data.forEach(mid => {
-                if (systemMenuKeys.indexOf(mid.menuid) > -1) {
+            
+            let list = res.menu_data || []
+
+            if (res.menu_del) {
+              list.push(...res.menu_del)
+            }
+
+            list = list.map(mid => mid.menuid)
+
+            if (typeof(reload) === 'string' && !list.includes(reload)) {
+              list.push(reload)
+            }
+
+            if (list.length > 0) {
+              let clear = false
+              list.forEach(mid => {
+                if (systemMenuKeys.indexOf(mid) > -1) {
                   clear = true
                 }
               })
-
               if (clear) {
-                CacheUtils.clearWebSqlConfig()
+                list = ''
               } else {
-                let keys = res.menu_data.map(mid => `'${mid.menuid}'`).join(',')
-                CacheUtils.delWebSqlConfig(keys)
+                list = list.map(mid => `'${mid}'`).join(',')
               }
+              CacheUtils.delWebSqlConfig(list)
             }
-            
-            if (msg.version) {
-              CacheUtils.updateWebSqlTime(curTime)
-            } else {
-              CacheUtils.createWebSqlversion(version, curTime)
-            }
+
+            CacheUtils.updateWebSqlversion(res.app_version || '1.00', curTime)
   
             resolve()
           })
@@ -384,13 +525,29 @@
     } else {
       return new Promise((resolve, reject) => {
         CacheUtils.getIndexDBVersion().then(msg => {
-          let modifydate = msg.createDate || curTime
-          if (modifydate.indexOf('Invalid date') > -1) {
-            modifydate = curTime
-          }
           let param = {
             func: 's_get_app_version',
-            modifydate
+            modifydate: msg.createDate
+          }
+
+          param.TypeCharOne = ''
+          param.typename = ''
+
+          if (!msg.createDate && !msg.menuids) {
+            CacheUtils.updateIndexDBversion({version: '1.00', createDate: curTime})
+            resolve()
+            return
+          } else if (!msg.createDate || reload === true) {
+            param.modifydate = curTime
+            param.menuids = window.btoa(msg.menuids)
+          } else if (msg.menuids) {
+            let d = localStorage.getItem(db)
+
+            if (!d || curTime.indexOf(d) === -1) {
+              param.menuids = window.btoa(msg.menuids)
+            }
+
+            localStorage.setItem(db, curTime.substr(0, 10))
           }
 
           this.getSystemConfig(param).then(res => {
@@ -398,25 +555,33 @@
               reject()
               return
             }
-            let clear = false
-            let version = '1.00'
   
-            if (res.menu_data && res.menu_data.length > 0) {
-              res.menu_data.forEach(mid => {
-                if (systemMenuKeys.indexOf(mid.menuid) > -1) {
+            let list = res.menu_data || []
+
+            if (res.menu_del) {
+              list.push(...res.menu_del)
+            }
+
+            list = list.map(mid => mid.menuid)
+
+            if (typeof(reload) === 'string' && !list.includes(reload)) {
+              list.push(reload)
+            }
+
+            if (list.length > 0) {
+              let clear = false
+              list.forEach(mid => {
+                if (systemMenuKeys.indexOf(mid) > -1) {
                   clear = true
                 }
               })
-
               if (clear) {
-                CacheUtils.clearIndexDBConfig()
-              } else {
-                let keys = res.menu_data.map(mid => `'${mid.menuid}'`)
-                CacheUtils.delIndexDBConfig(keys)
+                list = ''
               }
+              CacheUtils.delIndexDBConfig(list)
             }
 
-            CacheUtils.updateIndexDBversion({version: version, createDate: curTime})
+            CacheUtils.updateIndexDBversion({version: res.app_version || '1.00', createDate: curTime})
   
             resolve()
           })
@@ -431,12 +596,11 @@
    * @description 鏇存柊绯荤粺鐗堟湰淇℃伅锛屾竻绌洪厤缃俊鎭�
    */
   updateAppVersion () {
-    let curTime = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-    CacheUtils.clearWebSqlConfig()
-    CacheUtils.updateWebSqlversion('1.00', curTime)
-    CacheUtils.clearIndexDBConfig()
-    CacheUtils.updateIndexDBversion({version: '1.00', createDate: curTime})
-    CacheUtils.clearFuncs(options.sysType)
+    CacheUtils.delWebSqlConfig()
+    CacheUtils.updateWebSqlversion()
+    CacheUtils.delIndexDBConfig()
+    CacheUtils.updateIndexDBversion()
+    CacheUtils.clearFuncs()
   }
 
   /**
@@ -445,11 +609,6 @@
   deleteMenuStorage (menuId) {
     if (window.GLOB.IndexDB) {
       let key = menuId + (sessionStorage.getItem('UserID') || '')
-    
-      if (sessionStorage.getItem('isEditState') === 'true' && options.cloudServiceApi) {
-        key = menuId + (sessionStorage.getItem('CloudUserID') || '')
-      }
-
       return CacheUtils.delMenuIndexDBConfig(key)
     } else {
       return CacheUtils.delMenuWebSqlConfig(menuId)
@@ -520,32 +679,11 @@
       param.userid = sessionStorage.getItem('CloudUserID') || ''
       param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
     } else if (window.GLOB.mainSystemApi) {
-      url = window.GLOB.mainSystemApi
-    }
-
-    param = this.encryptParam(param)
-
-    return axios({
-      url: `${url}${param.func ? '/' + param.func : ''}`,
-      method: 'post',
-      data: param
-    })
-  }
-
-  /**
-   * @description 鑾峰彇鎴栦慨鏀规湰鍦伴厤缃紝澧炲姞appkey
-   */
-  getLocalConfig (param) {
-    param.userid = param.userid || sessionStorage.getItem('UserID') || ''
-    param.lang = param.lang || sessionStorage.getItem('lang') || ''
-    param.SessionUid = localStorage.getItem('SessionUid') || ''
-    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
+      if (!window.GLOB.transfer) {
+        url = window.GLOB.mainSystemApi
+      } else {
+        param.rduri = window.GLOB.mainSystemApi
+      }
     }
 
     param = this.encryptParam(param)
@@ -559,7 +697,6 @@
 
   /**
    * @description 鑾峰彇绯荤粺閰嶇疆锛屽彇鍊间紭鍏堢瓑绾ebsql銆佺紦瀛樸�佹湇鍔″櫒
-   * @param {Object}  param   璇锋眰鍙傛暟
    */
   getCacheConfig (param) {
     param.userid = sessionStorage.getItem('UserID') || ''
@@ -576,7 +713,11 @@
         param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
       }
     } else if (window.GLOB.mainSystemApi) {
-      url = window.GLOB.mainSystemApi
+      if (!window.GLOB.transfer) {
+        url = window.GLOB.mainSystemApi
+      } else {
+        param.rduri = window.GLOB.mainSystemApi
+      }
     }
 
     let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃
@@ -671,11 +812,10 @@
 
   /**
    * @description 鑾峰彇鏈湴绯荤粺閰嶇疆
-   * @param {Object}  param   璇锋眰鍙傛暟
    */
   getLocalCacheConfig (param) {
     param.userid = sessionStorage.getItem('UserID') || ''
-    param.lang = param.lang || sessionStorage.getItem('lang') || ''
+    param.lang = sessionStorage.getItem('lang') || ''
     param.SessionUid = localStorage.getItem('SessionUid') || ''
     param.LoginUID = sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
@@ -742,17 +882,20 @@
     param.appkey = window.GLOB.appkey || ''
 
     let url = '/webapi/dostars'
-    if (param.rduri) {
+    if (param.rduri && !window.GLOB.transfer) { // positecgroup
       url = param.rduri
       delete param.rduri
     }
 
-    let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃
-    delete _param.timestamp
-    delete _param.secretkey
-    delete _param.open_key
-    _param = JSON.stringify(_param)
-    _param  = md5(_param)
+    let _param = ''
+    if (cache) {
+      _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃
+      delete _param.timestamp
+      delete _param.secretkey
+      delete _param.open_key
+      _param = JSON.stringify(_param)
+      _param  = md5(_param)
+    }
 
     if (cache && window.GLOB.CacheMap.has(_param)) {
       return Promise.resolve(window.GLOB.CacheMap.get(_param))
@@ -774,87 +917,257 @@
     }
   }
 
-  /**
-   * @description 鑾峰彇涓氬姟閫氱敤鎺ュ彛
-   */
-  genericInterface (param) {
-    param.userid = sessionStorage.getItem('UserID') || ''
-    param.lang = sessionStorage.getItem('lang') || ''
-    param.SessionUid = localStorage.getItem('SessionUid') || ''
-    param.LoginUID = sessionStorage.getItem('LoginUID') || ''
-    param.appkey = window.GLOB.appkey || ''
+  visitOuterSystem (param, _resolve) {
+    let token = param.$token
+    delete param.$token
 
-    if (options.cloudServiceApi && param.rduri === options.cloudServiceApi) { // HS涓嬭彍鍗�
-      param.userid = sessionStorage.getItem('CloudUserID') || param.userid || ''
-      param.LoginUID = sessionStorage.getItem('CloudLoginUID') || param.LoginUID || ''
+    try {
+      token = JSON.parse(token)
+      token = token.message
+
+      const key = CryptoJS.enc.Utf8.parse(window.GLOB.appkey.slice(-16))
+      const iv = CryptoJS.enc.Utf8.parse('mksoft')
+  
+      let encryptedHexStr = CryptoJS.enc.Hex.parse(token)
+      let _srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr)
+      let decrypt = CryptoJS.AES.decrypt(_srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 })
+      let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)
+      token = decryptedStr.toString()
+  
+      token = JSON.parse(window.decodeURIComponent(window.atob(token)))
+    } catch (e) {
+      token = null
+      _resolve({status: false, ErrCode: 'E', message: '鎺ュ彛淇℃伅瑙f瀽澶辫触锛�'})
     }
 
-    // 寰呬紭鍖栵紝澧炲姞鏄惁鏀寔璺ㄥ煙璇锋眰
-    // let url = '/webapi/dostars'
-    // if (param.rduri) {
-    //   url = param.rduri
-    //   delete param.rduri
-    // }
+    if (!token) return
 
-    param = this.encryptParam(param)
+    let userid = ''
+    let loginUid = ''
+    let dataM = ''
 
-    return axios({
-      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
-      method: 'post',
-      data: param
-    })
-  }
+    if (window.GLOB.OuterToken[token.interface]) {
+      let msg = window.GLOB.OuterToken[token.interface]
 
-  /**
-   * @description 瀵煎嚭Excel
-   */
-  getExcelOut (param, name) {
-    param.userid = sessionStorage.getItem('UserID')
-    param.lang = sessionStorage.getItem('lang') || ''
-    param.SessionUid = localStorage.getItem('SessionUid') || ''
-    param.LoginUID = sessionStorage.getItem('LoginUID') || ''
-    param.appkey = window.GLOB.appkey || ''
-    
-    return new Promise(resolve => {
+      let seconds = Math.floor((new Date().getTime() - msg.timestamp) / 1000)
+      if (seconds >= 3600) {
+        delete window.GLOB.OuterToken[token.interface]
+      } else {
+        userid = msg.userid
+        loginUid = msg.loginUid
+        dataM = msg.dataM || ''
+      }
+    }
+
+    // param.appkey = token.appkey || ''
+
+    if (userid && loginUid) {
+      param.dataM = dataM
+      param.userid = userid
+      param.LoginUID = loginUid
+      param = this.encryptParam(param)
+
       axios({
-        url: '/webapi/doexcel',
-        responseType: 'blob',
+        url: token.interface,
         method: 'post',
         data: param
       }).then(res => {
-        try {
-          const blob = new Blob([res])
-          
-          if (res.type === 'application/json') {
-            const reader = new FileReader()
-            reader.onload = e => resolve(JSON.parse(e.target.result))
-            reader.readAsText(blob)
-          } else {
-            if ('download' in document.createElement('a')) { // 闈濱E涓嬭浇
-              const elink = document.createElement('a')
-              elink.download = name
-              elink.style.display = 'none'
-              elink.href = URL.createObjectURL(blob)
-              document.body.appendChild(elink)
-              elink.click()
-              URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
-              document.body.removeChild(elink)
-            } else { // IE10+涓嬭浇
-              navigator.msSaveBlob(blob, name)
-            }
-            resolve()
+        _resolve(res)
+      })
+    } else {
+      let _param = {
+        UserName: token.username,
+        systemType: options.sysType,
+        login_city: sessionStorage.getItem('city') || '',
+        device_id: token.appkey || '',
+        timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
+        Type: token.publicKey,
+        appkey: token.appkey || ''
+      }
+  
+      let shaObj = new jsSHA('SHA-1', 'TEXT')
+      shaObj.update(token.password)
+      _param.Password = shaObj.getHash('HEX').toUpperCase()
+      _param.Password = md5(token.privateKey + token.username + _param.Password + _param.timestamp)
+
+      let url = token.interface.replace(/\/webapi(.*)/, '/webapi/dologon')
+  
+      if (token.ssoInterface) {
+        _param.rduri = token.ssoInterface.replace(/\/webapi(.*)/, '/webapi/dologon')
+      }
+  
+      axios({
+        url,
+        method: 'post',
+        data: _param
+      }).then(result => {
+        if (result.status) {
+          window.GLOB.OuterToken[token.interface] = {
+            userid: result.UserID,
+            loginUid: result.LoginUID,
+            timestamp: new Date().getTime(),
+            dataM: result.dataM ? 'Y' : ''
           }
-        } catch (e) {
-          resolve({
-            ErrCode: 'E',
-            ErrMesg: '鏂囦欢瑙f瀽閿欒',
-            message: '',
-            status: false
+
+          param.dataM = result.dataM ? 'Y' : ''
+          param.userid = result.UserID
+          param.LoginUID = result.LoginUID
+          param = this.encryptParam(param)
+
+          axios({
+            url: token.interface,
+            method: 'post',
+            data: param
+          }).then(res => {
+            _resolve(res)
           })
+        } else {
+          _resolve(result)
         }
       })
-    })
+    }
   }
+
+  /**
+   * @description 鑾峰彇涓氬姟閫氱敤鎺ュ彛
+   * 璁块棶 'https://sso.mk9h.cn/webapi/dostars'鎴栦簯绔椂锛屼紶鍏serid銆丩oginUID
+   */
+  genericInterface (param) {
+    param.userid = param.userid || sessionStorage.getItem('UserID') || ''
+    param.lang = param.lang || sessionStorage.getItem('lang') || ''
+    param.SessionUid = localStorage.getItem('SessionUid') || ''
+    param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || ''
+    param.appkey = window.GLOB.appkey || ''
+
+    if (param.$token === '') {
+      return Promise.resolve({status: false, ErrCode: 'E', message: '鎺ュ彛鍦板潃灏氭湭璁剧疆锛�'})
+    } else if (param.$token) {
+      return new Promise(resolve => this.visitOuterSystem(param, resolve))
+    }
+
+    if (['sPC_Get_TableData', 'sPC_Get_TableData_debug', 'sPC_TableData_InUpDe', 'sPC_TableData_InUpDe_debug', 'sPC_Get_structured_data'].includes(param.func)) {
+      if (sessionStorage.getItem('isEditState') === 'true') {
+        param.username = sessionStorage.getItem('CloudUserName') || ''
+        param.fullname = sessionStorage.getItem('CloudFullName') || ''
+      } else {
+        param.username = sessionStorage.getItem('User_Name') || ''
+        param.fullname = sessionStorage.getItem('Full_Name') || ''
+      }
+    }
+
+    let login = false
+    let rduri = null
+
+    if (param.rduri && /\s|\n/.test(param.rduri)) {
+      param.rduri = param.rduri.replace(/\s|\n/g, '')
+      if (!param.rduri) {
+        delete param.rduri
+      }
+    }
+
+    if (param.$login && !window.GLOB.transfer) {
+      login = true
+      rduri = param.rduri || ''
+    }
+    delete param.$login
+
+    let url = '/webapi/dostars'
+
+    if (param.rduri && !window.GLOB.transfer && /\/dostars/.test(param.rduri) && param.func !== 'webapi_ChangeUser') {
+      url = param.rduri
+      delete param.rduri
+    }
+
+    param = this.encryptParam(param)
+
+    if (login) {
+      let time = +sessionStorage.getItem(rduri)
+      let c_time = Math.round(new Date().getTime() / 1000)
+
+      if (time && c_time - time <= 60) {
+        sessionStorage.setItem(rduri, c_time)
+        return axios({
+          url: `${url}${param.func ? '/' + param.func : ''}`,
+          method: 'post',
+          data: param
+        })
+      }
+
+      return new Promise((resolve, reject) => {
+        this.getTouristMsg('login_check', rduri).then(res => {
+          if (res.status) {
+            sessionStorage.setItem(rduri, c_time)
+            axios({
+              url: `${url}${param.func ? '/' + param.func : ''}`,
+              method: 'post',
+              data: param
+            }).then(result => {
+              resolve(result)
+            })
+          } else {
+            resolve(res)
+          }
+        })
+      })
+    } else {
+      return axios({
+        url: `${url}${param.func ? '/' + param.func : ''}`,
+        method: 'post',
+        data: param
+      })
+    }
+  }
+
+  /**
+   * @description 瀵煎嚭Excel锛屽悗鍙扮敓鎴愭枃浠�
+   */
+  // getExcelOut (param, name) {
+  //   param.userid = sessionStorage.getItem('UserID')
+  //   param.lang = sessionStorage.getItem('lang') || ''
+  //   param.SessionUid = localStorage.getItem('SessionUid') || ''
+  //   param.LoginUID = sessionStorage.getItem('LoginUID') || ''
+  //   param.appkey = window.GLOB.appkey || ''
+    
+  //   return new Promise(resolve => {
+  //     axios({
+  //       url: '/webapi/doexcel',
+  //       responseType: 'blob',
+  //       method: 'post',
+  //       data: param
+  //     }).then(res => {
+  //       try {
+  //         const blob = new Blob([res])
+          
+  //         if (res.type === 'application/json') {
+  //           const reader = new FileReader()
+  //           reader.onload = e => resolve(JSON.parse(e.target.result))
+  //           reader.readAsText(blob)
+  //         } else {
+  //           if ('download' in document.createElement('a')) { // 闈濱E涓嬭浇
+  //             const elink = document.createElement('a')
+  //             elink.download = name
+  //             elink.style.display = 'none'
+  //             elink.href = URL.createObjectURL(blob)
+  //             document.body.appendChild(elink)
+  //             elink.click()
+  //             URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
+  //             document.body.removeChild(elink)
+  //           } else { // IE10+涓嬭浇
+  //             navigator.msSaveBlob(blob, name)
+  //           }
+  //           resolve()
+  //         }
+  //       } catch (e) {
+  //         resolve({
+  //           ErrCode: 'E',
+  //           ErrMesg: '鏂囦欢瑙f瀽閿欒',
+  //           message: '',
+  //           status: false
+  //         })
+  //       }
+  //     })
+  //   })
+  // }
 
   /**
    * @description 涓婁紶base64
@@ -873,8 +1186,19 @@
     param = this.encryptParam(param)
 
     let url = '/webapi/SaveBase64Image'
+
     if (param.rduri) {
-      url = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image')
+      param.rduri = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image')
+      if (/\s|\n/.test(param.rduri)) {
+        param.rduri = param.rduri.replace(/\s|\n/g, '')
+        if (!param.rduri) {
+          delete param.rduri
+        }
+      }
+    }
+
+    if (param.rduri && !window.GLOB.transfer) {
+      url = param.rduri
       delete param.rduri
     }
 
@@ -908,16 +1232,56 @@
   }
 
   /**
+   * @description oss鏂囦欢涓婁紶
+   */
+  fileOssUpload (param) {
+    let _url = window.GLOB.location + '/file/oss/upload'
+    if (process.env.NODE_ENV === 'production') {
+      _url = document.location.origin + '/file/oss/upload'
+    }
+    if (/^http:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) {
+      _url = window.GLOB.location + ':8080/file/oss/upload'
+      if (process.env.NODE_ENV === 'production') {
+        _url = document.location.origin + ':8080/file/oss/upload'
+      }
+    } else if (/^https:\/\/(qingqiumarket.cn|cloud.mk9h.cn|sso.mk9h.cn)/.test(_url)) {
+      _url = window.GLOB.location + ':8443/file/oss/upload'
+      if (process.env.NODE_ENV === 'production') {
+        _url = document.location.origin + ':8443/file/oss/upload'
+      }
+    }
+    
+    return axios({
+      url: _url,
+      method: 'post',
+      data: param
+    })
+  }
+
+  /**
    * @description 鑾峰彇寰俊鏀粯浜岀淮鐮�
    */
   getWxNativePay (param) {
+    let _url = window.GLOB.baseurl + '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
     })
   }
 
+  postekPrint (data) {
+    return axios({
+      url: 'http://127.0.0.1:888/postek/print',
+      method: 'post',
+      data: data
+    })
+  }
+
   // /**
   //  * @description 鏂囦欢涓婁紶
   //  */

--
Gitblit v1.8.0