Compare commits

...

2 Commits

Author SHA1 Message Date
Wenzhe e7cc71d841 v1.2.9
1、结束页按钮间隔位置样式调整
2、首页滑动提示修改
3、bgm播放、鼓声播放、视频播放需要相互停止,保证同一时间内只有一种声音在播放
2026-02-04 21:27:25 +08:00
Wenzhe 3ed1978442 v1.2.8
1、loading页增加背景颜色,同时压缩loading_bg图片
2、点击开始按钮时,检测并进行音乐播放
3、调整视频播放关闭按钮位置
2026-02-04 14:54:29 +08:00
11 changed files with 268 additions and 72 deletions

View File

@ -23,7 +23,7 @@ const props = defineProps({
})
//
const emit = defineEmits(['collect-seal'])
const emit = defineEmits(['collect-seal', 'video-open', 'video-close'])
//
const sealCollected = ref(false)
@ -67,11 +67,13 @@ const openWebview = () => {
//
const openVideoPlayer = () => {
showVideoPlayer.value = true
emit('video-open')
}
//
const closeVideoPlayer = () => {
showVideoPlayer.value = false
emit('video-close')
}
//

View File

@ -23,7 +23,7 @@ const props = defineProps({
}
})
const emit = defineEmits(['collect-seal'])
const emit = defineEmits(['collect-seal', 'video-open', 'video-close'])
// sq3
const sq3ImageVisible = ref(false)
@ -478,11 +478,13 @@ const resetDuckPosition = () => {
//
const openVideoPlayer = () => {
showVideoPlayer.value = true
emit('video-open')
}
//
const closeVideoPlayer = () => {
showVideoPlayer.value = false
emit('video-close')
}
//

View File

@ -293,11 +293,14 @@ onMounted(() => {
.end-buttons {
display: flex;
gap: 20px;
justify-content: center;
margin-bottom: 60px;
}
.end-buttons .function-image:not(:last-child) {
margin-right: 20px;
}
.function-btn {
cursor: pointer;
width: 306rpx;

View File

@ -137,6 +137,7 @@ onMounted(() => {
align-items: center;
justify-content: center;
z-index: 9999;
background-color: #fd4336;
}
.loading-bg {

View File

@ -25,7 +25,7 @@ const props = defineProps({
})
//
const emit = defineEmits(['collect-seal'])
const emit = defineEmits(['collect-seal', 'video-open', 'video-close'])
// sq3
const sq3ImageVisible = ref(false)
@ -108,11 +108,13 @@ const closeGallery = () => {
//
const openVideoPlayer = () => {
showVideoPlayer.value = true
emit('video-open')
}
//
const closeVideoPlayer = () => {
showVideoPlayer.value = false
emit('video-close')
}
//

View File

@ -19,19 +19,28 @@ const props = defineProps({
videoUrl: {
type: String,
default: ''
},
// BGM
isMusicPlaying: {
type: Boolean,
default: false
}
})
//
const emit = defineEmits(['collect-seal', 'height-changed'])
const emit = defineEmits(['collect-seal', 'height-changed', 'video-open', 'video-close', 'pause-bgm', 'resume-bgm'])
//
const sealCollected = ref(false)
//
const isMusicPlaying = ref(false)
//
const musicPlayer = ref(null)
//
const isDrumPlaying = ref(false)
const drumPlayer = ref(null)
const wasBgPlayingBeforeDrum = ref(false)
//
const sq1ImageVisible = ref(false)
//
@ -79,7 +88,7 @@ const parallaxOffset = computed(() => {
return offset
})
// /
// /
const toggleMusic = () => {
//
if (!sealCollected.value) {
@ -88,38 +97,48 @@ const toggleMusic = () => {
emit('collect-seal')
}
if (!musicPlayer.value) {
//
musicPlayer.value = uni.createInnerAudioContext()
const bgmUrl = new URL('/static/music/bgm1.mp3', import.meta.url)
musicPlayer.value.src = bgmUrl.href
musicPlayer.value.loop = false
if (!drumPlayer.value) {
//
drumPlayer.value = uni.createInnerAudioContext()
const drumUrl = new URL('/static/music/bgm1.mp3', import.meta.url)
drumPlayer.value.src = drumUrl.href
drumPlayer.value.loop = false
//
musicPlayer.value.onEnded(() => {
isMusicPlaying.value = false
drumPlayer.value.onEnded(() => {
isDrumPlaying.value = false
// BGM
emit('resume-bgm')
})
//
musicPlayer.value.onError((err) => {
console.error('音乐播放失败:', err)
isMusicPlaying.value = false
showToast({
message: '音乐播放失败',
icon: 'error',
drumPlayer.value.onError((err) => {
console.error('鼓声播放失败:', err)
isDrumPlaying.value = false
// BGM
emit('resume-bgm')
uni.showToast({
title: '鼓声播放失败',
icon: 'none',
duration: 1500
})
})
}
if (isMusicPlaying.value) {
if (isDrumPlaying.value) {
//
musicPlayer.value.stop()
isMusicPlaying.value = false
drumPlayer.value.stop()
isDrumPlaying.value = false
// BGM
emit('resume-bgm')
} else {
//
musicPlayer.value.play()
isMusicPlaying.value = true
// BGM
wasBgPlayingBeforeDrum.value = props.isMusicPlaying
// BGM
emit('pause-bgm')
//
drumPlayer.value.play()
isDrumPlaying.value = true
}
}
@ -155,12 +174,23 @@ const calculateHeight = () => {
//
const openVideoPlayer = () => {
//
if (isDrumPlaying.value && drumPlayer.value) {
drumPlayer.value.stop()
isDrumPlaying.value = false
drumPlayer.value.destroy()
drumPlayer.value = null
// BGM
emit('resume-bgm')
}
showVideoPlayer.value = true
emit('video-open')
}
//
const closeVideoPlayer = () => {
showVideoPlayer.value = false
emit('video-close')
}
//
@ -170,6 +200,11 @@ onUnmounted(() => {
musicPlayer.value.destroy()
musicPlayer.value = null
}
if (drumPlayer.value) {
drumPlayer.value.stop()
drumPlayer.value.destroy()
drumPlayer.value = null
}
})
</script>
@ -181,22 +216,13 @@ onUnmounted(() => {
<img src="/static/bg/bg1.jpg" alt="前门商圈" class="background-image" />
</div>
<!-- 增强动效层 -->
<div class="enhancement-layer">
<!-- 灯笼增强动效 -->
<div class="lanterns">
<div class="lantern left-lantern">🏮</div>
<div class="lantern right-lantern">🏮</div>
</div>
</div>
<!-- 音乐控制按钮 -->
<div class="music-control" @click="toggleMusic">
<img
:src="isMusicPlaying ? '/static/images/icon_music2.png' : '/static/images/icon_music1.png'"
:src="isDrumPlaying ? '/static/images/icon_music2.png' : '/static/images/icon_music1.png' "
alt="音乐控制"
class="music-icon"
:class="{ 'playing': isMusicPlaying }"
:class="{ 'playing': isDrumPlaying }"
/>
</div>

View File

@ -117,6 +117,10 @@ const scenes = ref([
const sceneInteractiveStates = ref(scenes.value.map(() => false))
//
const sealCollectedStates = ref(scenes.value.map(() => false))
//
const isVideoPlaying = ref(false)
//
const isDrumPlaying = ref(false)
//
const collectedItems = computed(() => {
@ -140,6 +144,11 @@ const collectionProgress = computed(() => {
return Math.round((collected / total) * 100)
})
// BGM
const isBgmButtonDisabled = computed(() => {
return isVideoPlaying.value || isDrumPlaying.value
})
// EndPage
const collectedSeals = computed(() => {
return {
@ -234,6 +243,12 @@ const handleStart = () => {
hasScrolled.value = false
console.log('点击开始按钮hasScrolled:', hasScrolled.value)
//
if (!isMusicPlaying.value) {
console.log('背景音乐未播放,开始播放')
toggleMusic()
}
//
initPage()
}
@ -319,6 +334,9 @@ const initMusicPlayer = () => {
// /
const toggleMusic = () => {
//
if (isBgmButtonDisabled.value) return
if (!audioPlayer.value) {
initMusicPlayer()
}
@ -330,9 +348,27 @@ const toggleMusic = () => {
console.log('音乐已暂停')
} else {
//
audioPlayer.value.play()
isMusicPlaying.value = true
console.log('音乐已开始播放')
try {
const result = audioPlayer.value.play()
// play()PromiseWeb
if (result && typeof result.then === 'function') {
// Web使Promise
result.then(() => {
isMusicPlaying.value = true
console.log('音乐已开始播放')
}).catch(error => {
console.error('音乐播放失败(需要用户交互):', error)
// isMusicPlayingfalse
})
} else {
//
isMusicPlaying.value = true
console.log('音乐已开始播放')
}
} catch (error) {
console.error('音乐播放失败(需要用户交互):', error)
// isMusicPlayingfalse
}
}
}
@ -343,10 +379,8 @@ onMounted(() => {
//
initMusicPlayer()
//
setTimeout(() => {
toggleMusic()
}, 1000)
//
//
})
//
@ -577,6 +611,105 @@ const handleQianmenHeightChanged = (height) => {
console.log('当前CSS变量:', getComputedStyle(document.documentElement).getPropertyValue('--scene-height'))
}
// BGM
const wasMusicPlayingBeforeVideo = ref(false)
// BGM
const wasMusicPlayingBeforeDrum = ref(false)
//
const handleVideoOpen = () => {
//
isVideoPlaying.value = true
// BGM
wasMusicPlayingBeforeVideo.value = isMusicPlaying.value
// BGM
if (audioPlayer.value && isMusicPlaying.value) {
audioPlayer.value.pause()
isMusicPlaying.value = false
console.log('全局BGM已停止视频播放中')
}
}
//
const handleVideoClose = () => {
//
isVideoPlaying.value = false
// BGM
if (audioPlayer.value && wasMusicPlayingBeforeVideo.value && !isMusicPlaying.value) {
try {
const result = audioPlayer.value.play()
// play()PromiseWeb
if (result && typeof result.then === 'function') {
// Web使Promise
result.then(() => {
isMusicPlaying.value = true
console.log('全局BGM已恢复播放视频已关闭')
}).catch(error => {
console.error('BGM恢复播放失败需要用户交互:', error)
// isMusicPlayingfalse
})
} else {
//
isMusicPlaying.value = true
console.log('全局BGM已恢复播放视频已关闭')
}
} catch (error) {
console.error('BGM恢复播放失败需要用户交互:', error)
// isMusicPlayingfalse
}
}
}
// BGM
const pauseBgm = () => {
//
isDrumPlaying.value = true
// BGM
wasMusicPlayingBeforeDrum.value = isMusicPlaying.value
if (audioPlayer.value && isMusicPlaying.value) {
audioPlayer.value.pause()
isMusicPlaying.value = false
console.log('全局BGM已暂停鼓声播放中')
}
}
// BGM
const resumeBgm = () => {
//
isDrumPlaying.value = false
// BGM
if (audioPlayer.value && wasMusicPlayingBeforeDrum.value && !isMusicPlaying.value) {
try {
const result = audioPlayer.value.play()
// play()PromiseWeb
if (result && typeof result.then === 'function') {
// Web使Promise
result.then(() => {
isMusicPlaying.value = true
console.log('全局BGM已恢复播放鼓声已结束')
}).catch(error => {
console.error('BGM恢复播放失败需要用户交互:', error)
// isMusicPlayingfalse
})
} else {
//
isMusicPlaying.value = true
console.log('全局BGM已恢复播放鼓声已结束')
}
} catch (error) {
console.error('BGM恢复播放失败需要用户交互:', error)
// isMusicPlayingfalse
}
}
}
// 使scroll-view
// scroll-view
@ -591,7 +724,7 @@ onUnmounted(() => {
<!-- 音乐控制按钮 -->
<div
class="music-control"
:class="{ 'music-playing': isMusicPlaying }"
:class="{ 'music-playing': isMusicPlaying, 'disabled': isBgmButtonDisabled }"
@click="toggleMusic"
>
<img src="/static/images/music_on.png" alt="音乐" class="music-icon" />
@ -639,6 +772,8 @@ onUnmounted(() => {
:scroll-position="scrollContainer && scrollContainer.value ? scrollContainer.value.scrollTop : 0"
:video-url="scenes[1].videoUrl"
@collect-seal="collectSeal(1)"
@video-open="handleVideoOpen"
@video-close="handleVideoClose"
/>
<!-- 隆福寺商圈 -->
@ -647,6 +782,8 @@ onUnmounted(() => {
:scroll-position="scrollContainer && scrollContainer.value ? scrollContainer.value.scrollTop : 0"
:video-url="scenes[2].videoUrl"
@collect-seal="collectSeal(2)"
@video-open="handleVideoOpen"
@video-close="handleVideoClose"
/>
<!-- 王府井商圈 -->
@ -655,6 +792,8 @@ onUnmounted(() => {
:scroll-position="scrollContainer?.value?.scrollTop || 0"
:video-url="scenes[3].videoUrl"
@collect-seal="collectSeal(3)"
@video-open="handleVideoOpen"
@video-close="handleVideoClose"
/>
<!-- 崇文门商圈 -->
@ -663,6 +802,8 @@ onUnmounted(() => {
:scroll-position="scrollContainer?.value?.scrollTop || 0"
:video-url="scenes[4].videoUrl"
@collect-seal="collectSeal(4)"
@video-open="handleVideoOpen"
@video-close="handleVideoClose"
/>
<!-- 前门商圈 -->
@ -670,8 +811,13 @@ onUnmounted(() => {
:active="activeSceneIndex === 5"
:scroll-position="scrollContainer?.value?.scrollTop || 0"
:video-url="scenes[5].videoUrl"
:is-music-playing="isMusicPlaying"
@collect-seal="collectSeal(5)"
@height-changed="handleQianmenHeightChanged"
@video-open="handleVideoOpen"
@video-close="handleVideoClose"
@pause-bgm="pauseBgm"
@resume-bgm="resumeBgm"
/>
<!-- 新年文案模块 -->
@ -707,7 +853,7 @@ onUnmounted(() => {
<!-- 向上滑动提示 -->
<div class="scroll-tip-bottom" v-if="!hasScrolled">
<img src="/static/images/icon_hand1.png" class="tip-icon" alt="滑动提示" />
<p>滑动探索商圈</p>
<p>滑动探索商圈</p>
</div>
<!-- 抽奖留资弹窗 -->
@ -943,6 +1089,20 @@ onUnmounted(() => {
justify-content: center;
z-index: 1000;
cursor: pointer;
transition: all 0.3s ease;
}
.music-control:hover:not(.disabled) {
transform: scale(1.1);
}
.music-control:active:not(.disabled) {
transform: scale(0.95);
}
.music-control.disabled {
opacity: 0.5;
cursor: not-allowed;
}

View File

@ -63,7 +63,7 @@ const handlePlayClick = () => {
/* 鼠标悬停效果 */
.video-play-button-container:hover .video-play-button-bg {
background-color: rgba(0, 0, 0, 0.9);
background-color: rgba(0, 0, 0, 0.4);
transform: scale(1.05);
animation: none;
}

View File

@ -37,9 +37,6 @@ const handleContentClick = (e) => {
<template>
<div v-if="visible" class="video-modal">
<div class="video-modal-content" @click="handleContentClick">
<div class="video-close-button" @click="handleClose">
<span>×</span>
</div>
<video
:src="videoUrl"
class="video-player"
@ -48,6 +45,10 @@ const handleContentClick = (e) => {
loop
></video>
</div>
<!-- 关闭按钮放在视频下方 -->
<div class="video-close-button" @click="handleClose">
<img src="/static/images/btn_close.png" alt="关闭" class="close-icon" />
</div>
</div>
</template>
@ -63,6 +64,7 @@ const handleContentClick = (e) => {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
z-index: 999;
}
@ -70,18 +72,22 @@ const handleContentClick = (e) => {
position: relative;
border-radius: 20rpx;
overflow: hidden;
width: 720rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.video-player {
width: 720rpx;
height: 405rpx;
background-color: #000;
}
.video-close-button {
position: absolute;
top: 10rpx;
right: 10rpx;
width: 40rpx;
height: 40rpx;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 50%;
margin-top: 30rpx;
width: 68rpx;
height: 68rpx;
display: flex;
align-items: center;
justify-content: center;
@ -89,17 +95,9 @@ const handleContentClick = (e) => {
z-index: 10;
}
.video-close-button span {
color: white;
font-size: 30rpx;
font-weight: bold;
line-height: 30rpx;
height: 30rpx;
}
.video-player {
width: 100%;
height: 100%;
background-color: #000;
.close-icon {
width: 68rpx;
height: 68rpx;
object-fit: contain;
}
</style>

View File

@ -25,7 +25,7 @@ const props = defineProps({
})
//
const emit = defineEmits(['collect-seal'])
const emit = defineEmits(['collect-seal', 'video-open', 'video-close'])
//
const sq3ImageVisible = ref(false)
@ -106,11 +106,13 @@ const closeGallery = () => {
//
const openVideoPlayer = () => {
showVideoPlayer.value = true
emit('video-open')
}
//
const closeVideoPlayer = () => {
showVideoPlayer.value = false
emit('video-close')
}
//

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 41 KiB