已发生产环境
This commit is contained in:
parent
74b2d4db5e
commit
8c78ec3c01
BIN
src/assets/images/index/music.png
Normal file
BIN
src/assets/images/index/music.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="IndexPage">
|
<div class="IndexPage" @click.once="playMusic">
|
||||||
<div class="index-title">
|
<div class="index-title">
|
||||||
<div class="title-flower"></div>
|
<div class="title-flower"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -51,17 +51,20 @@
|
|||||||
<div class="click-tips" v-if="locationId == 0"></div>
|
<div class="click-tips" v-if="locationId == 0"></div>
|
||||||
<div class="tips-text" v-if="locationId == 0"></div>
|
<div class="tips-text" v-if="locationId == 0"></div>
|
||||||
|
|
||||||
|
<!-- 背景音乐 -->
|
||||||
|
<div class="music_icon" @click="musicIconPlay">
|
||||||
|
<audio style="display: none; height: 0" id="bg-music" autoplay="autoplay" preload="auto" :src="bgm"
|
||||||
|
loop="loop"></audio>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="video-popup" @touchmove.prevent>
|
<div class="video-popup" @touchmove.prevent>
|
||||||
<div class="video-box">
|
<div class="video-box">
|
||||||
<video class="plyr" id="player" controls>
|
<video class="plyr" id="player" controls>
|
||||||
<source src="https://cdn.plyr.io/static/our-video.mp4" type="video/mp4">
|
<source src="https://cdn.plyr.io/static/our-video.mp4" type="video/mp4">
|
||||||
<!-- 你可以根据需要添加多个source标签,支持不同的视频格式 -->
|
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
<div class="cls-btn" @click="hideVideo"></div>
|
<div class="cls-btn" @click="hideVideo"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <Line /> -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@ -70,10 +73,9 @@ import Plyr from 'plyr';
|
|||||||
import 'plyr/dist/plyr.css'; // 导入 Plyr 样式
|
import 'plyr/dist/plyr.css'; // 导入 Plyr 样式
|
||||||
import ImageFramePlayer from 'image-frame-player';
|
import ImageFramePlayer from 'image-frame-player';
|
||||||
import { showSuccessToast } from "vant";
|
import { showSuccessToast } from "vant";
|
||||||
import Line from './Line.vue';
|
|
||||||
import { gsap } from 'gsap'
|
import { gsap } from 'gsap'
|
||||||
import { MotionPathPlugin } from 'gsap/MotionPathPlugin'
|
import { MotionPathPlugin } from 'gsap/MotionPathPlugin'
|
||||||
|
import { isAndriod } from "@/plugins"
|
||||||
gsap.registerPlugin(MotionPathPlugin)
|
gsap.registerPlugin(MotionPathPlugin)
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +93,10 @@ const xflIconRef = ref(null)
|
|||||||
const currentProgress = ref(0) // 当前进度百分比
|
const currentProgress = ref(0) // 当前进度百分比
|
||||||
const debounce = ref(true)
|
const debounce = ref(true)
|
||||||
let animation = null
|
let animation = null
|
||||||
|
const firstClick = ref(true)
|
||||||
|
const isCloseMusic = ref(false)
|
||||||
|
|
||||||
|
const bgm = new URL(`../assets/media/bgm.mp3`, import.meta.url).href
|
||||||
|
|
||||||
// 视频库
|
// 视频库
|
||||||
const videoList = [
|
const videoList = [
|
||||||
@ -107,6 +113,7 @@ const frameList = Array.from({ length: 35 }, (_, index) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
iosMusic()
|
||||||
initSvgAnimation()
|
initSvgAnimation()
|
||||||
animationFn();
|
animationFn();
|
||||||
// palyFrame()
|
// palyFrame()
|
||||||
@ -117,7 +124,7 @@ onMounted(() => {
|
|||||||
fallback: true, // 启用全屏回退
|
fallback: true, // 启用全屏回退
|
||||||
iosNative: true, // 在 iOS 上启用原生全屏
|
iosNative: true, // 在 iOS 上启用原生全屏
|
||||||
},
|
},
|
||||||
autoplay: true, // 自动播放
|
autoplay: false, // 自动播放
|
||||||
mute: false, // 初始不静音
|
mute: false, // 初始不静音
|
||||||
loop: { // 循环播放
|
loop: { // 循环播放
|
||||||
active: false
|
active: false
|
||||||
@ -126,36 +133,24 @@ onMounted(() => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 帧图初始化
|
|
||||||
// const palyFrame = () => {
|
|
||||||
// imageFramePlayer.value = new ImageFramePlayer({
|
|
||||||
// dom: document.getElementById("frameBox"),
|
|
||||||
// imgArr: frameList,
|
|
||||||
// fps: 25,
|
|
||||||
// useCanvas: true,
|
|
||||||
// loop: -1,
|
|
||||||
// yoyo: true
|
|
||||||
// });
|
|
||||||
// imageFramePlayer.value.play();
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 播放事件
|
// 播放事件
|
||||||
const playFn = (index) => {
|
const playFn = (index) => {
|
||||||
|
if (firstClick.value) return
|
||||||
if (debounce.value) return
|
if (debounce.value) return
|
||||||
debounce.value = true
|
debounce.value = true
|
||||||
if (locationId.value == 0) {
|
if (locationId.value == 0) {
|
||||||
|
|
||||||
|
if(!isCloseMusic.value) pauseMusic()
|
||||||
gsap.set('.xfl-icon', { autoAlpha: 1 })
|
gsap.set('.xfl-icon', { autoAlpha: 1 })
|
||||||
}
|
}
|
||||||
if (locationId.value !== index) {
|
if (locationId.value !== index) {
|
||||||
// 计算相差多少步
|
// 计算相差多少步
|
||||||
const setpNum = Math.abs(index - locationId.value)
|
const setpNum = Math.abs(index - locationId.value)
|
||||||
const direction = index - locationId.value > 0 ? 1 : -1
|
const direction = index - locationId.value > 0 ? 1 : -1
|
||||||
console.log('setpNum', setpNum);
|
|
||||||
|
|
||||||
locationId.value = index;
|
locationId.value = index;
|
||||||
|
|
||||||
|
if(!isCloseMusic.value) pauseMusic()
|
||||||
playerRef.value.source = {
|
playerRef.value.source = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
sources: [
|
sources: [
|
||||||
@ -165,23 +160,35 @@ const playFn = (index) => {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
playerRef.value.pause();
|
||||||
|
console.log('playerRef.value', playerRef.value);
|
||||||
|
|
||||||
|
|
||||||
handleMove(progressArr[index - 1], setpNum, direction)
|
handleMove(progressArr[index - 1], setpNum, direction)
|
||||||
} else {
|
} else {
|
||||||
locationId.value = index
|
locationId.value = index
|
||||||
playerRef.value.source = {
|
|
||||||
type: 'video',
|
|
||||||
sources: [
|
|
||||||
{
|
|
||||||
src: videoList[locationId.value - 1],
|
|
||||||
type: 'video/mp4'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
gsap.to(".video-popup", {
|
gsap.to(".video-popup", {
|
||||||
autoAlpha: 1,
|
autoAlpha: 1,
|
||||||
duration: 0.3,
|
duration: 0.3,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
debounce.value = false
|
debounce.value = false
|
||||||
|
playerRef.value.source = {
|
||||||
|
type: 'video',
|
||||||
|
sources: [
|
||||||
|
{
|
||||||
|
src: videoList[locationId.value - 1],
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
playerRef.value.play()
|
||||||
|
},
|
||||||
|
onStart: () => {
|
||||||
|
pauseMusic()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -189,15 +196,17 @@ const playFn = (index) => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
const hideVideo = () => {
|
const hideVideo = () => {
|
||||||
// playerRef.value.fullscreen.enter();
|
// playerRef.value.fullscreen.enter();
|
||||||
playerRef.value.stop();
|
playerRef.value.stop();
|
||||||
gsap.to(".video-popup", {
|
gsap.to(".video-popup", {
|
||||||
autoAlpha: 0,
|
autoAlpha: 0,
|
||||||
duration: 0.5
|
duration: 0.5, onComplete: () => {
|
||||||
|
|
||||||
|
if(!isCloseMusic.value) musicPlay()
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isDone.value && !isShowDone.value) {
|
if (isDone.value && !isShowDone.value) {
|
||||||
@ -205,9 +214,6 @@ const hideVideo = () => {
|
|||||||
isShowDone.value = true
|
isShowDone.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 新增:坐标转换方法
|
// 新增:坐标转换方法
|
||||||
const convertCoordinates = (point) => {
|
const convertCoordinates = (point) => {
|
||||||
const svg = document.querySelector('.path-svg')
|
const svg = document.querySelector('.path-svg')
|
||||||
@ -300,19 +306,28 @@ const handleMove = (percent, setpNum,) => {
|
|||||||
console.log(`当前进度: ${currentProgress.value}%`)
|
console.log(`当前进度: ${currentProgress.value}%`)
|
||||||
// 标记已经去过的地点
|
// 标记已经去过的地点
|
||||||
isMarkList.value[locationId.value - 1] = true
|
isMarkList.value[locationId.value - 1] = true
|
||||||
|
|
||||||
|
|
||||||
gsap.to(".video-popup", {
|
gsap.to(".video-popup", {
|
||||||
autoAlpha: 1,
|
autoAlpha: 1,
|
||||||
duration: 0.3,
|
duration: 0.3,
|
||||||
|
onStart: () => {
|
||||||
|
|
||||||
|
},
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
debounce.value = false
|
debounce.value = false
|
||||||
|
setTimeout(() => {
|
||||||
|
playerRef.value.play()
|
||||||
|
console.log('ssddd');
|
||||||
|
|
||||||
|
}, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 入场动画
|
// 入场动画
|
||||||
const animationFn = () => {
|
const animationFn = () => {
|
||||||
const tl = gsap.timeline({
|
const tl = gsap.timeline({
|
||||||
@ -454,6 +469,74 @@ const animationFn = () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ios端音乐自动播放
|
||||||
|
const musicBtnAni = gsap.timeline();
|
||||||
|
const playStatu = ref(true);
|
||||||
|
const musicPlay = () => {
|
||||||
|
let audio = document.getElementById("bg-music");
|
||||||
|
musicBtnAni.play();
|
||||||
|
audio.play();
|
||||||
|
};
|
||||||
|
|
||||||
|
const musicIconPlay = () => {
|
||||||
|
let audio = document.getElementById("bg-music");
|
||||||
|
musicBtnAni.play();
|
||||||
|
audio.play();
|
||||||
|
if (playStatu.value == true) {
|
||||||
|
musicBtnAni.pause();
|
||||||
|
audio.pause();
|
||||||
|
playStatu.value = false;
|
||||||
|
console.log("暂停");
|
||||||
|
isCloseMusic.value = true
|
||||||
|
} else {
|
||||||
|
musicBtnAni.play();
|
||||||
|
audio.play();
|
||||||
|
playStatu.value = true;
|
||||||
|
console.log("播放");
|
||||||
|
isCloseMusic.value = false
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 暂停
|
||||||
|
const pauseMusic = () => {
|
||||||
|
|
||||||
|
let audio = document.getElementById("bg-music");
|
||||||
|
audio.pause();
|
||||||
|
musicBtnAni.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
const iosMusic = () => {
|
||||||
|
// ios自动播放音乐
|
||||||
|
var audio = document.getElementById("bg-music");
|
||||||
|
audio.play();
|
||||||
|
document.addEventListener(
|
||||||
|
"WeixinJSBridgeReady",
|
||||||
|
function () {
|
||||||
|
|
||||||
|
WeixinJSBridge.invoke("getNetworkType", {}, function (e) {
|
||||||
|
audio.play();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
musicBtnAni.fromTo(
|
||||||
|
".music_icon",
|
||||||
|
{ rotation: "0" },
|
||||||
|
{ rotation: "+=360", repeat: -1, duration: 7, ease: "none" }
|
||||||
|
);
|
||||||
|
musicBtnAni.play();
|
||||||
|
};
|
||||||
|
const playMusic = () => {
|
||||||
|
|
||||||
|
var audio = document.getElementById("bg-music");
|
||||||
|
audio.play();
|
||||||
|
firstClick.value = false
|
||||||
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@ -464,6 +547,12 @@ const animationFn = () => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.music_icon {
|
||||||
|
@include pos(50px, 50px, 73px, 100px);
|
||||||
|
@include bgSrc("index/music.png");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.index-title {
|
.index-title {
|
||||||
@include bgSrc("index/title.png");
|
@include bgSrc("index/title.png");
|
||||||
@include pos(602px, 372px, 74px, -10px);
|
@include pos(602px, 372px, 74px, -10px);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user