From 1de488b3b791d37d3693db7a73817a056988c870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Thu, 9 Oct 2025 16:20:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/common.ts | 39 +++++++++++++++++--------------------- src/views/tabbar/index.vue | 15 +-------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 1c334f73..756d599f 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -43,35 +43,30 @@ export const get_id = () => { }; // 获取当前业务类型 export const get_type = () => { - let new_type = ''; - // 去除origin的数据 - const url = document.location.href; - if (url.indexOf('type/') != -1) { - new_type = url.substring(url.indexOf('type/') + 5); - // 去除字符串的.html - const dot_data = new_type.split('.')[0]; - if (dot_data != '') { - new_type = dot_data.split('/')[0]; - } - return new_type; - } else { - return new_type; - } + return data_handle('type/', ''); } // 获取类型 export const get_business = () => { - let new_business = ''; + return data_handle('business/', ''); +} +// 数据处理 +export const data_handle = (val: string, default_val: string): string => { + let new_data = default_val; // 去除origin的数据 const url = document.location.href; - if (url.indexOf('business') != -1) { - new_business = url.substring(url.indexOf('business/') + 9); + if (url.indexOf(val) != -1) { + new_data = url.substring(url.indexOf(val) + val.length); // 去除字符串的.html - const dot_data = new_business.split('.')[0]; - if (dot_data != '') { - new_business = dot_data.split('/')[0]; + // 去除并且数据 + if (new_data.indexOf('&') != -1) { + new_data = new_data.split('&')[0]; } - return new_business; + const dot_data = new_data.split('.')[0]; + if (dot_data != '') { + new_data = dot_data.split('/')[0]; + } + return new_data; } else { - return new_business; + return new_data; } } \ No newline at end of file diff --git a/src/views/tabbar/index.vue b/src/views/tabbar/index.vue index a77c4ab4..3bf91534 100644 --- a/src/views/tabbar/index.vue +++ b/src/views/tabbar/index.vue @@ -38,7 +38,7 @@ onMounted(() => { }); const is_empty = ref(false); const init = () => { - CommonAPI.getDynamicApi(common_store.common.config.app_tabbar_data_url, { type: get_type() }) + CommonAPI.getDynamicApi(common_store.common.config.app_tabbar_data_url, { business: get_business() }) .then((res: any) => { if (res.data) { let data = res.data; @@ -78,7 +78,6 @@ const save_disabled = ref(false); const save_event = () => { const clone_form = cloneDeep(form.value); const new_data = { - type: get_type(), config: clone_form, business: get_business(), }; @@ -96,18 +95,6 @@ const save_event = () => { }); }; -const get_type = () => { - let new_type = 'home'; - if (document.location.search.indexOf('/type/') != -1) { - new_type = document.location.search.substring(document.location.search.indexOf('/type/') + 6); - // 进行3次切割选择参数内容 - const result1 = splitAndGetFirst(new_type, '/'); - const result2 = splitAndGetFirst(result1, '&'); - return splitAndGetFirst(result2, '#'); - } else { - return new_type; - } -}; function splitAndGetFirst(str: string, separator: string): string { const data = str.split(separator); if (data.length > 1) {