From f4bfea700a57d71a9c30315387a77650af13858c Mon Sep 17 00:00:00 2001 From: user1 <10901603+no-distractions1@user.noreply.gitee.com> Date: 星期五, 14 六月 2024 18:10:22 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/testbookLayout --- src/books/artAndDance/view/components/index.vue | 113 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 99 insertions(+), 14 deletions(-) diff --git a/src/books/artAndDance/view/components/index.vue b/src/books/artAndDance/view/components/index.vue index 78947f5..02232f5 100644 --- a/src/books/artAndDance/view/components/index.vue +++ b/src/books/artAndDance/view/components/index.vue @@ -18,30 +18,40 @@ <chapterOne v-if="showCatalogList.indexOf(2) > -1" :showPageList="loadPageList" + @closeAudio="closeAudio" ></chapterOne> <chapterTwo v-if="showCatalogList.indexOf(3) > -1" :showPageList="loadPageList" + @closeAudio="closeAudio" > </chapterTwo> <chapterThree v-if="showCatalogList.indexOf(4) > -1" :showPageList="loadPageList" + @closeAudio="closeAudio" ></chapterThree> <chapterFour v-if="showCatalogList.indexOf(5) > -1" :showPageList="loadPageList" + @closeAudio="closeAudio" ></chapterFour> <chapterFive v-if="showCatalogList.indexOf(6) > -1" :showPageList="loadPageList" + @closeAudio="closeAudio" ></chapterFive> <chapterSix v-if="showCatalogList.indexOf(7) > -1" :showPageList="loadPageList" ></chapterSix> </div> - + <miniAudio + :path="audioPath" + :currentTime="currentTime" + @closeMiniAudio="closeMiniAudio" + ref="audioPlayer" + ></miniAudio> </div> </template> @@ -54,12 +64,14 @@ import chapterFive from './chapter005.vue' import chapterSix from './chapter006.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"; import Viewer from "viewerjs"; import "viewerjs/dist/viewer.css"; export default { + name:"pageContent", data() { return { catalogLength: 7, // 鎬荤珷鑺傛暟 @@ -74,6 +86,9 @@ questionDataMap: {}, renderSignMap: {}, highlightData: null, + audioPath: "", + currentTime: null, + videoList: [], }; }, computed: { @@ -228,6 +243,7 @@ scrollFun(event) { // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩 if (event.target.scrollTop > this.previousScrollTop) { + this.getAduio() // 鍚戜笅 const currentScrollTop = event.target.scrollTop + event.target.offsetHeight; @@ -251,6 +267,7 @@ } } } else if (event.target.scrollTop < this.previousScrollTop) { + this.handleAudio() // 鍚戜笂 const currentScrollTop = event.target.scrollTop; if (currentScrollTop <= this.loadThreshold) { @@ -528,7 +545,7 @@ const catalog = catalogDom.getAttribute("num"); let text = null; if (target.querySelector("p")) { - text = target.querySelector("p").textContent.substring(0, 20); + text = target.querySelector("p").textContent.substring(0, 50); } // 杩斿洖椤电爜鍜岀珷鑺備俊鎭� if (this.$store.state.qiankun && this.$store.state.qiankun.pageChange) @@ -554,6 +571,8 @@ target, "chapter" ); + // 娣诲姞椤电爜 + this.loadPageList.push(Number(page)); const catalog = catalogDom.getAttribute("num"); // if (!this.questionDataMap[page]) { // if (testData && testData[catalog]) { @@ -579,8 +598,6 @@ // } // } // } - // 娣诲姞椤电爜 - this.loadPageList.push(Number(page)); // 娓叉煋杩欎竴椤电殑鏍囪 for (const key in this.renderSignMap) { if (this.renderSignMap[key][page]) { @@ -638,23 +655,23 @@ autoplay: { //鑷姩寮�濮� delay: 3000, //鏃堕棿闂撮殧 - disableOnInteraction: false, //*鎵嬪姩鎿嶄綔杞挱鍥惧悗涓嶄細鏆傚仠* + disableOnInteraction: false //*鎵嬪姩鎿嶄綔杞挱鍥惧悗涓嶄細鏆傚仠* }, paginationClickable: true, slidesPerView: 1, // 涓�缁勪笁涓� spaceBetween: 30, // 闂撮殧 // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳 navigation: { - nextEl: (this.container ? this.container : document).querySelector( + nextEl: dom.querySelector( ".swiper-button-next" ), - prevEl: (this.container ? this.container : document).querySelector( + prevEl: dom.querySelector( ".swiper-button-prev" - ), + ) }, // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔� observer: true, - observeParents: true, + observeParents: true // // 濡傛灉闇�瑕佸垎椤靛櫒 // pagination: { // el: (this.container ? this.container : document).querySelector( @@ -677,12 +694,12 @@ spaceBetween: 30, // 闂撮殧 // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳 navigation: { - nextEl: (this.container ? this.container : document).querySelector( + nextEl: dom.querySelector( ".swiper-button-next" ), - prevEl: (this.container ? this.container : document).querySelector( + prevEl: dom.querySelector( ".swiper-button-prev" - ), + ) }, // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔� observer: true, @@ -701,8 +718,8 @@ var paginationInfoEl = dom.querySelector(".pageBox"); if (paginationInfoEl) paginationInfoEl.textContent = currentPage + "/" + totalPages; - }, - }, + } + } }); } }, @@ -746,6 +763,7 @@ propsData: { showPageList: [], questionData: {}, + isSearch: true }, }); pageExample.$mount( @@ -777,6 +795,7 @@ propsData: { showPageList: [pageNum], questionData: {}, + isSearch: true }, }); pageExample.$mount( @@ -831,6 +850,71 @@ // 璺宠浆 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 = ""; + }, + // 鐐瑰嚮闊抽鎾斁锛屽叧闂叾浠栭煶棰� + closeAudio(path) { + let allVideo = ( + this.container ? this.container : document + ).querySelectorAll(".audio"); + allVideo = Array.from(allVideo); + if(allVideo.length) { + for (let index = 0; index < allVideo.length; index++) { + const item = allVideo[index]; + if(item.currentSrc != path) { + item.pause() + } + } + } + this.closeMiniAudio() + } }, components: { pageHeader, @@ -840,6 +924,7 @@ chapterFour, chapterFive, chapterSix, + miniAudio }, }; </script> -- Gitblit v1.9.1