|
@@ -13,11 +13,11 @@
|
|
|
:showHead="currentCommonCategoryContentDefine?.props.showHead"
|
|
:showHead="currentCommonCategoryContentDefine?.props.showHead"
|
|
|
:showDeadBox="currentCommonCategoryContentDefine?.props.showDeadBox"
|
|
:showDeadBox="currentCommonCategoryContentDefine?.props.showDeadBox"
|
|
|
:load="load"
|
|
:load="load"
|
|
|
- :extraTabs="tabRenderDefinesArray"
|
|
|
|
|
|
|
+ :tabs="tabRenderDefinesArray"
|
|
|
@loaded="onLoaded"
|
|
@loaded="onLoaded"
|
|
|
>
|
|
>
|
|
|
<template #extraTabs="{ content, tabCurrentId }">
|
|
<template #extraTabs="{ content, tabCurrentId }">
|
|
|
- <template v-if="tabRenderDefines[tabCurrentId].type === 'intro'">
|
|
|
|
|
|
|
+ <template v-if="tabRenderDefines[tabCurrentId]?.type === 'intro'">
|
|
|
<!-- 简介 -->
|
|
<!-- 简介 -->
|
|
|
<Parse
|
|
<Parse
|
|
|
v-if="content.intro"
|
|
v-if="content.intro"
|
|
@@ -33,7 +33,7 @@
|
|
|
{{ content.from }}
|
|
{{ content.from }}
|
|
|
</text>
|
|
</text>
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].type === 'images'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.type === 'images'">
|
|
|
<!-- 图片 -->
|
|
<!-- 图片 -->
|
|
|
<view v-if="tabRenderDefines[tabCurrentId].prefix" class="d-flex flex-row justify-center align-center mt-2 mb-2">
|
|
<view v-if="tabRenderDefines[tabCurrentId].prefix" class="d-flex flex-row justify-center align-center mt-2 mb-2">
|
|
|
<text class="size-s font-bold color-text-content">{{ tabRenderDefines[tabCurrentId].prefix }}</text>
|
|
<text class="size-s font-bold color-text-content">{{ tabRenderDefines[tabCurrentId].prefix }}</text>
|
|
@@ -45,7 +45,7 @@
|
|
|
imageHeight="200rpx"
|
|
imageHeight="200rpx"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].type === 'video'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.type === 'video'">
|
|
|
<!-- 视频 -->
|
|
<!-- 视频 -->
|
|
|
<video
|
|
<video
|
|
|
v-if="content.video"
|
|
v-if="content.video"
|
|
@@ -56,7 +56,7 @@
|
|
|
controls
|
|
controls
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].type === 'audio'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.type === 'audio'">
|
|
|
<!-- 视频 -->
|
|
<!-- 视频 -->
|
|
|
<video
|
|
<video
|
|
|
v-if="content.audio"
|
|
v-if="content.audio"
|
|
@@ -67,7 +67,7 @@
|
|
|
controls
|
|
controls
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].type === 'list'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.type === 'list'">
|
|
|
<!-- 列表 -->
|
|
<!-- 列表 -->
|
|
|
<CommonCategoryListBlock
|
|
<CommonCategoryListBlock
|
|
|
v-if="currentCommonCategoryDefine"
|
|
v-if="currentCommonCategoryDefine"
|
|
@@ -84,17 +84,17 @@
|
|
|
@error="errorMessage = $event"
|
|
@error="errorMessage = $event"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].type === 'rich'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.type === 'rich'">
|
|
|
<!-- 富文本 -->
|
|
<!-- 富文本 -->
|
|
|
<view class="d-flex flex-col mt-3 mb-2">
|
|
<view class="d-flex flex-col mt-3 mb-2">
|
|
|
<Parse :content="(content[tabRenderDefines[tabCurrentId].key] as string)" />
|
|
<Parse :content="(content[tabRenderDefines[tabCurrentId].key] as string)" />
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].type === 'nestCategory'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.type === 'nestCategory'">
|
|
|
<!-- 嵌套分类 -->
|
|
<!-- 嵌套分类 -->
|
|
|
<CommonCategoryBlocks :categoryDefine="tabRenderDefines[tabCurrentId].categoryDefine" />
|
|
<CommonCategoryBlocks :categoryDefine="tabRenderDefines[tabCurrentId].categoryDefine" />
|
|
|
</template>
|
|
</template>
|
|
|
- <template v-else-if="tabRenderDefines[tabCurrentId].key === 'vr'">
|
|
|
|
|
|
|
+ <template v-else-if="tabRenderDefines[tabCurrentId]?.key === 'vr'">
|
|
|
<!-- VR参观 -->
|
|
<!-- VR参观 -->
|
|
|
<view class="d-flex flex-row justify-center p-5">
|
|
<view class="d-flex flex-row justify-center p-5">
|
|
|
<Button @click="handleGoToVr(content.vr as string)">
|
|
<Button @click="handleGoToVr(content.vr as string)">
|
|
@@ -138,9 +138,10 @@ import { injectAppConfiguration } from '@/api/system/useAppConfiguration';
|
|
|
import { injectCommonCategory } from './CommonCategoryGlobalLoader';
|
|
import { injectCommonCategory } from './CommonCategoryGlobalLoader';
|
|
|
import { doLoadDynamicCategoryDataMergeTypeGetColumns } from './CommonCategoryDynamicData';
|
|
import { doLoadDynamicCategoryDataMergeTypeGetColumns } from './CommonCategoryDynamicData';
|
|
|
import { formatError, StringUtils, waitTimeOut } from '@imengyu/imengyu-utils';
|
|
import { formatError, StringUtils, waitTimeOut } from '@imengyu/imengyu-utils';
|
|
|
|
|
+import { getIsDevtoolsPlatform } from '@/common/utils/MpVersions';
|
|
|
import type { IHomeCommonCategoryDefine, IHomeCommonCategoryListTabNestCategoryItemDefine } from './CommonCategoryDefine';
|
|
import type { IHomeCommonCategoryDefine, IHomeCommonCategoryListTabNestCategoryItemDefine } from './CommonCategoryDefine';
|
|
|
import type { IHomeCommonCategoryDetailDefine, IHomeCommonCategoryDetailTabItemDefine } from './defines/Details';
|
|
import type { IHomeCommonCategoryDetailDefine, IHomeCommonCategoryDetailTabItemDefine } from './defines/Details';
|
|
|
-import type { DetailTabPageProps, DetailTabPageTabsArray } from '../common/DetailTabPage';
|
|
|
|
|
|
|
+import type { DetailTabPageProps } from '../common/DetailTabPage';
|
|
|
import type { CategoryDefine } from './CommonCategoryBlocks';
|
|
import type { CategoryDefine } from './CommonCategoryBlocks';
|
|
|
import LoadingPage from '@/components/display/loading/LoadingPage.vue';
|
|
import LoadingPage from '@/components/display/loading/LoadingPage.vue';
|
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
@@ -152,7 +153,7 @@ import CommonCategoryDetailIntroBlocks from './CommonCategoryDetailIntroBlocks.v
|
|
|
import Tag from '@/components/display/Tag.vue';
|
|
import Tag from '@/components/display/Tag.vue';
|
|
|
import CommonCategoryBlocks from './CommonCategoryBlocks.vue';
|
|
import CommonCategoryBlocks from './CommonCategoryBlocks.vue';
|
|
|
import Parse from '@/components/display/parse/Parse.vue';
|
|
import Parse from '@/components/display/parse/Parse.vue';
|
|
|
-import CommonContent from '@/api/CommonContent';
|
|
|
|
|
|
|
+import CommonContent, { GetContentDetailItem, GetContentListParams } from '@/api/CommonContent';
|
|
|
import CommonCategoryDetailContentBlocks from './CommonCategoryDetailContentBlocks.vue';
|
|
import CommonCategoryDetailContentBlocks from './CommonCategoryDetailContentBlocks.vue';
|
|
|
import ImageGrid from '@/pages/parts/ImageGrid.vue';
|
|
import ImageGrid from '@/pages/parts/ImageGrid.vue';
|
|
|
import CommonCategoryListBlock from './CommonCategoryListBlock.vue';
|
|
import CommonCategoryListBlock from './CommonCategoryListBlock.vue';
|
|
@@ -207,7 +208,7 @@ const currentCommonCategoryDefine = ref<IHomeCommonCategoryDefine['page'][0]>();
|
|
|
const currentCommonCategoryContentDefine = ref<IHomeCommonCategoryDetailDefine>();
|
|
const currentCommonCategoryContentDefine = ref<IHomeCommonCategoryDetailDefine>();
|
|
|
const commonCategory = injectCommonCategory();
|
|
const commonCategory = injectCommonCategory();
|
|
|
|
|
|
|
|
-const tabDefines = computed(() => currentCommonCategoryContentDefine.value?.props.tabs || []);
|
|
|
|
|
|
|
+const tabDefines = ref<IHomeCommonCategoryDetailTabItemDefine[]>([]);
|
|
|
const tabRenderDefines = computed(() => {
|
|
const tabRenderDefines = computed(() => {
|
|
|
const result = {} as Record<number, RenderTabDefine>;
|
|
const result = {} as Record<number, RenderTabDefine>;
|
|
|
try {
|
|
try {
|
|
@@ -242,10 +243,13 @@ const tabRenderDefines = computed(() => {
|
|
|
return result;
|
|
return result;
|
|
|
});
|
|
});
|
|
|
const tabRenderDefinesArray = computed(() => {
|
|
const tabRenderDefinesArray = computed(() => {
|
|
|
- return Object.values(tabRenderDefines.value);
|
|
|
|
|
|
|
+ return Object.values(tabRenderDefines.value) || [];
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
async function loadPageConfig() {
|
|
async function loadPageConfig() {
|
|
|
|
|
+ if (getIsDevtoolsPlatform()) {
|
|
|
|
|
+ await waitTimeOut(1000);
|
|
|
|
|
+ }
|
|
|
if (!props.pageConfigName) {
|
|
if (!props.pageConfigName) {
|
|
|
errorMessage.value = '配置有误';
|
|
errorMessage.value = '配置有误';
|
|
|
return;
|
|
return;
|
|
@@ -266,12 +270,14 @@ async function loadPageConfig() {
|
|
|
title: currentCommonCategoryDefine.value?.title || '',
|
|
title: currentCommonCategoryDefine.value?.title || '',
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ const tabs = currentCommonCategoryContentDefine.value?.props.tabs || [];
|
|
|
|
|
+
|
|
|
await waitTimeOut(50);
|
|
await waitTimeOut(50);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
//特殊处理
|
|
//特殊处理
|
|
|
let hasNestCategory = false;
|
|
let hasNestCategory = false;
|
|
|
- for (const [_, tab] of Object.entries(tabDefines.value)) {
|
|
|
|
|
|
|
+ for (const tab of tabs) {
|
|
|
if (tab.type === 'nestCategory') {
|
|
if (tab.type === 'nestCategory') {
|
|
|
tab.categorys = await doLoadDynamicCategoryDataMergeTypeGetColumns(tab.categorys)
|
|
tab.categorys = await doLoadDynamicCategoryDataMergeTypeGetColumns(tab.categorys)
|
|
|
hasNestCategory = true;
|
|
hasNestCategory = true;
|
|
@@ -281,12 +287,63 @@ async function loadPageConfig() {
|
|
|
await waitTimeOut(50);
|
|
await waitTimeOut(50);
|
|
|
loadState.value = true;
|
|
loadState.value = true;
|
|
|
await waitTimeOut(50);
|
|
await waitTimeOut(50);
|
|
|
- pageRef.value?.load(props.pageQuerys);
|
|
|
|
|
|
|
+ const content = (await pageRef.value?.load(props.pageQuerys)) as GetContentDetailItem;
|
|
|
|
|
+
|
|
|
|
|
+ //Tab标签动态处理
|
|
|
|
|
+ function loadByContentData(text: string) {
|
|
|
|
|
+ let result = text;
|
|
|
|
|
+ const keys = text.split(':');
|
|
|
|
|
+ if (keys.length >= 2) {
|
|
|
|
|
+ switch (keys[1]) {
|
|
|
|
|
+ case 'byContentType':
|
|
|
|
|
+ switch(content.type) {
|
|
|
|
|
+ default:
|
|
|
|
|
+ case GetContentListParams.TYPE_ARTICLE: result = '相关文章'; break;
|
|
|
|
|
+ case GetContentListParams.TYPE_VIDEO: result = '视频'; break;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'bySubListType': {
|
|
|
|
|
+ const subListKey = keys[2];
|
|
|
|
|
+ if (subListKey) {
|
|
|
|
|
+ const list = content?.[subListKey];
|
|
|
|
|
+ console.log('aaaa', list);
|
|
|
|
|
+ if (Array.isArray(list) && list.length > 0) {
|
|
|
|
|
+ switch(list[0].type) {
|
|
|
|
|
+ default:
|
|
|
|
|
+ case GetContentListParams.TYPE_ARTICLE: result = '相关文章'; break;
|
|
|
|
|
+ case GetContentListParams.TYPE_ARCHIVE: result = '相关文档'; break;
|
|
|
|
|
+ case GetContentListParams.TYPE_VIDEO: result = '视频'; break;
|
|
|
|
|
+ case GetContentListParams.TYPE_IMAGE: result = '相册'; break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result = '相关';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'idMap': {
|
|
|
|
|
+ if (currentCommonCategoryContentDefine.value?.props.customTabNameIdMap) {
|
|
|
|
|
+ result = currentCommonCategoryContentDefine.value.props.customTabNameIdMap[content.id];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (const tab of tabs) {
|
|
|
|
|
+ if (tab.text.startsWith('dynamic')) {
|
|
|
|
|
+ tab.text = loadByContentData(tab.text);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ await loadTabVisible(tabs, content);
|
|
|
|
|
+
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
console.error(error);
|
|
|
loadState.value = false;
|
|
loadState.value = false;
|
|
|
errorMessage.value = formatError(error);
|
|
errorMessage.value = formatError(error);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ tabDefines.value = tabs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.pageConfigName, loadPageConfig);
|
|
watch(() => props.pageConfigName, loadPageConfig);
|
|
@@ -309,34 +366,73 @@ const descItems = computed(() => (
|
|
|
function onLoaded(d: any) {
|
|
function onLoaded(d: any) {
|
|
|
content.value = d;
|
|
content.value = d;
|
|
|
}
|
|
}
|
|
|
-async function load(id: number, tabsArray: DetailTabPageTabsArray) {
|
|
|
|
|
|
|
+async function loadTabVisible(tabs: IHomeCommonCategoryDetailTabItemDefine[], d: any) {
|
|
|
|
|
+ for (const tab of tabs) {
|
|
|
|
|
+ const v = d[tab.key];
|
|
|
|
|
+ let check = true
|
|
|
|
|
+ let visibleCheckBy = 'auto';
|
|
|
|
|
+ let visibleCheckKeys = [] as string[];
|
|
|
|
|
+ if (tab.visibleVia && tab.visibleVia.includes(':')) {
|
|
|
|
|
+ visibleCheckKeys = tab.visibleVia.split(':');
|
|
|
|
|
+ visibleCheckBy = visibleCheckKeys[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ switch (visibleCheckBy) {
|
|
|
|
|
+ case 'auto': {
|
|
|
|
|
+ switch (tab.type) {
|
|
|
|
|
+ case 'intro': check = true; break;
|
|
|
|
|
+ case 'audio': check = Boolean(d.audio); break;
|
|
|
|
|
+ case 'video': check = Boolean(d.video); break;
|
|
|
|
|
+ case 'images': check = Boolean(d.images) && (d.images as string[]).length > 1; break;
|
|
|
|
|
+ case 'map': check = Boolean(d.latitude) && Boolean(d.longitude); break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ if (!v)
|
|
|
|
|
+ check = false;
|
|
|
|
|
+ else if (Array.isArray(v))
|
|
|
|
|
+ check = (v as any[]).length > 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'contentProps': {
|
|
|
|
|
+ for (let i = 1; i < visibleCheckKeys.length; i++) {
|
|
|
|
|
+ let key = visibleCheckKeys[i];
|
|
|
|
|
+ let keyMatchProps2 = '';
|
|
|
|
|
+ if (key.includes(',')) {
|
|
|
|
|
+ const arr = key.split(',');
|
|
|
|
|
+ key = arr[0];
|
|
|
|
|
+ keyMatchProps2 = arr[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ const value = d[key];
|
|
|
|
|
+ switch (keyMatchProps2) {
|
|
|
|
|
+ case 'array0': check = Array.isArray(value) && value.length > 0; break;
|
|
|
|
|
+ case 'array1': check = Array.isArray(value) && value.length > 1; break;
|
|
|
|
|
+ case 'noZero': check = Number(value) !== 0 && !isNaN(Number(value)); break;
|
|
|
|
|
+ case 'trim': check = String(value).trim() !== ''; break;
|
|
|
|
|
+ default: check = Boolean(value); break;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!check)
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ case 'idMap': {
|
|
|
|
|
+ const idMap = currentCommonCategoryContentDefine.value?.props.customTabVisibleViaIdMap;
|
|
|
|
|
+ if (idMap && visibleCheckKeys.length >= 2)
|
|
|
|
|
+ check = idMap[`${d.id}:${visibleCheckKeys[1]}`];
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ tab.visible = tab.visible !== false && check;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+async function load(id: number) {
|
|
|
if (isNaN(id) || id <= 0)
|
|
if (isNaN(id) || id <= 0)
|
|
|
throw new Error("请输入ID。如果正在测试,可在后台复制ID");
|
|
throw new Error("请输入ID。如果正在测试,可在后台复制ID");
|
|
|
- const d = await CommonContent.getContentDetail(
|
|
|
|
|
|
|
+ return await CommonContent.getContentDetail(
|
|
|
id,
|
|
id,
|
|
|
undefined,
|
|
undefined,
|
|
|
props.pageQuerys.modelId && Number(props.pageQuerys.modelId) > 0 ? Number(props.pageQuerys.modelId) : undefined
|
|
props.pageQuerys.modelId && Number(props.pageQuerys.modelId) > 0 ? Number(props.pageQuerys.modelId) : undefined
|
|
|
);
|
|
);
|
|
|
- for (const tab of tabRenderDefinesArray.value) {
|
|
|
|
|
- const v = d[tab.key];
|
|
|
|
|
- let check = true
|
|
|
|
|
- if (['intro'].includes(tab.type))
|
|
|
|
|
- check = true;
|
|
|
|
|
- else if (tab.type === 'audio')
|
|
|
|
|
- check = Boolean(d.audio);
|
|
|
|
|
- else if (tab.type === 'video')
|
|
|
|
|
- check = Boolean(d.video);
|
|
|
|
|
- else if (tab.type === 'images')
|
|
|
|
|
- check = Boolean(d.images) && (d.images as string[]).length > 1;
|
|
|
|
|
- else if (tab.type === 'map')
|
|
|
|
|
- check = Boolean(d.latitude) && Boolean(d.longitude);
|
|
|
|
|
- else if (!v)
|
|
|
|
|
- check = false;
|
|
|
|
|
- else if (Array.isArray(v))
|
|
|
|
|
- check = (v as any[]).length > 0;
|
|
|
|
|
- tabsArray.getTabById(tab.id)!.visible = tab.visible !== false && check;
|
|
|
|
|
- }
|
|
|
|
|
- return d;
|
|
|
|
|
}
|
|
}
|
|
|
function handleGoToVr(vr: string) {
|
|
function handleGoToVr(vr: string) {
|
|
|
navTo('/pages/article/web/ewebview', { url: vr })
|
|
navTo('/pages/article/web/ewebview', { url: vr })
|