Blame view

yudao-ui-app/utils/request/requestInterceptors.js 565 Bytes
7fd8e0dd   sfmind   1.静态页面: 首页 个人中心 登...
1
2
3
4
  /**
   * 请求拦截
   * @param {Object} http
   */
93352b53   sfmind   完善手机密码登录和Vuex状态管理
5
6
7
8
9
10
  module.exports = vm => {
    uni.$u.http.interceptors.request.use(
      config => {
        // 可使用async await 做异步操作
        // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{}
        config.data = config.data || {}
93352b53   sfmind   完善手机密码登录和Vuex状态管理
11
        if (vm.$store.getters.hasLogin) {
13b5ad12   sfmind   1.同步调整到OAuth2方式登录...
12
          config.header.Authorization = 'Bearer ' + vm.$store.getters.accessToken
93352b53   sfmind   完善手机密码登录和Vuex状态管理
13
14
15
16
17
18
19
        }
        return config
      },
      (
        config // 可使用async await 做异步操作
      ) => Promise.reject(config)
    )
7fd8e0dd   sfmind   1.静态页面: 首页 个人中心 登...
20
  }