Commit c77bfa10 by 胡悦

feat(home): 将自动驾驶页面轮播图替换为3D相册效果

- 移除 Element UI 的 el-carousel 组件,实现自定义 3D 轮播轨道
- 添加 3D 透视、旋转、缩放及层级效果,提升视觉体验
- 实现自动播放、鼠标悬停暂停及指示器点击切换功能
- 优化交互细节,包括激活状态高亮和过渡动画
1 parent 54b5b9f3
......@@ -7,12 +7,46 @@
-->
<template>
<div class="view-content">
<div class="content">
<el-carousel height="70vh" :interval="4000" arrow="never" indicator-position="outside">
<el-carousel-item v-for="(item, index) in imageList" :key="index">
<img :src="item" alt="" class="carousel-img">
</el-carousel-item>
</el-carousel>
<div class="carousel-container" ref="carouselContainer">
<!-- 3D 相册轨道 -->
<div class="slide-track" ref="slideTrack">
<div
v-for="(item, index) in imageList"
:key="index"
class="slide-item"
:class="{ active: index === currentIndex }"
:style="getSlideStyle(index)"
@click="goToSlide(index)"
>
<img :src="item" alt="" class="slide-img">
<div class="grid-overlay"></div>
<div class="glass-reflection"></div>
<div class="gradient-overlay"></div>
</div>
</div>
<!-- 指示器 -->
<div class="indicators">
<button
v-for="(item, index) in imageList"
:key="index"
class="indicator-dot"
:class="{ active: index === currentIndex }"
@click="goToSlide(index)"
></button>
</div>
<!-- 左右切换按钮 -->
<!-- <button class="control-btn prev-btn" @click="prevSlide">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" />
</svg>
</button>
<button class="control-btn next-btn" @click="nextSlide">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
</svg>
</button> -->
</div>
</div>
</template>
......@@ -28,12 +62,95 @@ export default {
'https://img02.glsx.com.cn/weapp/resource/saas/images/auto-3.png',
'https://img02.glsx.com.cn/weapp/resource/saas/images/auto-4.png',
// 'https://img02.glsx.com.cn/weapp/resource/saas/images/auto-5.png'
]
],
currentIndex: 0,
autoPlayTimer: null,
playInterval: 4000
}
},
created() {},
mounted() {},
methods: {}
mounted() {
this.startAutoPlay()
this.$refs.carouselContainer.addEventListener('mouseenter', this.stopAutoPlay)
this.$refs.carouselContainer.addEventListener('mouseleave', this.startAutoPlay)
},
beforeDestroy() {
this.stopAutoPlay()
},
methods: {
getSlideStyle(index) {
const total = this.imageList.length
let distance = index - this.currentIndex
// 计算环形数组中的最短距离
if (distance > Math.floor(total / 2)) distance -= total
if (distance < -Math.floor(total / 2)) distance += total
if (distance === 0) {
// 当前激活图:居中、最大、不旋转、高亮发光
return {
transform: 'translateX(0%) translateZ(120px) rotateY(0deg) scale(1.35)',
opacity: '1',
zIndex: '30',
filter: 'brightness(1.1)'
}
} else if (distance === -1) {
// 左侧上一张
return {
transform: 'translateX(-65%) translateZ(-100px) rotateY(20deg) scale(0.95)',
opacity: '0.85',
zIndex: '20',
filter: 'brightness(0.6)'
}
} else if (distance === 1) {
// 右侧下一张
return {
transform: 'translateX(65%) translateZ(-100px) rotateY(-20deg) scale(0.95)',
opacity: '0.85',
zIndex: '20',
filter: 'brightness(0.6)'
}
} else {
// 更远处的卡片
const sign = Math.sign(distance)
return {
transform: `translateX(${sign * 70}%) translateZ(-250px) rotateY(${sign * -35}deg) scale(0.8)`,
opacity: '0.1',
zIndex: '10',
filter: 'brightness(0.3)'
}
}
},
goToSlide(index) {
if (index === this.currentIndex) return
this.currentIndex = index
this.resetAutoPlay()
},
nextSlide() {
let target = this.currentIndex + 1
if (target >= this.imageList.length) target = 0
this.goToSlide(target)
},
prevSlide() {
let target = this.currentIndex - 1
if (target < 0) target = this.imageList.length - 1
this.goToSlide(target)
},
startAutoPlay() {
if (!this.autoPlayTimer) {
this.autoPlayTimer = setInterval(this.nextSlide, this.playInterval)
}
},
stopAutoPlay() {
if (this.autoPlayTimer) {
clearInterval(this.autoPlayTimer)
this.autoPlayTimer = null
}
},
resetAutoPlay() {
this.stopAutoPlay()
this.startAutoPlay()
}
}
}
</script>
......@@ -42,46 +159,145 @@ export default {
width: 90%;
margin: 0 auto;
height: 100%;
margin-top: 100px;
// margin-top: 20%;
// transform: translateY(-50%);
// margin-top: 100px;
position: relative;
}
.carousel-container {
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transform-style: preserve-3d;
perspective: 1200px;
}
.slide-track {
position: relative;
width: 100%;
max-width: 900px;
aspect-ratio: 2/1;
transform-style: preserve-3d;
}
.slide-item {
position: absolute;
inset: 0;
// border-radius: 20px;
cursor: pointer;
transition: all 0.7s cubic-bezier(0.25, 0.8, 0.25, 1);
overflow: hidden;
&.active {
// box-shadow: 0 0 40px rgba(0, 243, 255, 0.3);
}
}
.carousel-img {
.slide-img {
width: 100%;
height: 100%;
object-fit: contain;
// border-radius: 12px;
// border: 2px solid rgba(0, 200, 255, 0.5);
// box-shadow: 0 0 20px rgba(0, 200, 255, 0.3);
}
/deep/ {
.el-carousel__arrow--left {
left: 20px;
.grid-overlay {
position: absolute;
inset: 0;
opacity: 0.3;
// background-image: radial-gradient(#00f3ff 1px, transparent 1px);
background-size: 40px 40px;
pointer-events: none;
}
.glass-reflection {
position: absolute;
inset: 0;
// background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 40%);
z-index: 10;
pointer-events: none;
}
.gradient-overlay {
position: absolute;
inset-x: 0;
bottom: 0;
height: 33%;
// background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
pointer-events: none;
z-index: 5;
}
.indicators {
position: absolute;
bottom: 60px;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
gap: 12px;
z-index: 40;
}
.indicator-dot {
height: 8px;
width: 12px;
background: rgba(255, 255, 255, 0.3);
border: none;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s;
padding: 0;
&:hover {
background: rgba(255, 255, 255, 0.6);
}
.el-carousel__arrow--right {
right: 20px;
&.active {
width: 40px;
background: #00f3ff;
box-shadow: 0 0 10px #00f3ff;
}
}
.el-carousel__arrow {
width: 50px;
height: 50px;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 50%;
transition: all 0.3s;
border: 2px solid rgba(0, 200, 255, 0.5);
&:hover {
background-color: rgba(0, 200, 255, 0.8);
border-color: rgba(0, 200, 255, 1);
}
.control-btn {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 56px;
height: 56px;
border-radius: 50%;
background: rgba(15, 70, 100, 0.6);
backdrop-filter: blur(8px);
border: 1px solid rgba(0, 243, 255, 0.5);
color: #00f3ff;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s;
z-index: 50;
i {
font-size: 24px;
color: #fff;
}
svg {
width: 28px;
height: 28px;
}
&:hover {
background: rgba(0, 243, 255, 0.3);
border-color: rgba(0, 243, 255, 0.8);
transform: translateY(-50%) scale(1.1);
box-shadow: 0 0 25px rgba(0, 243, 255, 0.6);
}
}
.prev-btn {
left: 30px;
}
.next-btn {
right: 30px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!