jiangping
2023-10-16 d7fe8ae3888c8e2b1eea3c1e3769be0d42a21cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * 请求拦截
 * @param {Object} http
 */
module.exports = (vm) => {
    uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作
        console.log(config);
        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 做异步操作
}