king
2023-11-09 b4520cab9cb2a46b759fcc7fd890c632868a5f7f
src/api/index.js
@@ -82,7 +82,6 @@
  
  /**
   * @description 使用dostar接口,跳过验证
   * @param {Object} param 查询及提交参数
   */
  dostarInterface (param) {
    param.userid = param.userid || ''
@@ -304,6 +303,11 @@
    // Type: 'X' 时
    // param.Password = Utils.formatOptions(password)
    // positecgroup
    if (window.GLOB.appkey === '202011021844144334E823A3011414082AD77') {
      param.svccode = 'oms'
    }
    let url = '/webapi/dologon'
    if (isCloud) {
@@ -355,7 +359,41 @@
  }
  /**
<<<<<<< HEAD
   * @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
=======
   * @description 获取系统版本信息
>>>>>>> master
   */
  getAppVersion (reload) {
    if (!window.GLOB.IndexDB) {
@@ -522,11 +560,7 @@
    param.appkey = param.appkey || window.GLOB.appkey
    let url = '/webapi/dostars'
    if (window.GLOB.mkHS && window.GLOB.cloudServiceApi) { // HS下,且存在云端地址
      url = window.GLOB.cloudServiceApi
      param.userid = sessionStorage.getItem('CloudUserID') || ''
      param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
    } else if (window.GLOB.mainSystemApi) {
    if (window.GLOB.mainSystemApi) {
      if (!window.GLOB.transfer) {
        url = window.GLOB.mainSystemApi
      } else {
@@ -554,13 +588,7 @@
    param.appkey = param.appkey || window.GLOB.appkey || ''
    let url = '/webapi/dostars'
    if (window.GLOB.mkHS) {          // HS下,单点登录服务器为云端
      if (window.GLOB.cloudServiceApi) { // 存在云端地址时,使用云端系统参数
        url = window.GLOB.cloudServiceApi
        param.userid = sessionStorage.getItem('CloudUserID') || ''
        param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
      }
    } else if (window.GLOB.mainSystemApi) {
    if (window.GLOB.mainSystemApi) {
      if (!window.GLOB.transfer) {
        url = window.GLOB.mainSystemApi
      } else {
@@ -631,7 +659,7 @@
    if (window.GLOB.CacheMap.has(_param)) {
      return Promise.resolve(window.GLOB.CacheMap.get(_param))
    } else {
      return Promise.resolve({ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false})
      return Promise.resolve({ErrCode: 'S', LongParam: '', message: '', status: false})
    }
  }
@@ -670,7 +698,7 @@
  /**
   * @description 获取系统配置,优先从缓存中取值,增加appkey
   * @param {Object}  param   请求参数
   * @param {Boolean} SSO     是否为单点登录地址
   * @param {Boolean} cache   是否使用缓存
   */
  getSystemCacheConfig (param, cache = true) {
    param.userid = param.userid || sessionStorage.getItem('UserID') || ''
@@ -680,7 +708,7 @@
    param.appkey = window.GLOB.appkey || ''
    let url = '/webapi/dostars'
    if (param.rduri && !window.GLOB.transfer) {
    if (param.rduri && !window.GLOB.transfer) { // positecgroup
      url = param.rduri
      delete param.rduri
    }
@@ -715,7 +743,7 @@
    }
  }
  visitOuterSystem (param, _resolve) {
  visitOuterSystem (param, _resolve, _reject) {
    let token = param.$token
    delete param.$token
@@ -735,7 +763,7 @@
      token = JSON.parse(window.decodeURIComponent(window.atob(token)))
    } catch (e) {
      token = null
      _resolve({status: false, ErrCode: 'E', message: '接口信息解析失败!', ErrMesg: 'token_error'})
      _resolve({status: false, ErrCode: 'token_error', message: '接口信息解析失败!'})
    }
    if (!token) return
@@ -771,6 +799,8 @@
        data: JSON.stringify(param)
      }).then(res => {
        _resolve(res)
      }, () => {
        _reject()
      })
    } else {
      let _param = {
@@ -818,9 +848,22 @@
            data: JSON.stringify(param)
          }).then(res => {
            _resolve(res)
          }, () => {
            _reject()
          })
        } else {
          _resolve(result)
        }
      }, (e) => {
        if (!e || !e.status) {
          let msg = '网络连接不正常。'
          if (/^http:/.test(token.interface) && /https:/.test(window.location.protocol)) {
            msg = '网络连接不正常,接口地址可能不支持https。'
          }
          _resolve({status: false, ErrCode: 'E', message: msg})
        } else {
          _reject()
        }
      })
    }
@@ -838,9 +881,9 @@
    param.appkey = window.GLOB.appkey || ''
    if (param.$token === '') {
      return Promise.resolve({status: false, ErrCode: 'E', message: '接口地址尚未设置!', ErrMesg: 'token_error'})
      return Promise.resolve({status: false, ErrCode: 'token_error', message: '接口地址尚未设置!'})
    } else if (param.$token) {
      return new Promise(resolve => this.visitOuterSystem(param, resolve))
      return new Promise((resolve, reject) => this.visitOuterSystem(param, resolve, reject))
    }
    if (['sPC_TableData_InUpDe', 'sPC_TableData_InUpDe_debug'].includes(param.func)) {
@@ -877,7 +920,7 @@
      let time = +sessionStorage.getItem(rduri)
      let c_time = Math.round(new Date().getTime() / 1000)
      if (time && c_time - time <= 60) {
      if (time && c_time - time <= 1800) {
        sessionStorage.setItem(rduri, c_time)
        return axios({
          url: `${url}${param.func ? '/' + param.func : ''}`,
@@ -899,6 +942,17 @@
            })
          } else {
            resolve(res)
          }
        }, (e) => {
          if (!e || !e.status) {
            let msg = '网络连接不正常。'
            if (/^http:/.test(rduri) && /https:/.test(window.location.protocol)) {
              msg = '网络连接不正常,接口地址可能不支持https。'
            }
            resolve({status: false, ErrCode: 'E', message: msg})
          } else {
            reject()
          }
        })
      })
@@ -1023,6 +1077,79 @@
      data: qs.stringify(data)
    })
  }
  /**
   * @description sql检验
   */
  sDebug (sql, rduri = null) {
    let param = {
      func: 's_debug_sql',
      exec_type: 'y',
      timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
      userid: sessionStorage.getItem('UserID') || '',
      lang: sessionStorage.getItem('lang') || '',
      SessionUid: localStorage.getItem('SessionUid') || '',
      LoginUID: sessionStorage.getItem('LoginUID') || '',
      appkey: window.GLOB.appkey || ''
    }
    let id = Utils.getuuid()
    sql = sql.replace(/@time_id@/ig, `'${id}'`)
    if (window.GLOB.externalDatabase !== null) {
      sql = sql.replace(/@db@/ig, window.GLOB.externalDatabase)
    }
    console.info(`/* sql 验证 */\n${sql.replace(/\n\s{6,20}/ig, '\n')}`)
    sql = sql.replace(/\n/ig, ' ')
    param.LText = Utils.formatOptions(sql)
    param.secretkey = Utils.encrypt('', param.timestamp)
    param = this.encryptParam(param)
    let url = '/webapi/dostars'
    if (rduri) {
      url = rduri
    }
    let timer = setTimeout(() => {
      let _param = {
        func: 's_debug_sql_cancel',
        userid: sessionStorage.getItem('UserID') || '',
        lang: sessionStorage.getItem('lang') || '',
        SessionUid: localStorage.getItem('SessionUid') || '',
        LoginUID: sessionStorage.getItem('LoginUID') || '',
        appkey: window.GLOB.appkey || ''
      }
      _param = this.encryptParam(_param)
      axios({
        url: `${url}/s_debug_sql_cancel`,
        method: 'post',
        data: JSON.stringify(_param)
      })
    }, 20000)
    return new Promise(resolve => {
      axios({
        url: `${url}/s_debug_sql`,
        method: 'post',
        data: JSON.stringify(param)
      }).then(res => {
        clearTimeout(timer)
        if (/Shared Memory Provider|会话处于终止状态|当前命令发生了严重错误/.test(res.message)) {
          res.message = '验证失败,请检查SQL中是否存在死循环。'
        } else if (res.message.indexOf('EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 1,当前计数 = 0') > -1) {
          res.ErrCode = '-2'
        }
        resolve(res)
      }, () => {
        clearTimeout(timer)
        resolve({status: false, ErrCode: 'E', message: '验证失败:1请检查SQL中是否存在死循环;2请检查网络连接是否正常。'})
      })
    })
  }
}
export default new Api()