|
|
@@ -1,5 +1,5 @@
|
|
|
// 基础配置
|
|
|
-import { removeUserInfo, removeToken } from "./auth.js";
|
|
|
+import { showLoading, hideLoading } from '@/hooks/useLoading'
|
|
|
import config from "@/config";
|
|
|
const { Host85, Host00 } = config;
|
|
|
// const baseUrl = "https://ucard.cwgrd.com";
|
|
|
@@ -7,6 +7,8 @@ const { Host85, Host00 } = config;
|
|
|
// const baseUrl = "http://192.168.0.18:8700";
|
|
|
const baseUrl = Host85;
|
|
|
const timeout = 10000;
|
|
|
+// 不加loading
|
|
|
+const urlLoading = ['/list', '/page', '/field/params', '/dropdown', '/single', '/detail']
|
|
|
import { CLIENT, lang, userToken } from "@/composables/config";
|
|
|
const LOGIN_PAGE_PATH = "/pages/login/index";
|
|
|
import useGlobalStore from "@/stores/use-global-store";
|
|
|
@@ -131,6 +133,10 @@ export const request = (options) => {
|
|
|
const processedConfig = requestInterceptor(config);
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
+ const needLoading = urlLoading.some(item => config.url.includes(item));
|
|
|
+ if (!needLoading) {
|
|
|
+ showLoading();
|
|
|
+ }
|
|
|
uni.request({
|
|
|
...processedConfig,
|
|
|
success: (response) => {
|
|
|
@@ -139,11 +145,18 @@ export const request = (options) => {
|
|
|
resolve(result);
|
|
|
} catch (err) {
|
|
|
reject(err);
|
|
|
+ } finally {
|
|
|
+ if (!needLoading) {
|
|
|
+ hideLoading();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
const handledError = errorHandler(error);
|
|
|
reject(handledError);
|
|
|
+ if (!needLoading) {
|
|
|
+ hideLoading();
|
|
|
+ }
|
|
|
},
|
|
|
});
|
|
|
});
|