v1.2.8
1、loading页增加背景颜色,同时压缩loading_bg图片 2、点击开始按钮时,检测并进行音乐播放 3、调整视频播放关闭按钮位置
This commit is contained in:
parent
f58436e0fe
commit
3ed1978442
|
|
@ -137,6 +137,7 @@ onMounted(() => {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
|
background-color: #fd4336;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-bg {
|
.loading-bg {
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,12 @@ const handleStart = () => {
|
||||||
hasScrolled.value = false
|
hasScrolled.value = false
|
||||||
console.log('点击开始按钮,hasScrolled:', hasScrolled.value)
|
console.log('点击开始按钮,hasScrolled:', hasScrolled.value)
|
||||||
|
|
||||||
|
// 检查并播放背景音乐
|
||||||
|
if (!isMusicPlaying.value) {
|
||||||
|
console.log('背景音乐未播放,开始播放')
|
||||||
|
toggleMusic()
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化页面
|
// 初始化页面
|
||||||
initPage()
|
initPage()
|
||||||
}
|
}
|
||||||
|
|
@ -330,9 +336,27 @@ const toggleMusic = () => {
|
||||||
console.log('音乐已暂停')
|
console.log('音乐已暂停')
|
||||||
} else {
|
} else {
|
||||||
// 播放音乐
|
// 播放音乐
|
||||||
audioPlayer.value.play()
|
try {
|
||||||
isMusicPlaying.value = true
|
const result = audioPlayer.value.play()
|
||||||
console.log('音乐已开始播放')
|
// 检查play()方法是否返回Promise(Web平台)
|
||||||
|
if (result && typeof result.then === 'function') {
|
||||||
|
// Web平台:使用Promise处理
|
||||||
|
result.then(() => {
|
||||||
|
isMusicPlaying.value = true
|
||||||
|
console.log('音乐已开始播放')
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('音乐播放失败(需要用户交互):', error)
|
||||||
|
// 不更新isMusicPlaying状态,保持为false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 其他平台:同步处理
|
||||||
|
isMusicPlaying.value = true
|
||||||
|
console.log('音乐已开始播放')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('音乐播放失败(需要用户交互):', error)
|
||||||
|
// 不更新isMusicPlaying状态,保持为false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,10 +367,8 @@ onMounted(() => {
|
||||||
// 初始化音乐播放器
|
// 初始化音乐播放器
|
||||||
initMusicPlayer()
|
initMusicPlayer()
|
||||||
|
|
||||||
// 自动开始播放音乐
|
// 移除自动播放音乐的代码,避免触发浏览器自动播放限制
|
||||||
setTimeout(() => {
|
// 音乐将在用户点击开始按钮或音乐控制按钮时播放
|
||||||
toggleMusic()
|
|
||||||
}, 1000)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 处理滚动事件(从下往上滑动)
|
// 处理滚动事件(从下往上滑动)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ const handlePlayClick = () => {
|
||||||
|
|
||||||
/* 鼠标悬停效果 */
|
/* 鼠标悬停效果 */
|
||||||
.video-play-button-container:hover .video-play-button-bg {
|
.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);
|
transform: scale(1.05);
|
||||||
animation: none;
|
animation: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,6 @@ const handleContentClick = (e) => {
|
||||||
<template>
|
<template>
|
||||||
<div v-if="visible" class="video-modal">
|
<div v-if="visible" class="video-modal">
|
||||||
<div class="video-modal-content" @click="handleContentClick">
|
<div class="video-modal-content" @click="handleContentClick">
|
||||||
<div class="video-close-button" @click="handleClose">
|
|
||||||
<span>×</span>
|
|
||||||
</div>
|
|
||||||
<video
|
<video
|
||||||
:src="videoUrl"
|
:src="videoUrl"
|
||||||
class="video-player"
|
class="video-player"
|
||||||
|
|
@ -48,6 +45,10 @@ const handleContentClick = (e) => {
|
||||||
loop
|
loop
|
||||||
></video>
|
></video>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 关闭按钮(放在视频下方) -->
|
||||||
|
<div class="video-close-button" @click="handleClose">
|
||||||
|
<img src="/static/images/btn_close.png" alt="关闭" class="close-icon" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -63,6 +64,7 @@ const handleContentClick = (e) => {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,18 +72,22 @@ const handleContentClick = (e) => {
|
||||||
position: relative;
|
position: relative;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
width: 720rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-player {
|
||||||
width: 720rpx;
|
width: 720rpx;
|
||||||
height: 405rpx;
|
height: 405rpx;
|
||||||
|
background-color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-close-button {
|
.video-close-button {
|
||||||
position: absolute;
|
margin-top: 30rpx;
|
||||||
top: 10rpx;
|
width: 68rpx;
|
||||||
right: 10rpx;
|
height: 68rpx;
|
||||||
width: 40rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
@ -89,17 +95,9 @@ const handleContentClick = (e) => {
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-close-button span {
|
.close-icon {
|
||||||
color: white;
|
width: 68rpx;
|
||||||
font-size: 30rpx;
|
height: 68rpx;
|
||||||
font-weight: bold;
|
object-fit: contain;
|
||||||
line-height: 30rpx;
|
|
||||||
height: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-player {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-color: #000;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 41 KiB |
Loading…
Reference in New Issue