You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
739 B
29 lines
739 B
import { BASE_URL } from "@/config/index.js";
|
|
const { httpMessage } = require('@/common/requestMessage.js');
|
|
|
|
module.exports = (vm) => {
|
|
// 请求全局配置
|
|
uni.$u.http.setConfig((config) => {
|
|
config.baseURL = BASE_URL;
|
|
return config
|
|
})
|
|
|
|
// 请求前拦截, 现在不做拦截
|
|
uni.$u.http.interceptors.request.use(config => {
|
|
return config;
|
|
})
|
|
|
|
// 响应拦截
|
|
uni.$u.http.interceptors.response.use(res => {
|
|
if(res.data.code == 0) {
|
|
return res;
|
|
} else if (res.data.code == 401) {
|
|
httpMessage('您的登录状态已过期,登录后我们才能提供更好的服务');
|
|
return false;
|
|
} else {
|
|
vm.$msg(res.data.msg);
|
|
return false;
|
|
}
|
|
// res.code == 9998 手机号 res.code == 9999 用户信息
|
|
})
|
|
}
|