text: import axios from 'axios'
  import store from '@/store'
  import JSONbig from 'json-bigint'
  
  // create an axios instance
  const service = axios.create({
    // url = base url + request url
    baseURL: process.env.VUE_APP_BASE_API,
  
    // send cookies when cross-domain requests
    // withCredentials: true,
  
    // request timeout
    timeout: 30 * 1000,
  
    // axios 在自动解析 JSON 数据之前的 data
    // 这里用于处理 Long 类型精度丢失问题
    transformResponse: [function(data) {
      return JSONbig.parse(data)
    }]
  
  })
  
  // request interceptor
  service.interceptors.request.use(
    config => {
      // do something before request is sent
  
      if (store.getters.token) {
        // let each request carry token
        // ['X-Token'] is a custom headers key
        // please modify it according to the actual situation
        config.headers['authorization'] = 'Bearer ' + '请求的 Token'
      }
      return config
    },
    error => {
      // do something with request error
      // console.log(error) // for debug
      return Promise.reject(error)
    }
  )
  
  // response interceptor
  service.interceptors.response.use(
    /**
     * If you want to get http information such as headers or status
     * Please return  response => response
    */
  
    /**
     * Determine the request status by custom code
     * Here is just an example
     * You can also judge the status by HTTP Status Code
     */
    response => {
      const res = response.data
  
      // if the custom code is not 20000, it is judged as an error.
      if (res.code !== 20000) {
        // 请求成功时的消息提示
  
        // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
        if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
          // to re-login
          // Token 过期的操作与提示
        }
        return Promise.reject(new Error(res.message || 'Error'))
      } else {
        return res
      }
    },
    error => {
      // console.log('err' + error) // for debug
      // 请求失败的消息提示
      return Promise.reject(error)
    }
  )
  
  export default service
  