Mr.Shi
2023-09-04 682182cf67a5aa9fed34335fea22d4673f30f10c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * 请求拦截
 * @param {Object} http
 */
module.exports = (vm) => {
    uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作
        if (vm.$store.state.session) {
            config.header['Cookie'] = 'eva-auth-token=' + vm.$store.state.session
        }
        uni.showLoading({ title: '请求中' });
        config.data = config.data || {}
        return config
    }, (config) => Promise.reject(config)) // 可使用async await 做异步操作
}