123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import {config} from '@/common/config.js';
- const install = (Vue, vm) => {
-
- Vue.prototype.$u.http.setConfig({
- baseUrl: config.baseUrl,
- method: 'POST',
-
- dataType: 'json',
- showLoading: true,
- loadingText: '请求中...',
- loadingTime: 800,
- originalData: false,
- loadingMask: true,
-
- header: {
- 'content-type': 'application/json;charset=UTF-8'
- },
- });
-
-
- Vue.prototype.$u.http.interceptor.request = (config) => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(config.url == '/user/login') config.header.noToken = true;
-
- return config;
-
-
- }
-
-
- Vue.prototype.$u.http.interceptor.response = (res) => {
- if(res.retHead.errCode == 0) {
-
-
-
- return res;
- } else if(res.retHead.errCode == 1) {
-
- vm.$u.toast('获取失败');
-
-
-
-
- return false;
- } else {
-
-
- return false;
- }
- }
- }
- export default {
- install
- }
|