|
|
@ -1,16 +1,15 @@ |
|
|
|
<template> |
|
|
|
<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="(e) => handleVerticalChange(e, outerIndex)" |
|
|
|
:current="nestedIndices[outerIndex]"> |
|
|
|
<swiper class="nested-swiper" :duration="300" @change="handleVerticalChange" :current="nestedIndices[outerIndex]"> |
|
|
|
<!-- 嵌套swiper的第一个item(封面页) --> |
|
|
|
<swiper-item> |
|
|
|
<view class="page-container home-page"> |
|
|
|
<image class="bg-image" :src="`/static/images/chapter3/cover${outerIndex+2}.png`" mode="" |
|
|
|
:lazy-load="true"></image> |
|
|
|
<image class="cover-txt" :class="{'cover-txt2': outerIndex > 0}" |
|
|
|
:src="`/static/images/chapter3/cover${outerIndex+2}-txt.png`" mode="" :lazy-load="true"> |
|
|
|
</image> |
|
|
|
<image class="bg-image" :src="'/static/images/chapter3/cover' + (outerIndex+2) + '.png'" mode="" :lazy-load="true"></image> |
|
|
|
<image class="cover-txt" :class="{'cover-txt2': outerIndex > 0}" :src="'/static/images/chapter3/cover' + (outerIndex+2) + '-txt.png'" mode="" :lazy-load="true"></image> |
|
|
|
<image class="btn" src="/static/seek2-btn.png" mode="" :lazy-load="true"></image> |
|
|
|
</view> |
|
|
|
</swiper-item> |
|
|
@ -18,13 +17,10 @@ |
|
|
|
<swiper-item> |
|
|
|
<view class="page-container home-page"> |
|
|
|
<view class="gif-container"> |
|
|
|
<image v-if="shouldLoadContent(outerIndex)" class="gif-style" |
|
|
|
:src="`/static/3-${outerIndex+1}-2.gif`" mode="aspectFill" :lazy-load="true"> |
|
|
|
</image> |
|
|
|
<image v-if="shouldLoadContent(outerIndex)" class="gif-style" :src="'/static/3-' + (outerIndex+1) + '-2.gif'" mode="aspectFill" :lazy-load="true"></image> |
|
|
|
</view> |
|
|
|
|
|
|
|
<image class="bg-image" :src="`/static/images/chapter3/cover${outerIndex+2}-1.png`" mode="" |
|
|
|
:lazy-load="true"></image> |
|
|
|
<image class="bg-image" :src="'/static/images/chapter3/cover' + (outerIndex+2) + '-1.png'" mode="" :lazy-load="true"></image> |
|
|
|
<view class="qrcode-content"> |
|
|
|
<image class="qrCode" src="/static/qrcode.png" mode="" :lazy-load="true"></image> |
|
|
|
<view class="code-txt"> |
|
|
@ -38,28 +34,21 @@ |
|
|
|
<swiper-item> |
|
|
|
<view class="page-container home-page"> |
|
|
|
<image class="bg-image" src="/static/images/chapter3/cover9.png" mode="" :lazy-load="true"></image> |
|
|
|
<image @click="goRandomImage" class="cover-txt9" src="/static/images/chapter3/cover9-txt.png" mode="" |
|
|
|
:lazy-load="true"></image> |
|
|
|
<image @click="goRandomImage" class="cover-txt9" src="/static/images/chapter3/cover9-txt.png" mode="" :lazy-load="true"></image> |
|
|
|
</view> |
|
|
|
</swiper-item> |
|
|
|
</swiper> |
|
|
|
<MusicControl /> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { |
|
|
|
ref, |
|
|
|
reactive, |
|
|
|
onMounted, |
|
|
|
onUnmounted, |
|
|
|
watch, |
|
|
|
computed |
|
|
|
} from 'vue'; |
|
|
|
|
|
|
|
const currentIndex = ref(0); |
|
|
|
|
|
|
|
<script> |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
currentIndex: 0, |
|
|
|
// 嵌套swiper索引 |
|
|
|
const nestedIndices = reactive({ |
|
|
|
nestedIndices: { |
|
|
|
0: 0, |
|
|
|
1: 0, |
|
|
|
2: 0, |
|
|
@ -67,10 +56,9 @@ |
|
|
|
4: 0, |
|
|
|
5: 0, |
|
|
|
6: 0 |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
// 当前活跃的页面,用于内容加载判断 |
|
|
|
const activePages = reactive({ |
|
|
|
activePages: { |
|
|
|
mainIndex: 0, |
|
|
|
nestedIndices: { |
|
|
|
0: 0, |
|
|
@ -81,31 +69,28 @@ |
|
|
|
5: 0, |
|
|
|
6: 0 |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
// 预加载缓冲区大小 |
|
|
|
const preloadBuffer = 2; |
|
|
|
|
|
|
|
const shouldLoadContent = (outerIndex) => { |
|
|
|
// 当主索引在附近,且嵌套索引是第二页(GIF页)时预加载 |
|
|
|
return Math.abs(outerIndex - currentIndex.value) <= preloadBuffer && |
|
|
|
(nestedIndices[outerIndex] === 1 || activePages.nestedIndices[outerIndex] === 1); |
|
|
|
}; |
|
|
|
|
|
|
|
preloadBuffer: 2 |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 主swiper切换事件处理 |
|
|
|
const handleSwiperChange = (e) => { |
|
|
|
currentIndex.value = e.detail.current; |
|
|
|
activePages.mainIndex = e.detail.current; |
|
|
|
}; |
|
|
|
handleSwiperChange(e) { |
|
|
|
this.currentIndex = e.detail.current; |
|
|
|
this.activePages.mainIndex = e.detail.current; |
|
|
|
}, |
|
|
|
|
|
|
|
// 嵌套swiper切换事件处理 |
|
|
|
const handleVerticalChange = (e, outerIndex) => { |
|
|
|
nestedIndices[outerIndex] = e.detail.current; |
|
|
|
activePages.nestedIndices[outerIndex] = e.detail.current; |
|
|
|
}; |
|
|
|
handleVerticalChange(e) { |
|
|
|
const outerIndex = parseInt(e.target.dataset.index); |
|
|
|
this.nestedIndices[outerIndex] = e.detail.current; |
|
|
|
this.activePages.nestedIndices[outerIndex] = e.detail.current; |
|
|
|
}, |
|
|
|
|
|
|
|
const goRandomImage = () => { |
|
|
|
const imageArray = [{ |
|
|
|
goRandomImage() { |
|
|
|
const imageArray = [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
image: '/static/images/chapter3/random/image1.png', |
|
|
|
name: '雏菊', |
|
|
@ -153,55 +138,68 @@ |
|
|
|
app.globalData.randomImages = imageArray; |
|
|
|
uni.setStorageSync('randomImages', JSON.stringify(imageArray)); |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/chapter3/randomImage' |
|
|
|
url: '/xxdf/chapter3/randomImage' |
|
|
|
}); |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
const goback = () => { |
|
|
|
goback() { |
|
|
|
const app = getApp(); |
|
|
|
app.globalData.mainSliderIndex = 4; |
|
|
|
uni.redirectTo({ |
|
|
|
url: '/pages/home/home' |
|
|
|
url: '/xxdf/home/home' |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
shouldLoadContent() { |
|
|
|
return (outerIndex) => { |
|
|
|
// 当主索引在附近,且嵌套索引是第二页(GIF页)时预加载 |
|
|
|
return Math.abs(outerIndex - this.currentIndex) <= this.preloadBuffer && |
|
|
|
(this.nestedIndices[outerIndex] === 1 || this.activePages.nestedIndices[outerIndex] === 1); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
// 初始化状态 |
|
|
|
currentIndex.value = 0; |
|
|
|
activePages.mainIndex = 0; |
|
|
|
}); |
|
|
|
this.currentIndex = 0; |
|
|
|
this.activePages.mainIndex = 0; |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
// 组件销毁前的清理工作(如果有) |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.main-swiper { |
|
|
|
.main-swiper { |
|
|
|
width: 100%; |
|
|
|
height: 100vh; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.nested-swiper { |
|
|
|
.nested-swiper { |
|
|
|
width: 100%; |
|
|
|
height: 100vh; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.page-container { |
|
|
|
.page-container { |
|
|
|
height: 100vh; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.home-page { |
|
|
|
.home-page { |
|
|
|
position: relative; |
|
|
|
overflow: hidden; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.bg-image { |
|
|
|
.bg-image { |
|
|
|
position: absolute; |
|
|
|
top: 0; |
|
|
|
left: 0; |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
z-index: 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.cover-txt { |
|
|
|
.cover-txt { |
|
|
|
position: absolute; |
|
|
|
left: 50%; |
|
|
|
bottom: 22%; |
|
|
@ -209,14 +207,14 @@ |
|
|
|
z-index: 2; |
|
|
|
width: 74%; |
|
|
|
height: 122rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.cover-txt2 { |
|
|
|
.cover-txt2 { |
|
|
|
width: 60% !important; |
|
|
|
height: 134rpx !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.cover-txt9 { |
|
|
|
.cover-txt9 { |
|
|
|
position: absolute; |
|
|
|
left: 50%; |
|
|
|
bottom: 0; |
|
|
@ -224,9 +222,9 @@ |
|
|
|
z-index: 2; |
|
|
|
width: 360rpx; |
|
|
|
height: 280rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.btn { |
|
|
|
.btn { |
|
|
|
position: absolute; |
|
|
|
left: 50%; |
|
|
|
bottom: 16%; |
|
|
@ -234,9 +232,9 @@ |
|
|
|
z-index: 2; |
|
|
|
width: 244rpx; |
|
|
|
height: 60rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.qrcode-content { |
|
|
|
.qrcode-content { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
align-items: center; |
|
|
@ -245,20 +243,20 @@ |
|
|
|
bottom: 0; |
|
|
|
transform: translate(-50%, -25%); |
|
|
|
z-index: 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.qrCode { |
|
|
|
.qrCode { |
|
|
|
width: 200rpx; |
|
|
|
height: 200rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.code-txt { |
|
|
|
.code-txt { |
|
|
|
color: #333; |
|
|
|
font-size: 24rpx; |
|
|
|
margin-top: 10rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.gif-container { |
|
|
|
.gif-container { |
|
|
|
background: #333333; |
|
|
|
position: absolute; |
|
|
|
top: 0; |
|
|
@ -266,11 +264,11 @@ |
|
|
|
width: 100%; |
|
|
|
height: 400rpx; |
|
|
|
z-index: 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.gif-style { |
|
|
|
.gif-style { |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
object-fit: cover; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |