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

32 lines
758 B

  1. import { BASE_URL } from "@/config/index.js"
  2. const install = (Vue, vm) => {
  3. // 请求全局配置
  4. Vue.prototype.$u.http.setConfig({
  5. baseUrl: BASE_URL,
  6. method: 'POST',
  7. dataType: 'json', // 返回数据时自动 JSON.parse()
  8. showLoading: false, // 是否显示请求中的loading
  9. loadingText: '正在加载',
  10. loadingTime: 800 // 延迟800毫秒时显示加载框
  11. });
  12. // 请求前拦截, 现在不做拦截
  13. Vue.prototype.$u.http.interceptor.request = config => {
  14. return true;
  15. };
  16. // 响应拦截
  17. Vue.prototype.$u.http.interceptor.response = res => {
  18. if(res.code == 0) {
  19. return res;
  20. } else {
  21. vm.$msg(res.msg);
  22. return false;
  23. }
  24. // res.code == 9998 手机号 res.code == 9999 用户信息
  25. }
  26. }
  27. export default {
  28. install
  29. }