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) {