king
2022-07-06 be22457344d6d3fc079de2a4f0a1e06e4c0f85c3
src/api/index.js
@@ -48,7 +48,7 @@
    }
    sessionStorage.clear()
    sessionStorage.setItem('loginError', JSON.stringify({request: res.config ? res.config.data : '', response: JSON.stringify(res.data)}))
    sessionStorage.setItem('loginError', JSON.stringify({url: res.config ? res.config.url : '', request: res.config ? res.config.data : '', response: JSON.stringify(res.data)}))
    window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
    window.location.reload()
  }
@@ -59,23 +59,29 @@
    if (window.debugger === true) {
      response.data.ErrCode = 'E'
      return Promise.resolve(response.data)
    } else {
    } else if (!sessionStorage.getItem('loginError')) {
      setCurrentUrl(response)
    }
  } else {
    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 {
@@ -99,6 +105,29 @@
      method: 'post',
      data: param
    })
  }
  /**
   * @description 微信业务请求
   */
  wxRequest (url, method, param) {
    let _url = window.GLOB.location + ':8080/' + window.GLOB.service + url
    if (process.env.NODE_ENV === 'production') {
      _url = document.location.origin + ':8080/' + window.GLOB.service + url
    }
    if (param) {
      return axios({
        url: _url,
        method,
        data: param
      })
    } else {
      return axios({
        url: _url,
        method
      })
    }
  }
  /**
@@ -671,7 +700,15 @@
      }
    })
    param.sign = md5(values)
    param.t = new Date().getTime()
    param.t = new Date().getTime();
    ['arr_field', 'LText_field', 'custom_script', 'LText1', 'LText', 'LText2', 'DateCount'].forEach(key => {
      if (param[key]) {
        let val = param[key]
        delete param[key]
        param[key] = val
      }
    })
    return param
  }