You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
8.3 KiB

4 months ago
<template>
4 months ago
<view>
<swiper class="main-swiper" :vertical="true" :current="currentIndex" @change="handleSwiperChange" :duration="300">
<swiper-item v-for="(_, outerIndex) in 7" :key="outerIndex">
<swiper class="nested-swiper" :duration="300" @change="handleVerticalChange" :current="nestedIndices[outerIndex]">
<!-- 嵌套swiper的第一个item封面页 -->
<swiper-item>
<view class="page-container home-page">
4 months ago
<image class="bg-image" :src="'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/cover' + (outerIndex+2) + '.png'" mode="" :lazy-load="true"></image>
<image class="cover-txt" :class="{'cover-txt2': outerIndex > 0}" :src="'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/cover' + (outerIndex+2) + '-txt.png'" mode="" :lazy-load="true"></image>
<image class="btn" src="https://static.ticket.sz-trip.com/epicSoul/seek2-btn.png" mode="" :lazy-load="true"></image>
4 months ago
</view>
</swiper-item>
<!-- 嵌套swiper的第二个item-->
<swiper-item>
<view class="page-container home-page">
<view class="gif-container">
4 months ago
<image v-if="shouldLoadContent(outerIndex)" class="gif-style" :src="'https://static.ticket.sz-trip.com/epicSoul/3-' + (outerIndex+1) + '-2.gif'" mode="aspectFill" :lazy-load="true"></image>
4 months ago
</view>
4 months ago
4 months ago
<image class="bg-image" :src="'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/cover' + (outerIndex+2) + '-1.png'" mode="" :lazy-load="true"></image>
4 months ago
<view class="qrcode-content">
4 months ago
<image class="qrCode" src="https://static.ticket.sz-trip.com/epicSoul/qrcode.png" mode="" :lazy-load="true"></image>
4 months ago
<view class="code-txt">
扫码下单
</view>
</view>
</view>
</swiper-item>
</swiper>
</swiper-item>
<swiper-item>
<view class="page-container home-page">
4 months ago
<image class="bg-image" src="https://static.ticket.sz-trip.com/epicSoul/images/chapter3/cover9.png" mode="" :lazy-load="true"></image>
<image @click="goRandomImage" class="cover-txt9" src="https://static.ticket.sz-trip.com/epicSoul/images/chapter3/cover9-txt.png" mode="" :lazy-load="true"></image>
4 months ago
</view>
</swiper-item>
</swiper>
<MusicControl />
</view>
4 months ago
</template>
4 months ago
<script>
export default {
data() {
return {
currentIndex: 0,
// 嵌套swiper索引
nestedIndices: {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0
},
// 当前活跃的页面,用于内容加载判断
activePages: {
mainIndex: 0,
nestedIndices: {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0
}
},
// 预加载缓冲区大小
preloadBuffer: 2
}
},
methods: {
// 主swiper切换事件处理
handleSwiperChange(e) {
this.currentIndex = e.detail.current;
this.activePages.mainIndex = e.detail.current;
},
// 嵌套swiper切换事件处理
handleVerticalChange(e) {
const outerIndex = parseInt(e.target.dataset.index);
this.nestedIndices[outerIndex] = e.detail.current;
this.activePages.nestedIndices[outerIndex] = e.detail.current;
},
goRandomImage() {
const imageArray = [
{
id: 1,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image1.png',
4 months ago
name: '雏菊',
desc: '宋 丛菊图页'
},
{
id: 2,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image2.png',
4 months ago
name: '杜鹃',
desc: '清 恽寿平 花卉十开 杜鹃'
},
{
id: 3,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image3.png',
4 months ago
name: '金桂',
desc: '清 蒋延锡 桂花图 局部 台北故宫博物馆院藏'
},
{
id: 4,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image4.png',
4 months ago
name: '绿梅',
desc: '北宋 赵佶 梅花秀眼图页 北京故宫博物院藏'
},
{
id: 5,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image5.png',
4 months ago
name: '墨兰',
desc: '宋 秋兰绽蕊图'
},
{
id: 6,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image6.png',
4 months ago
name: '茉莉',
desc: '宋 茉莉花图页'
},
{
id: 7,
4 months ago
image: 'https://static.ticket.sz-trip.com/epicSoul/images/chapter3/random/image7.png',
4 months ago
name: '青莲',
desc: '宋 出水芙蓉图页'
},
];
4 months ago
4 months ago
const app = getApp();
app.globalData.randomImages = imageArray;
uni.setStorageSync('randomImages', JSON.stringify(imageArray));
uni.navigateTo({
url: '/xxdf/chapter3/randomImage'
});
},
goback() {
const app = getApp();
app.globalData.mainSliderIndex = 4;
uni.redirectTo({
url: '/xxdf/home/home'
});
}
},
computed: {
shouldLoadContent() {
return (outerIndex) => {
// 当主索引在附近,且嵌套索引是第二页(GIF页)时预加载
return Math.abs(outerIndex - this.currentIndex) <= this.preloadBuffer &&
(this.nestedIndices[outerIndex] === 1 || this.activePages.nestedIndices[outerIndex] === 1);
}
}
},
mounted() {
// 初始化状态
this.currentIndex = 0;
this.activePages.mainIndex = 0;
},
beforeDestroy() {
// 组件销毁前的清理工作(如果有)
}
}
4 months ago
</script>
<style scoped>
4 months ago
.main-swiper {
width: 100%;
height: 100vh;
}
4 months ago
4 months ago
.nested-swiper {
width: 100%;
height: 100vh;
}
4 months ago
4 months ago
.page-container {
height: 100vh;
}
4 months ago
4 months ago
.home-page {
position: relative;
overflow: hidden;
}
4 months ago
4 months ago
.bg-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
4 months ago
4 months ago
.cover-txt {
position: absolute;
left: 50%;
bottom: 22%;
transform: translate(-50%, -50%);
z-index: 2;
width: 74%;
height: 122rpx;
}
4 months ago
4 months ago
.cover-txt2 {
width: 60% !important;
height: 134rpx !important;
}
4 months ago
4 months ago
.cover-txt9 {
position: absolute;
left: 50%;
bottom: 0;
transform: translate(-50%, -20%);
z-index: 2;
width: 360rpx;
height: 280rpx;
}
4 months ago
4 months ago
.btn {
position: absolute;
left: 50%;
bottom: 16%;
transform: translate(-50%, -50%);
z-index: 2;
width: 244rpx;
height: 60rpx;
}
4 months ago
4 months ago
.qrcode-content {
display: flex;
flex-direction: column;
align-items: center;
position: absolute;
left: 50%;
bottom: 0;
transform: translate(-50%, -25%);
z-index: 2;
}
4 months ago
4 months ago
.qrCode {
width: 200rpx;
height: 200rpx;
}
4 months ago
4 months ago
.code-txt {
color: #333;
font-size: 24rpx;
margin-top: 10rpx;
}
4 months ago
4 months ago
.gif-container {
background: #333333;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 400rpx;
z-index: 2;
}
4 months ago
4 months ago
.gif-style {
width: 100%;
height: 100%;
object-fit: cover;
}
4 months ago
</style>