球星卡微信小程序
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.

28 lines
739 B

  1. import { BASE_URL } from "@/config/index.js";
  2. const { httpMessage } = require('@/common/requestMessage.js');
  3. module.exports = (vm) => {
  4. // 请求全局配置
  5. uni.$u.http.setConfig((config) => {
  6. config.baseURL = BASE_URL;
  7. return config
  8. })
  9. // 请求前拦截, 现在不做拦截
  10. uni.$u.http.interceptors.request.use(config => {
  11. return config;
  12. })
  13. // 响应拦截
  14. uni.$u.http.interceptors.response.use(res => {
  15. if(res.data.code == 0) {
  16. return res;
  17. } else if (res.data.code == 401) {
  18. httpMessage('您的登录状态已过期,登录后我们才能提供更好的服务');
  19. return false;
  20. } else {
  21. vm.$msg(res.data.msg);
  22. return false;
  23. }
  24. // res.code == 9998 手机号 res.code == 9999 用户信息
  25. })
  26. }