|
@@ -42,7 +42,7 @@
|
|
|
|
|
|
|
|
<view class="d-flex flex-col radius-l bg-light p-25 mt-3" style="min-height:70vh">
|
|
<view class="d-flex flex-col radius-l bg-light p-25 mt-3" style="min-height:70vh">
|
|
|
<!-- 简介 -->
|
|
<!-- 简介 -->
|
|
|
- <template v-if="tabCurrentId == 0">
|
|
|
|
|
|
|
+ <template v-if="tabCurrentId == TAB_ID_INTRO">
|
|
|
<Parse
|
|
<Parse
|
|
|
v-if="loader.content.value.intro"
|
|
v-if="loader.content.value.intro"
|
|
|
:content="loader.content.value.intro"
|
|
:content="loader.content.value.intro"
|
|
@@ -56,7 +56,7 @@
|
|
|
<text v-if="emptyContent">暂无简介</text>
|
|
<text v-if="emptyContent">暂无简介</text>
|
|
|
</template>
|
|
</template>
|
|
|
<!-- 图片 -->
|
|
<!-- 图片 -->
|
|
|
- <template v-else-if="tabCurrentId == 1">
|
|
|
|
|
|
|
+ <template v-else-if="tabCurrentId == TAB_ID_IMAGES">
|
|
|
<slot name="imagesPrefix" />
|
|
<slot name="imagesPrefix" />
|
|
|
<ImageGrid
|
|
<ImageGrid
|
|
|
:images="loader.content.value.images"
|
|
:images="loader.content.value.images"
|
|
@@ -66,7 +66,7 @@
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
<!-- 视频 -->
|
|
<!-- 视频 -->
|
|
|
- <template v-else-if="tabCurrentId == 2">
|
|
|
|
|
|
|
+ <template v-else-if="tabCurrentId == TAB_ID_VIDEO">
|
|
|
<video
|
|
<video
|
|
|
v-if="loader.content.value.video"
|
|
v-if="loader.content.value.video"
|
|
|
class="w-100 video"
|
|
class="w-100 video"
|
|
@@ -77,7 +77,7 @@
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
<!-- 音频 -->
|
|
<!-- 音频 -->
|
|
|
- <template v-else-if="tabCurrentId == 3">
|
|
|
|
|
|
|
+ <template v-else-if="tabCurrentId == TAB_ID_AUDIO">
|
|
|
<video
|
|
<video
|
|
|
v-if="loader.content.value.audio"
|
|
v-if="loader.content.value.audio"
|
|
|
class="w-100 video"
|
|
class="w-100 video"
|
|
@@ -106,6 +106,7 @@ import type { GetContentDetailItem } from "@/api/CommonContent";
|
|
|
import { useSimplePageContentLoader } from "@/common/composeabe/SimplePageContentLoader";
|
|
import { useSimplePageContentLoader } from "@/common/composeabe/SimplePageContentLoader";
|
|
|
import { useLoadQuerys } from "@/common/composeabe/LoadQuerys";
|
|
import { useLoadQuerys } from "@/common/composeabe/LoadQuerys";
|
|
|
import { useTabControl, type TabControlItem } from "@/common/composeabe/TabControl";
|
|
import { useTabControl, type TabControlItem } from "@/common/composeabe/TabControl";
|
|
|
|
|
+import { requireNotNull } from "@imengyu/imengyu-utils";
|
|
|
import SimplePageContentLoader from "@/common/components/SimplePageContentLoader.vue";
|
|
import SimplePageContentLoader from "@/common/components/SimplePageContentLoader.vue";
|
|
|
import ImageGrid from "@/pages/parts/ImageGrid.vue";
|
|
import ImageGrid from "@/pages/parts/ImageGrid.vue";
|
|
|
import ImageSwiper from "@/pages/parts/ImageSwiper.vue";
|
|
import ImageSwiper from "@/pages/parts/ImageSwiper.vue";
|
|
@@ -117,9 +118,17 @@ import Tabs from "@/components/nav/Tabs.vue";
|
|
|
import LikeFooter from "@/pages/parts/LikeFooter.vue";
|
|
import LikeFooter from "@/pages/parts/LikeFooter.vue";
|
|
|
import ArticleCorrect from "@/pages/parts/ArticleCorrect.vue";
|
|
import ArticleCorrect from "@/pages/parts/ArticleCorrect.vue";
|
|
|
|
|
|
|
|
|
|
+export interface DetailTabPageTabsArray {
|
|
|
|
|
+ tabsArray: Ref<TabControlItem[]>,
|
|
|
|
|
+ getTabById(id: number): TabControlItem | undefined;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
load: {
|
|
load: {
|
|
|
- type: Function as PropType<(id: number, tabsArray: Ref<TabControlItem[]>) => Promise<GetContentDetailItem>>,
|
|
|
|
|
|
|
+ type: Function as PropType<(
|
|
|
|
|
+ id: number,
|
|
|
|
|
+ tabsArray: DetailTabPageTabsArray
|
|
|
|
|
+ ) => Promise<GetContentDetailItem>>,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
|
extraTabs: {
|
|
extraTabs: {
|
|
@@ -140,16 +149,21 @@ const emptyContent = computed(() => {
|
|
|
return !(loader.content.value?.intro as string || '').trim() && !(loader.content.value?.content || '').trim();
|
|
return !(loader.content.value?.intro as string || '').trim() && !(loader.content.value?.content || '').trim();
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const TAB_ID_INTRO = 0;
|
|
|
|
|
+const TAB_ID_IMAGES = 1;
|
|
|
|
|
+const TAB_ID_VIDEO = 2;
|
|
|
|
|
+const TAB_ID_AUDIO = 3;
|
|
|
|
|
+
|
|
|
const loader = useSimplePageContentLoader<
|
|
const loader = useSimplePageContentLoader<
|
|
|
GetContentDetailItem,
|
|
GetContentDetailItem,
|
|
|
{ id: number }
|
|
{ id: number }
|
|
|
>(async (params) => {
|
|
>(async (params) => {
|
|
|
if (!params)
|
|
if (!params)
|
|
|
throw new Error("!params");
|
|
throw new Error("!params");
|
|
|
- const d = await props.load(params.id, tabsArray);
|
|
|
|
|
- tabsArray.value[1].visible = Boolean(d.images && d.images.length > 1);
|
|
|
|
|
- tabsArray.value[2].visible = Boolean(d.video);
|
|
|
|
|
- tabsArray.value[3].visible = Boolean(d.audio);
|
|
|
|
|
|
|
+ const d = await props.load(params.id, tabsArrayObject);
|
|
|
|
|
+ requireNotNull(tabsArrayObject.getTabById(TAB_ID_IMAGES)).visible = Boolean(d.images && d.images.length > 1);
|
|
|
|
|
+ requireNotNull(tabsArrayObject.getTabById(TAB_ID_VIDEO)).visible = Boolean(d.video);
|
|
|
|
|
+ requireNotNull(tabsArrayObject.getTabById(TAB_ID_AUDIO)).visible = Boolean(d.audio);
|
|
|
|
|
|
|
|
if (d.title)
|
|
if (d.title)
|
|
|
uni.setNavigationBarTitle({ title: d.title });
|
|
uni.setNavigationBarTitle({ title: d.title });
|
|
@@ -172,22 +186,22 @@ const {
|
|
|
} = useTabControl({
|
|
} = useTabControl({
|
|
|
tabs: [
|
|
tabs: [
|
|
|
{
|
|
{
|
|
|
- id: 0,
|
|
|
|
|
|
|
+ id: TAB_ID_INTRO,
|
|
|
text: '简介',
|
|
text: '简介',
|
|
|
visible: true,
|
|
visible: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- id: 1,
|
|
|
|
|
|
|
+ id: TAB_ID_IMAGES,
|
|
|
text: '图片',
|
|
text: '图片',
|
|
|
visible: true,
|
|
visible: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- id: 2,
|
|
|
|
|
|
|
+ id: TAB_ID_VIDEO,
|
|
|
text: '视频',
|
|
text: '视频',
|
|
|
visible: true,
|
|
visible: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- id: 3,
|
|
|
|
|
|
|
+ id: TAB_ID_AUDIO,
|
|
|
text: '音频',
|
|
text: '音频',
|
|
|
visible: true,
|
|
visible: true,
|
|
|
},
|
|
},
|
|
@@ -198,6 +212,13 @@ const {
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const tabsArrayObject : DetailTabPageTabsArray = {
|
|
|
|
|
+ tabsArray,
|
|
|
|
|
+ getTabById(id: number) {
|
|
|
|
|
+ return tabsArray.value.find(t => t.id == id);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
useLoadQuerys({ id : 0 }, (p) => loader.loadData(p));
|
|
useLoadQuerys({ id : 0 }, (p) => loader.loadData(p));
|
|
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|