king
2021-01-26 4b18ab4bf4eff4383bd85beb76564dc6aeb1df86
src/api/index.js
@@ -41,13 +41,11 @@
axios.defaults.withCredentials = true
axios.interceptors.request.use((config) => {
  config.method = 'post'
  if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) {
    config.data = qs.stringify(config.data)
  } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) {
    config.headers = { 'Content-Type': 'multipart/form-data' }
  } else {
    // config.headers.token = sessionStorage.getItem('TOKEN') || ''
  } else if (config.method === 'post') {
    config.data = JSON.stringify(config.data)
  }
@@ -70,9 +68,6 @@
  }
}
window.GLOB.CacheMap = new Map()     // 缓存配置信息
window.GLOB.UserCacheMap = new Map() // 缓存用户自定义设置
axios.interceptors.response.use((response) => {
  if (response.data.ErrCode === 'LoginError') {
    if (window.debugger === true) {
@@ -94,7 +89,7 @@
      duration: 15
    })
  }
  return Promise.reject(error)
  return Promise.reject(error.response)
})
class Api {
@@ -115,8 +110,33 @@
    return axios({
      url: '/webapi/dostar',
      method: 'post',
      data: param
    })
  }
  /**
   * @description 直接请求
   * @param {Object} param 查询及提交参数
   */
  directRequest (url, method = 'post', param) {
    let params = { method: 'post' }
    let _url = url
    if (method === 'get' && param) {
      let keys = Object.keys(param).map(key => `${key}=${param[key]}`)
      keys = keys.join('&')
      if (keys) {
        _url = _url + '?' + keys
      }
    } else if (method === 'post' && param) {
      params.data = param
    }
    _url = window.btoa(_url)
    params.url = '/trans/redirect?rd=' + _url + '&method=' + method
    return axios(params)
  }
  /**
@@ -131,6 +151,7 @@
    return axios({
      url: '/webapi/dostar',
      method: 'post',
      data: param
    })
  }
@@ -164,6 +185,7 @@
    return axios({
      url: '/webapi/dologon',
      method: 'post',
      data: param
    })
  }
@@ -195,6 +217,7 @@
    return axios({
      url: '/webapi/dologon',
      method: 'post',
      data: param
    })
  }
@@ -225,6 +248,7 @@
    return axios({
      url: '/webapi/dologon',
      method: 'post',
      data: param
    })
  }
@@ -287,6 +311,7 @@
      return new Promise((resolve, reject) => {
        axios({
          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
          method: 'post',
          data: param
        }).then(res => {
          if (!res.status) {
@@ -417,6 +442,7 @@
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
      method: 'post',
      data: param
    })
  }
@@ -457,6 +483,7 @@
      return new Promise(resolve => {
        axios({
          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
          method: 'post',
          data: param
        }).then(res => {
          if (res.status) {
@@ -490,6 +517,7 @@
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
      method: 'post',
      data: param
    })
  }
@@ -508,6 +536,7 @@
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
      method: 'post',
      data: param
    })
  }
@@ -561,6 +590,7 @@
            } else {
              axios({
                url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
                method: 'post',
                data: param
              }).then(res => {
                if (res.status) {
@@ -575,6 +605,7 @@
            axios({
              url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
              method: 'post',
              data: param
            }).then(res => {
              if (res.status) {
@@ -593,6 +624,7 @@
      return new Promise(resolve => {
        axios({
          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
          method: 'post',
          data: param
        }).then(res => {
          if (res.status) {
@@ -705,6 +737,7 @@
      return new Promise(resolve => {
        axios({
          url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
          method: 'post',
          data: param
        }).then(res => {
          if (res.status) {
@@ -735,6 +768,7 @@
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
      method: 'post',
      data: param
    })
  }
@@ -753,6 +787,7 @@
      axios({
        url: '/webapi/doexcel',
        responseType: 'blob',
        method: 'post',
        data: param
      }).then(res => {
@@ -824,11 +859,13 @@
      return axios({
        url: '/webapi/dostars',
        method: 'post',
        data: param
      })
    } else {
      return axios({
        url: '/webapi/SaveBase64Image',
        method: 'post',
        data: param
      })
    }
@@ -840,6 +877,7 @@
  getLargeFileUpload (param) {
    return axios({
      url: '/webapi/doupload',
      method: 'post',
      data: param
    })
  }
@@ -850,6 +888,7 @@
  getFilePreUpload (param) {
    return axios({
      url: '/webapi/dopreload',
      method: 'post',
      data: param
    })
  }
@@ -860,6 +899,7 @@
  getWxNativePay (param) {
    return axios({
      url: '/wxpay/wxNativePay',
      method: 'post',
      data: param
    })
  }
@@ -870,6 +910,7 @@
  getFileUpload (param) {
    return axios({
      url: '/zh-CN/Home/Upload',
      method: 'post',
      data: param
    })
  }
@@ -888,6 +929,7 @@
    
    return axios({
      url: '/webapi/dostar',
      method: 'post',
      data: param
    })
  }
@@ -904,6 +946,7 @@
    return axios({
      url: '/webapi/dostar',
      method: 'post',
      data: param
    })
  }