topfans/frontend/pages/square/components/BannerCarousel.vue
2026-05-11 17:56:16 +08:00

78 lines
1.7 KiB
Vue

<template>
<view class="banner-carousel" @click.stop>
<swiper
class="banner-swiper"
:autoplay="true"
:interval="4000"
:duration="400"
:circular="true"
:indicator-dots="false"
@change="onSwiperChange"
>
<swiper-item @click.stop="$emit('top3Click')" style="display: flex;
align-items: center;">
<BannerTop3 @dataLoaded="onTop3DataLoaded" @top3Click="$emit('top3Click')" />
</swiper-item>
<swiper-item
v-for="item in bannerActivities"
:key="item.id"
@click.stop="$emit('activityClick', item)"
>
<image
class="banner-activity-img"
:src="item.cover_image || '/static/avatar/1.jpeg'"
mode="aspectFill"
/>
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import { ref } from 'vue'
import BannerTop3 from '../../components/BannerTop3.vue'
defineProps({
bannerActivities: { type: Array, default: () => [] }
})
defineEmits(['activityClick', 'top3Click'])
const currentIndex = ref(0)
const onSwiperChange = (e) => {
currentIndex.value = e.detail.current
}
const onTop3DataLoaded = (items) => {
// 数据已由 BannerTop3 内部处理,这里可以做一些额外操作
console.log('[BannerCarousel] top3 data loaded', items)
}
</script>
<style scoped>
.banner-carousel {
position: relative;
width: 100%;
z-index: 100;
padding: 0 8rpx;
box-sizing: border-box;
}
.banner-swiper {
width: 100%;
height: 392rpx;
border-radius: 24rpx;
position: relative;
bottom: 24rpx;
}
.banner-activity-img {
width: 100%;
height: 328rpx;
display: block;
border-radius:24rpx;
position: relative;
top: 32rpx;
}
</style>