king
2019-12-10 bd06958321afa706f32287c71bd219eb0622c86c
src/api/index.js
@@ -22,16 +22,19 @@
  return Promise.reject(error)
})
// const setCurrentUrl = () => {
//   if (!!(window.history && window.history.pushState)) {
//     window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
//     window.location.reload()
//   }
// }
const setCurrentUrl = () => {
  if (!!(window.history && window.history.pushState)) {
    window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
    window.location.reload()
  }
}
let GlobMap = new Map()
axios.interceptors.response.use((response) => {
  if (response.data.ErrCode === 'LoginError') {
    // setCurrentUrl()
    setCurrentUrl()
    // return Promise.resolve(response.data)
  } else {
    return Promise.resolve(response.data)
  }
@@ -126,6 +129,7 @@
    if (window.GLOB.mainSystemApi) {
      param.rduri = window.GLOB.mainSystemApi
    }
    return axios({
      url: '/webapi/dostar',
      data: param
@@ -133,6 +137,40 @@
  }
  /**
   * @description 获取系统配置,优先从缓存中取值,增加appkey
   */
  getSystemCacheConfig (param) {
    param.userid = sessionStorage.getItem('UserID')
    param.lang = localStorage.getItem('lang') || ''
    param.SessionUid = sessionStorage.getItem('SessionUid') || ''
    param.LoginUID = sessionStorage.getItem('LoginUID') || ''
    param.appkey = window.GLOB.appkey || ''
    if (window.GLOB.mainSystemApi) {
      param.rduri = window.GLOB.mainSystemApi
    }
    let _param = JSON.parse(JSON.stringify(param)) // 缓存校验,去除时间和加密字符
    delete _param.timestamp
    delete _param.secretkey
    _param = JSON.stringify(_param)
    if (GlobMap.has(_param)) {
      return Promise.resolve(GlobMap.get(_param))
    } else {
      return new Promise(resolve => {
        axios({
          url: '/webapi/dostar',
          data: param
        }).then(res => {
          GlobMap.set(_param, res)
          resolve(res)
        })
      })
    }
  }
  /**
   * @description 获取业务通用接口
   */
  genericInterface (param) {