|
@@ -9,7 +9,10 @@
|
|
|
moreText="更多"
|
|
moreText="更多"
|
|
|
@clickMore="category.morePage"
|
|
@clickMore="category.morePage"
|
|
|
/>
|
|
/>
|
|
|
- <SimplePageContentLoader :loader="category.data" >
|
|
|
|
|
|
|
+ <template v-if="category.type === 'CalendarBlock'">
|
|
|
|
|
+ <CalendarBlock />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <SimplePageContentLoader v-else-if="category.data" :loader="category.data" >
|
|
|
<FlexCol>
|
|
<FlexCol>
|
|
|
<template v-if="category.type === 'article'">
|
|
<template v-if="category.type === 'article'">
|
|
|
<Box2LineRightShadow
|
|
<Box2LineRightShadow
|
|
@@ -40,6 +43,39 @@
|
|
|
</FlexRow>
|
|
</FlexRow>
|
|
|
</scroll-view>
|
|
</scroll-view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template v-else-if="category.type === 'horizontal-large'">
|
|
|
|
|
+ <scroll-view scroll-x>
|
|
|
|
|
+ <view class="pb-3 pt-3 d-flex flex-row overflow-visible align-stretch">
|
|
|
|
|
+ <Box2LineLargeImageUserShadow
|
|
|
|
|
+ v-for="(item, i) in category.data.content.value"
|
|
|
|
|
+ classNames="width-2-3 mr-2"
|
|
|
|
|
+ titleColor="title-text"
|
|
|
|
|
+ title1
|
|
|
|
|
+ fixSize
|
|
|
|
|
+ :key="i"
|
|
|
|
|
+ :title="item.title"
|
|
|
|
|
+ :desc="item.desc"
|
|
|
|
|
+ :image="item.thumbnail || item.image"
|
|
|
|
|
+ @click="category.detailPage(item)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </scroll-view>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-else-if="category.type === 'large-grid2'">
|
|
|
|
|
+ <FlexRow wrap align="stretch" justify="space-between" overflow="visible">
|
|
|
|
|
+ <Box2LineLargeImageUserShadow
|
|
|
|
|
+ v-for="(item, i) in category.data.content.value"
|
|
|
|
|
+ titleColor="title-text"
|
|
|
|
|
+ width="calc(50% - 10rpx)"
|
|
|
|
|
+ fixSize
|
|
|
|
|
+ :key="i"
|
|
|
|
|
+ :title="item.title"
|
|
|
|
|
+ :desc="item.desc"
|
|
|
|
|
+ :image="item.image"
|
|
|
|
|
+ @click="category.detailPage(item)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </FlexRow>
|
|
|
|
|
+ </template>
|
|
|
<template v-else>
|
|
<template v-else>
|
|
|
<Box2LineImageRightShadow
|
|
<Box2LineImageRightShadow
|
|
|
v-for="(item, i) in category.data.content.value"
|
|
v-for="(item, i) in category.data.content.value"
|
|
@@ -60,24 +96,25 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">;
|
|
<script setup lang="ts">;
|
|
|
|
|
+import { type PropType } from 'vue';
|
|
|
|
|
+import { CommonContentApi, GetContentListItem, GetContentListParams } from '@/api/CommonContent';
|
|
|
|
|
+import { navCommonDetail, navCommonList, resolveCommonContentFormData, resolveCommonContentGetPageDetailUrlAuto, useHomeCommonCategoryBlock, type HomeCommonCategoryBlockProps, type IHomeCommonCategoryBlock } from './CommonContent';
|
|
|
|
|
+import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
|
|
|
|
|
+import { navTo } from '@/components/utils/PageAction';
|
|
|
|
|
+import { DateUtils } from '@imengyu/imengyu-utils';
|
|
|
import HomeTitle from '@/pages/parts/HomeTitle.vue';
|
|
import HomeTitle from '@/pages/parts/HomeTitle.vue';
|
|
|
import SimplePageContentLoader from '@/common/components/SimplePageContentLoader.vue';
|
|
import SimplePageContentLoader from '@/common/components/SimplePageContentLoader.vue';
|
|
|
import Box2LineImageRightShadow from '@/pages/parts/Box2LineImageRightShadow.vue';
|
|
import Box2LineImageRightShadow from '@/pages/parts/Box2LineImageRightShadow.vue';
|
|
|
import Box2LineRightShadow from '@/pages/parts/Box2LineRightShadow.vue';
|
|
import Box2LineRightShadow from '@/pages/parts/Box2LineRightShadow.vue';
|
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
|
-import type { PropType } from 'vue';
|
|
|
|
|
-import { CommonContentApi, GetContentListItem, GetContentListParams } from '@/api/CommonContent';
|
|
|
|
|
-import { navCommonDetail, navCommonList, resolveCommonContentFormData, resolveCommonContentGetPageDetailUrlAuto, type IHomeCommonCategoryBlock } from './CommonContent';
|
|
|
|
|
-import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
|
|
|
|
|
-import { navTo } from '@/components/utils/PageAction';
|
|
|
|
|
-import { DateUtils } from '@imengyu/imengyu-utils';
|
|
|
|
|
import FlexRow from '@/components/layout/FlexRow.vue';
|
|
import FlexRow from '@/components/layout/FlexRow.vue';
|
|
|
|
|
+import CalendarBlock from '@/pages/travel/calendar/block.vue';
|
|
|
import Box2LineLargeImageUserShadow from '@/pages/parts/Box2LineLargeImageUserShadow.vue';
|
|
import Box2LineLargeImageUserShadow from '@/pages/parts/Box2LineLargeImageUserShadow.vue';
|
|
|
|
|
|
|
|
export interface CategoryDefine {
|
|
export interface CategoryDefine {
|
|
|
title: string;
|
|
title: string;
|
|
|
- content: CommonContentApi|IHomeCommonCategoryBlock;
|
|
|
|
|
- type?: 'article'|'large-image2'|''|undefined;
|
|
|
|
|
|
|
+ content: CommonContentApi|IHomeCommonCategoryBlock|HomeCommonCategoryBlockProps|null;
|
|
|
|
|
+ type?: 'article'|'large-image2'|'horizontal-large'|'large-grid2'|'CalendarBlock'|undefined;
|
|
|
detailPage?: string;
|
|
detailPage?: string;
|
|
|
morePage?: string;
|
|
morePage?: string;
|
|
|
noFrom?: boolean;
|
|
noFrom?: boolean;
|
|
@@ -85,61 +122,86 @@ export interface CategoryDefine {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分类定义。仅支持初始化后立即使用,后续修改不会生效。
|
|
|
|
|
+ */
|
|
|
categoryDefine: {
|
|
categoryDefine: {
|
|
|
type: Array as PropType<CategoryDefine[]>,
|
|
type: Array as PropType<CategoryDefine[]>,
|
|
|
default: () => [],
|
|
default: () => [],
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const categoryDatas = props.categoryDefine.map(item => ({
|
|
|
|
|
- ...item,
|
|
|
|
|
- detailPage: (dataItem: GetContentListItem) => {
|
|
|
|
|
- const id = dataItem.id;
|
|
|
|
|
- if (item.content instanceof CommonContentApi) {
|
|
|
|
|
- if (item.detailPage) {
|
|
|
|
|
- if (item.detailPage === 'byContent')
|
|
|
|
|
- navTo(resolveCommonContentGetPageDetailUrlAuto(dataItem), { id });
|
|
|
|
|
|
|
+const categoryDatas = props.categoryDefine.map(item => {
|
|
|
|
|
+ if (!item.content)
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ detailPage: () => {},
|
|
|
|
|
+ morePage: () => {
|
|
|
|
|
+ if (item.morePage) {
|
|
|
|
|
+ navTo(item.morePage, {});
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ data: null,
|
|
|
|
|
+ };
|
|
|
|
|
+ if (item.content instanceof CommonContentApi) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ detailPage: (dataItem: GetContentListItem) => {
|
|
|
|
|
+ const id = dataItem.id;
|
|
|
|
|
+ const content = item.content as CommonContentApi;
|
|
|
|
|
+ if (item.detailPage) {
|
|
|
|
|
+ if (item.detailPage === 'byContent')
|
|
|
|
|
+ navTo(resolveCommonContentGetPageDetailUrlAuto(dataItem), { id });
|
|
|
|
|
+ else
|
|
|
|
|
+ navTo(item.detailPage, { id });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ navCommonDetail({
|
|
|
|
|
+ id,
|
|
|
|
|
+ mainBodyColumnId: content.mainBodyColumnId,
|
|
|
|
|
+ modelId: content.modelId,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ morePage: () => {
|
|
|
|
|
+ const content = item.content as CommonContentApi;
|
|
|
|
|
+ if (item.morePage) {
|
|
|
|
|
+ navTo(item.morePage, {});
|
|
|
|
|
+ } else {
|
|
|
|
|
+ navCommonList({
|
|
|
|
|
+ title: item.title,
|
|
|
|
|
+ mainBodyColumnId: content.mainBodyColumnId,
|
|
|
|
|
+ modelId: content.modelId,
|
|
|
|
|
+ detailsPage: item.detailPage,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ data: useSimpleDataLoader(async () => {
|
|
|
|
|
+ let res = (await (item.content as CommonContentApi)
|
|
|
|
|
+ .getContentList(new GetContentListParams(), 1, 3))
|
|
|
|
|
+ .list;
|
|
|
|
|
+ if (!item.noFrom)
|
|
|
|
|
+ res = resolveCommonContentFormData(res);
|
|
|
else
|
|
else
|
|
|
- navTo(item.detailPage, { id });
|
|
|
|
|
- } else {
|
|
|
|
|
- navCommonDetail({
|
|
|
|
|
- id,
|
|
|
|
|
- mainBodyColumnId: item.content.mainBodyColumnId,
|
|
|
|
|
- modelId: item.content.modelId,
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- item.content.goDetail(dataItem);
|
|
|
|
|
|
|
+ res.forEach(p => {
|
|
|
|
|
+ if (!p.desc)
|
|
|
|
|
+ p.desc = DateUtils.formatDate(p.publishAt, 'YYYY-MM-dd');
|
|
|
|
|
+ })
|
|
|
|
|
+ return res;
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- morePage: () => {
|
|
|
|
|
- if (item.content instanceof CommonContentApi) {
|
|
|
|
|
- if (item.morePage) {
|
|
|
|
|
- navTo(item.morePage, {});
|
|
|
|
|
- } else {
|
|
|
|
|
- navCommonList({
|
|
|
|
|
- title: item.title,
|
|
|
|
|
- mainBodyColumnId: item.content.mainBodyColumnId,
|
|
|
|
|
- modelId: item.content.modelId,
|
|
|
|
|
- detailsPage: item.detailPage,
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- item.content.goList();
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const block = item.content.type === 'CommonCategoryBlock' ?
|
|
|
|
|
+ item.content :
|
|
|
|
|
+ useHomeCommonCategoryBlock({
|
|
|
|
|
+ ...item.content,
|
|
|
|
|
+ resolveData: item.noFrom ? undefined : resolveCommonContentFormData,
|
|
|
|
|
+ });
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ detailPage: block.goDetail,
|
|
|
|
|
+ morePage: block.goList,
|
|
|
|
|
+ data: block.loader,
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- data: item.content instanceof CommonContentApi ? useSimpleDataLoader(async () => {
|
|
|
|
|
- let res = (await (item.content as CommonContentApi)
|
|
|
|
|
- .getContentList(new GetContentListParams(), 1, 3))
|
|
|
|
|
- .list;
|
|
|
|
|
- if (!item.noFrom)
|
|
|
|
|
- res = resolveCommonContentFormData(res);
|
|
|
|
|
- else
|
|
|
|
|
- res.forEach(p => {
|
|
|
|
|
- if (!p.desc)
|
|
|
|
|
- p.desc = DateUtils.formatDate(p.publishAt, 'YYYY-MM-dd');
|
|
|
|
|
- })
|
|
|
|
|
- return res;
|
|
|
|
|
- }) : item.content.loader,
|
|
|
|
|
-}));
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|