king
2023-03-14 da34633b25d16359cd91a656acad5e811f9972b7
src/api/index.js
@@ -12,7 +12,7 @@
window.GLOB.WebSql = null
window.GLOB.IndexDB = null
window.GLOB.OuterToken = {}
const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas,
const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,
  1585192949946f3et2ts8tn82krmumdf,15855615451212m12ip23vpcm79kloro,1587005717541lov40vg61q7l1rbveon,1590458676585agbbr63t6ihighg2i1g,1602315375262ikd33ii0nii34pt861o,1582771068837vsv54a089lgp45migbg,
  1582777675954ifu05upurs465omoth7,158294809668898cklbv6c5bou8e1fpu,1584676379094iktph45fb8imhg96bql,1584695125339vo5g7iqgfn01qmrd6s2,1584699661372vhmpp9dn9foo0eob722,15848421131551gg04ie8sitsd3f7467,
  1589782279158ngr675kk3oksin35sul,1589788042787ffdt9hle4s45k9r1nvs,1594095599055qicg2eb642v5qglhnuo,1577972969199lei1g0qkvlh4tkc908m,16044812935562g807p3p12huk8kokmb,
@@ -32,7 +32,7 @@
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 (/\/doupload|\/dopreload|\/upload/.test(config.url)) {
    config.headers = { 'Content-Type': 'multipart/form-data' }
@@ -219,7 +219,8 @@
      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 || ''
    }
    let url = '/webapi/dologon/s_visitor_login'
@@ -253,8 +254,6 @@
    param.v_type = param.v_type || 'Y'
    param.secretkey = md5(param.LText + solt + param.timestamp)
    param.appkey = window.GLOB.appkey || ''
    return axios({
      url: url,
      method: 'post',
@@ -265,7 +264,7 @@
  /**
   * @description 手机号验证码登录
   */
  getphoneusermsg (phoneNo, checkcode, isCloud = false, ipAddress, city) {
  getphoneusermsg (phoneNo, checkcode, isCloud = false) {
    let param = {
      // func: 'webapi_login',
      mob: phoneNo,
@@ -274,13 +273,12 @@
      check_code: checkcode,
      way_no: 'sms_vcode',
      systemType: options.sysType,
      login_city: city,
      login_id_address: ipAddress,
      login_city: sessionStorage.getItem('city') || '',
      login_id_address: sessionStorage.getItem('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) {
@@ -305,19 +303,19 @@
  /**
   * @description 登录系统, 获取用户信息
   */
  getusermsg (username, password, isCloud = false, ipAddress, city) {
  getusermsg (username, password, isCloud = false) {
    let param = {
      // func: 'webapi_login',
      UserName: username,
      systemType: options.sysType,
      Type: 'S',
      login_city: city,
      login_id_address: ipAddress,
      login_city: sessionStorage.getItem('city') || '',
      login_id_address: sessionStorage.getItem('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')
@@ -342,20 +340,17 @@
    // Type: 'X' 时
    // param.Password = Utils.formatOptions(password)
    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')
    }
@@ -363,6 +358,55 @@
      url,
      method: 'post',
      data: param
    })
  }
  delCacheConfig (type = '') {
    let date = moment().subtract(7, 'days').format('YYYY-MM-DD')
    CacheUtils.delWebSqlCacheConfig(date, type)
    CacheUtils.delIndexDBCacheConfig(date, type)
  }
  writeCacheConfig (menuid, data) {
    if (!menuid) return
    let date = moment().format('YYYY-MM-DD')
    let _data = data ? JSON.stringify(data) : ''
    CacheUtils.writeCacheInWebSql([menuid, date, _data])
    CacheUtils.writeCacheInIndexDB({menuid, CreateDate: date, LongParam: _data})
  }
  getLCacheConfig (menuid) {
    return new Promise((resolve, reject) => {
      if (window.GLOB.WebSql) {
        CacheUtils.getWebSqlCacheConfig(menuid).then(res => {
          if (res && res.LongParam) {
            let _data = JSON.parse(res.LongParam)
            if (_data.length === 0) {
              resolve()
            } else {
              resolve(_data)
            }
          } else {
            resolve()
          }
        })
      } else if (window.GLOB.IndexDB) {
        CacheUtils.getIndexDBCacheConfig(menuid).then(res => {
          if (res && res.LongParam) {
            let _data = JSON.parse(res.LongParam)
            if (_data.length === 0) {
              resolve()
            } else {
              resolve(_data)
            }
          } else {
            resolve()
          }
        })
      } else {
        resolve()
      }
    })
  }
@@ -802,12 +846,15 @@
      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))
@@ -891,17 +938,17 @@
        UserName: token.username,
        systemType: options.sysType,
        login_city: sessionStorage.getItem('city') || '',
        device_id: localStorage.getItem('SessionUid')
        device_id: token.appkey || '',
        timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
        Type: token.publicKey,
        appkey: token.appkey || ''
      }
  
      _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      _param.Type = token.publicKey
      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)
      _param.appkey = token.appkey || ''
      let url = token.interface.replace(/\/webapi(.*)/, '/webapi/dologon')
  
      if (token.ssoInterface) {
@@ -1186,6 +1233,14 @@
    })
  }
  postekPrint (data) {
    return axios({
      url: 'http://127.0.0.1:888/postek/print',
      method: 'post',
      data: data
    })
  }
  // /**
  //  * @description 文件上传
  //  */