From ee3eb8715b362e975c25f8fb303e41e925a23b3a Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 13 六月 2024 11:57:23 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/testbookLayout --- src/books/artAndDrama/view/components/index.vue | 86 +++++++++++++++++++++++++++++++++++++------ 1 files changed, 74 insertions(+), 12 deletions(-) diff --git a/src/books/artAndDrama/view/components/index.vue b/src/books/artAndDrama/view/components/index.vue index d53531e..c37fbcf 100644 --- a/src/books/artAndDrama/view/components/index.vue +++ b/src/books/artAndDrama/view/components/index.vue @@ -24,17 +24,23 @@ :showPageList="loadPageList" > </chapterTwo> - <chapterThree + <!-- <chapterThree v-if="showCatalogList.indexOf(4) > -1" :showPageList="loadPageList" ></chapterThree> <chapterFour v-if="showCatalogList.indexOf(5) > -1" :showPageList="loadPageList" - ></chapterFour> + ></chapterFour> --> </div> - + <!-- 闊抽灏忕獥鎾斁缁勪欢 --> + <miniAudio + :path="audioPath" + :currentTime="currentTime" + @closeMiniAudio="closeMiniAudio" + ref="audioPlayer" + ></miniAudio> </div> </template> @@ -42,9 +48,10 @@ import pageHeader from "./header.vue"; import chapterOne from "./chapter001.vue"; import chapterTwo from "./chapter002.vue"; - import chapterThree from "./chapter003.vue"; - import chapterFour from "./chapter004.vue"; + // import chapterThree from "./chapter003.vue"; + // import chapterFour from "./chapter004.vue"; import NoteIcon from "@/assets/images/biji.png"; + import miniAudio from "@/components/miniAudio/index.vue"; import _ from "lodash"; import Swiper from "swiper/bundle"; import "swiper/swiper-bundle.css"; @@ -53,7 +60,7 @@ export default { data() { return { - catalogLength: 4, // 鎬荤珷鑺傛暟 + catalogLength: 3, // 鎬荤珷鑺傛暟 showCatalogList: [], // 鏄剧ず鐨勭珷鑺� loadThreshold: 300, // 瑙﹀彂鍔犺浇闃堝�� throttleThreshold: 100, // 鑺傛祦闃堝�� @@ -65,6 +72,9 @@ questionDataMap: {}, renderSignMap: {}, highlightData: null, + audioPath: "", + currentTime: null, + videoList: [], }; }, computed: { @@ -219,6 +229,7 @@ scrollFun(event) { // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩 if (event.target.scrollTop > this.previousScrollTop) { + this.getAduio(); // 鍚戜笅 const currentScrollTop = event.target.scrollTop + event.target.offsetHeight; @@ -243,6 +254,7 @@ } } else if (event.target.scrollTop < this.previousScrollTop) { // 鍚戜笂 + this.handleAudio(); const currentScrollTop = event.target.scrollTop; if (currentScrollTop <= this.loadThreshold) { // 鍒拌揪闃堝�� @@ -722,10 +734,9 @@ pageHeader, chapterOne, chapterTwo, - chapterThree, - chapterFour, - chapterFive, - chapterSix, + // chapterThree, + // chapterFour, + }; // 閬嶅巻鎵�鏈夌珷鑺傛枃浠� for (const key in pageData) { @@ -824,13 +835,64 @@ // 璺宠浆 this.gotoPage(data.catalog, data.page, () => {}); }, + // 椤甸潰鍚戜笅婊氬姩锛岄煶棰戝皬绐楁挱鏀惧姛鑳� + getAduio() { + let allVideo = ( + this.container ? this.container : document + ).querySelectorAll(".audio"); + allVideo = Array.from(allVideo); + this.videoList = allVideo; + if (allVideo.length) { + // 鏌ユ壘鎾斁鐘舵�佺殑鏈�鍚庝竴鏉¢煶棰� + const playAudio = allVideo + .reverse() + .find((item) => item.paused == false); + if (playAudio) { + const bottomGap = playAudio.getBoundingClientRect().bottom; + if (bottomGap < 0) { + playAudio.pause(); + this.audioPath = playAudio.src; + this.currentTime = playAudio.currentTime; + } + } + } + }, + // 椤甸潰鍚戜笂婊氬姩锛岄煶棰戝皬绐楀洖鏀� + handleAudio() { + if (!this.audioPath) return false; + let allVideo = ( + this.container ? this.container : document + ).querySelectorAll(".audio"); + allVideo = Array.from(allVideo); + if (allVideo.length) { + //鏌ユ壘涓庡皬绐楁挱鏀鹃煶棰戝悓婧愮殑椤甸潰audio DOM + const playAudio = allVideo.find((item) => item.src == this.audioPath); + if (playAudio) { + const bottomGap = playAudio.getBoundingClientRect().bottom; + if (bottomGap >= 0) { + if (this.$refs.audioPlayer) { + const playerState = this.$refs.audioPlayer.getVideoPlayer(); + this.audioPath = ""; + playAudio.currentTime = playerState.currentTime; + if (!playerState.paused) playAudio.play(); + } + } + } + } + }, + // 鍏抽棴mini video + closeMiniAudio() { + this.audioPath = ""; + }, }, components: { pageHeader, chapterOne, chapterTwo, - chapterThree, - chapterFour, + miniAudio + // chapterThree, + // chapterFour, + }, }; </script> -- Gitblit v1.9.1