From 94d5e96bbbf7978335de77e7d84523b0efbd3cb4 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 15:58:28 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9diy=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.ts | 3 ++- src/utils/common.ts | 19 ++++++++++++++++++- src/views/layout/index.vue | 3 ++- src/views/tabbar/index.vue | 3 +++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index bf979f6e..7f0ea508 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -7,7 +7,8 @@ class CommonAPI { /** 链接初始化接口 */ static getInit() { const new_type = get_type(); - if (isEmpty(new_type)) { + const location_host = document.location.host; + if (isEmpty(new_type) || location_host.indexOf('#/tabbar') !== -1) { return request({ url: `diyapi/init`, method: 'post', diff --git a/src/utils/common.ts b/src/utils/common.ts index fb6446c4..1c334f73 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -41,7 +41,7 @@ export const get_id = () => { return new_id; } }; - +// 获取当前业务类型 export const get_type = () => { let new_type = ''; // 去除origin的数据 @@ -57,4 +57,21 @@ export const get_type = () => { } else { return new_type; } +} +// 获取类型 +export const get_business = () => { + let new_business = ''; + // 去除origin的数据 + const url = document.location.href; + if (url.indexOf('business') != -1) { + new_business = url.substring(url.indexOf('business/') + 9); + // 去除字符串的.html + const dot_data = new_business.split('.')[0]; + if (dot_data != '') { + new_business = dot_data.split('/')[0]; + } + return new_business; + } else { + return new_business; + } } \ No newline at end of file diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index bcaf7768..b7f90025 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -28,7 +28,7 @@ import { diyData, headerAndFooter, diyConfig } from '@/api/diy'; import CommonAPI from '@/api/common'; import { commonStore } from '@/store'; import { magic_config } from '@/config/const/tabs-magic'; -import { get_id, get_type } from '@/utils/common'; +import { get_business, get_id, get_type } from '@/utils/common'; const common_store = commonStore(); interface diy_data_item { id: string; @@ -644,6 +644,7 @@ const diy_data_transfor_form_data = (clone_form: diy_data_item) => { name: clone_form.model.name, is_enable: clone_form.model.is_enable, describe: clone_form.model.describe, + business: get_business(), config: JSON.stringify({ header: clone_form.header, footer: clone_form.footer, diff --git a/src/views/tabbar/index.vue b/src/views/tabbar/index.vue index 34ff7f11..a77c4ab4 100644 --- a/src/views/tabbar/index.vue +++ b/src/views/tabbar/index.vue @@ -24,6 +24,7 @@ import defaultSettings from './components/main/index'; import { cloneDeep } from 'lodash'; import CommonAPI from '@/api/common'; import { commonStore } from '@/store'; +import { get_business } from '@/utils/common'; const common_store = commonStore(); const temp_form = ref(defaultSettings.footer_nav); const form = ref({}); @@ -79,6 +80,7 @@ const save_event = () => { const new_data = { type: get_type(), config: clone_form, + business: get_business(), }; save_disabled.value = true; // 数据改造 @@ -93,6 +95,7 @@ const save_event = () => { save_disabled.value = false; }); }; + const get_type = () => { let new_type = 'home'; if (document.location.search.indexOf('/type/') != -1) { 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 02/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=98=BE=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) { From 1773e48e3e81b3b8c9530172eb45aa8eb99e1a2e 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:32:20 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BC=A0=E9=80=92=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/layout/index.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index b7f90025..bcaf7768 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -28,7 +28,7 @@ import { diyData, headerAndFooter, diyConfig } from '@/api/diy'; import CommonAPI from '@/api/common'; import { commonStore } from '@/store'; import { magic_config } from '@/config/const/tabs-magic'; -import { get_business, get_id, get_type } from '@/utils/common'; +import { get_id, get_type } from '@/utils/common'; const common_store = commonStore(); interface diy_data_item { id: string; @@ -644,7 +644,6 @@ const diy_data_transfor_form_data = (clone_form: diy_data_item) => { name: clone_form.model.name, is_enable: clone_form.model.is_enable, describe: clone_form.model.describe, - business: get_business(), config: JSON.stringify({ header: clone_form.header, footer: clone_form.footer, From 786a62272b7abe16e524a76a604aba0db3d8e68a 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:33:11 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 756d599f..57b53e51 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -47,7 +47,7 @@ export const get_type = () => { } // 获取类型 export const get_business = () => { - return data_handle('business/', ''); + return data_handle('business/', 'home'); } // 数据处理 export const data_handle = (val: string, default_val: string): string => { From 1fcec31046a736ac4bccc767f271b3fa2b2e63f7 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:34:18 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 57b53e51..756d599f 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -47,7 +47,7 @@ export const get_type = () => { } // 获取类型 export const get_business = () => { - return data_handle('business/', 'home'); + return data_handle('business/', ''); } // 数据处理 export const data_handle = (val: string, default_val: string): string => { From 30bd427d7022d8a5f66ab319771fd250ee1f8015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Wed, 15 Oct 2025 17:56:39 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/common.ts | 3 + src/utils/common.ts | 69 ++++++++++++++------ src/views/layout/components/navbar/index.vue | 12 ++-- 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/src/store/modules/common.ts b/src/store/modules/common.ts index e6b32486..25168694 100644 --- a/src/store/modules/common.ts +++ b/src/store/modules/common.ts @@ -22,6 +22,9 @@ export const commonStore = defineStore('common', () => { goods_order_by_type_list: [] as any[], //---- 商品排序 data_order_by_rule_list: [] as any[], //---- 数据排序 brand_order_by_type_list: [] as any[], //---- 品牌排序 + diy_config_operate: { + is_base_data: 1, //---- 是否需要基础数据 + } as any, //---- diy配置权限 config: { common_amap_map_ak: '', common_amap_map_safety_ak: '', diff --git a/src/utils/common.ts b/src/utils/common.ts index 756d599f..4d407510 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -15,32 +15,63 @@ export const font_weight = [ { name: '正常', value: '400' }, ]; +/** + * 从URL中提取指定前缀后的ID值 + * @param prefix 前缀字符串 + * @returns 提取的ID值 + */ +const extractIdFromUrl = (prefix: string): string => { + const url = document.location.href; + const startIndex = url.indexOf(prefix); + if (startIndex === -1) return ''; + + // 计算起始位置(包含前缀) + const start = startIndex + prefix.length; + let result = url.substring(start); + + // 移除.html后缀 + const dotIndex = result.indexOf('.'); + if (dotIndex !== -1) { + result = result.substring(0, dotIndex); + } + + // 移除查询参数 + const andIndex = result.indexOf('&'); + if (andIndex !== -1) { + result = result.substring(0, andIndex); + } + + // 移除路径分隔符后的部分 + const slashIndex = result.indexOf('/'); + if (slashIndex !== -1) { + result = result.substring(0, slashIndex); + } + + return result; +}; // 截取document.location.search字符串内id/后面的所有字段 export const get_id = () => { - let new_id = ''; - // 去除origin的数据 + // 先尝试匹配 id/ 模式 const url = document.location.href; - if (url.indexOf('id/') != -1) { - new_id = url.substring(url.indexOf('id/') + 3); - // 去除字符串的.html - let html_index = new_id.indexOf('.html'); - if (html_index != -1) { - new_id = new_id.substring(0, html_index); + const idIndex = url.indexOf('id/'); + if (idIndex !== -1) { + const result = url.substring(idIndex + 3); + const htmlIndex = result.indexOf('.html'); + if (htmlIndex !== -1) { + return result.substring(0, htmlIndex); } - return new_id; - } else if (url.indexOf('-saveinfo') != -1) { - new_id = url.substring(url.indexOf('-saveinfo-') + 10); - // 去除字符串的.html - const dot_data = new_id.split('.')[0]; - if (dot_data != '') { - new_id = dot_data.split('/')[0]; - } - return new_id; - } else { - return new_id; + return result.split('.')[0].split('/')[0]; } + + // 尝试匹配-saveinfo-模式 + const saveinfoResult = extractIdFromUrl('-saveinfo-'); + if (saveinfoResult) return saveinfoResult; + + // 尝试匹配-forminputinfo-模式 + return extractIdFromUrl('-diyinfo-'); }; + // 获取当前业务类型 export const get_type = () => { return data_handle('type/', ''); diff --git a/src/views/layout/components/navbar/index.vue b/src/views/layout/components/navbar/index.vue index aa2608ab..287b33d9 100644 --- a/src/views/layout/components/navbar/index.vue +++ b/src/views/layout/components/navbar/index.vue @@ -5,17 +5,17 @@
-
+
{{ modelValue.name }}
- +
@@ -53,6 +53,8 @@