diff --git a/src/api/content.js b/src/api/content.js index c090d29..fc58229 100644 --- a/src/api/content.js +++ b/src/api/content.js @@ -96,6 +96,21 @@ export const getSectionBannerImages = async (sectionKey) => { return unique(urls.filter(Boolean)).slice(0, 3); }; +/** + * 首页板块卡轮播图集:**每个分组取一张代表图**(组内首个有主图的条目)。 + * 与 getSectionBannerImages 的区别:那个是「组内逐个条目」取前 3 张, + * 可能全落在同一个分组里;首页旅居卡要的是「酒店 / 民宿别院 / 旅居公寓 / 露营基地」 + * 四个分组各一张,张数 = 分组数。 + */ +export const getSectionGroupCovers = async (sectionKey) => { + const section = await getSection(sectionKey); + if (!section) return []; + const urls = section.groups + .map((g) => g.items.find((it) => it.main_image_url)?.main_image_url) + .filter(Boolean); + return unique(urls); +}; + export default { getSections, getSection, @@ -104,4 +119,5 @@ export default { getFeaturedItems, getOverviewMapAsset, getSectionBannerImages, + getSectionGroupCovers, }; diff --git a/src/components/ContentCard/index.vue b/src/components/ContentCard/index.vue index c7cdeb4..9a4a084 100644 --- a/src/components/ContentCard/index.vue +++ b/src/components/ContentCard/index.vue @@ -1,25 +1,21 @@