12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import url from "./url.js"
- const install = (Vue, vm) => {
- Vue.prototype.$u.http.setConfig({
- baseUrl: url,
- loadingText: '加载中...',
- loadingTime: 800,
- showLoading: true,
- loadingMask: true,
- originalData: true,
-
- header: {
- 'content-type': 'application/json;charset=UTF-8',
- 'version': 'v1'
- },
- });
-
- Vue.prototype.$u.http.interceptor.request = (config) => {
-
-
-
-
-
-
-
-
-
-
- const token = uni.getStorageSync('token');
- config.header.Authorization = token;
-
-
-
- return config;
-
-
- }
-
- Vue.prototype.$u.http.interceptor.response = (res) => {
- if (res.statusCode == 200) {
-
-
-
- return res.data;
- } else {
-
- if (res.statusCode == 500) {
-
-
-
-
-
-
-
-
-
-
-
- } else {
- uni.showModal({
- content: `未知错误:${res.statusCode}`
- })
- }
- return false;
- }
- }
- }
- export default {
- install
- }
|