feat:mock 的对接了首页、分类、商家列表和详情的接口
This commit is contained in:
1 parent
87cf7dfbaa
commit
d723eb1232
20 files changed
+3948
-333
No files matched your search
@@ -15,24 +15,24 @@ import { computed, ref } from "vue";
|
||||
import { goCatalog } from "@/utils/nav";
|
||||
|
||||
const props = defineProps({
|
||||
/** 首页 /v1/homepage 的 entries[i]:section_key / title / subtitle / image_url / image_urls */
|
||||
section: { type: Object, required: true },
|
||||
variant: { type: String, default: "short" },
|
||||
/**
|
||||
* 卡内轮播图集。首页旅居卡传「每个分组一张代表图」(4 张),
|
||||
* 传空则回落为板块封面单图(右二半高卡就是这种)。
|
||||
*/
|
||||
covers: { type: Array, default: () => [] },
|
||||
});
|
||||
|
||||
const isTall = computed(() => props.variant === "tall");
|
||||
|
||||
/** 轮播图集:有 covers 用 covers,否则单张封面 —— 统一成一个数组,模板只判长度 */
|
||||
/** 轮播图集:接口给 image_urls(旅居卡 = 各分类代表图),单张或无则回落 image_url */
|
||||
const images = computed(() => {
|
||||
if (props.covers?.length) return props.covers;
|
||||
return props.section?.coverImage ? [props.section.coverImage] : [];
|
||||
const list = props.section?.image_urls;
|
||||
if (Array.isArray(list) && list.length) return list;
|
||||
return props.section?.image_url ? [props.section.image_url] : [];
|
||||
});
|
||||
/** ≥2 张才起轮播:单张时 swiper 没有意义,还会白白多一层节点 */
|
||||
const hasSlider = computed(() => images.value.length > 1);
|
||||
/**
|
||||
* ≥2 张才起轮播,且**只有通高卡轮播**(首页旅居卡 = 四个住宿分类各一张)。
|
||||
* 右二半高卡保持单图 —— 与设计稿一致,接口即使给了多张也不轮。
|
||||
*/
|
||||
const hasSlider = computed(() => isTall.value && images.value.length > 1);
|
||||
|
||||
const activeIndex = ref(0);
|
||||
/** 取模防越界:图集长度变化(如热更新/接口返回变少)时进度点不会全部熄灭 */
|
||||
@@ -76,7 +76,7 @@ const arrowCls = computed(() =>
|
||||
: "right-3 bottom-3 w-8 h-8 border-[rgba(255,255,255,0.46)]"
|
||||
);
|
||||
|
||||
const onTap = () => goCatalog(props.section.key);
|
||||
const onTap = () => goCatalog(props.section.section_key);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -103,7 +103,7 @@ const onTap = () => goCatalog(props.section.key);
|
||||
<image class="w-full h-full" :src="url" mode="aspectFill" />
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<image v-else class="absolute inset-0 w-full h-full" :src="section.coverImage" mode="aspectFill" />
|
||||
<image v-else class="absolute inset-0 w-full h-full" :src="section.image_url" mode="aspectFill" />
|
||||
|
||||
<!-- 遮罩:文字锚顶部 → 顶部最重 -->
|
||||
<view class="absolute inset-0" :class="isTall ? 'scrim-tile-tall' : 'scrim-tile'" />
|
||||
|
||||
Reference in new issue
Block a user