12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import config from "./config.js"
- const install = (Vue, vm) => {
- Vue.prototype.$u.http.setConfig({
-
- baseUrl: config.baseUrl,
- });
-
- Vue.prototype.$u.http.interceptor.request = (config) => {
-
-
-
-
- return config;
- };
-
- Vue.prototype.$u.http.interceptor.response = (res) => {
-
-
- if (res.code == 200) {
- return res;
- } else if (res.code == 301) {
- vm.$u.toast('警告:' + res.msg);
- return false;
- } else if (res.code == 401) {
- uni.reLaunch({
- url: '../login/login'
- })
- vm.$u.toast('认证失败,请重新登录')
- return false;
- } else if (res.code == 403) {
- uni.reLaunch({
- url: '../login/login'
- })
- vm.$u.toast('认证失败,请重新登录')
- return false;
- } else if (res.code == 500) {
- vm.$u.toast('错误:' + res.msg);
- return false;
- } else {
-
- vm.$u.toast('警告:' + res.msg);
- return false;
- }
- };
- }
- export default {
- install
- }
|