From 91cc846ad7f1d9c417260837b54fcd4bb0a0d94f Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 17 六月 2024 14:51:27 +0800 Subject: [PATCH] 图书优化 --- src/books/artAndDance/view/components/index.vue | 110 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 96 insertions(+), 14 deletions(-) diff --git a/src/books/artAndDance/view/components/index.vue b/src/books/artAndDance/view/components/index.vue index 5574cf3..6678a4d 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,6 +64,7 @@ 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"; @@ -75,6 +86,9 @@ questionDataMap: {}, renderSignMap: {}, highlightData: null, + audioPath: "", + currentTime: null, + videoList: [], }; }, computed: { @@ -180,7 +194,7 @@ // 娴嬭瘯椤甸潰璺宠浆 // setTimeout(() => { - // this.gotoPage(1, 10); + // this.gotoPage(6, 26); // setTimeout(() => { // this.renderSign("Highlight", { // id: "2ACA9359", @@ -208,7 +222,7 @@ // txt: " 杩愬姩绯荤粺鏄敱楠ㄣ�侀杩炵粨鍜岄楠艰倢涓夐儴鍒嗙粍鎴愮殑銆傚叏韬殑楠ㄩ�氳繃楠ㄨ繛缁撶粍鎴愪汉浣撻楠硷紙瑙佸浘1-1锛夈�傞楠兼槸浜轰綋鐨勬敮鏋讹紝鍏锋湁淇濇姢鍐呰剰鍣ㄥ畼銆佷緵鑲岃倝闄勭潃鍜屼綔涓鸿倢鑲夎繍鍔ㄧ殑鏉犳潌绛変綔鐢ㄣ�傚湪绁炵粡绯荤粺鐨勬敮閰嶄笅锛岃倢鑲夋敹缂╃壍鍔ㄦ墍闄勭潃鐨勯缁曠潃鍏宠妭杞姩锛屼娇韬綋浜х敓鍚勭鍔ㄤ綔銆傛墍浠ワ紝杩愬姩绯荤粺鍏锋湁杩愬姩銆佹敮鎸佸拰淇濇姢绛夊姛鑳斤紝骞煎勾鏃舵湡鐨勯楠艰繕鍏锋湁閫犺鍔熻兘銆� ", // txtIndex: 57 // }); - // }, 5000); + // }, 500); }, methods: { // setZoom1() { @@ -229,6 +243,7 @@ scrollFun(event) { // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩 if (event.target.scrollTop > this.previousScrollTop) { + this.getAduio() // 鍚戜笅 const currentScrollTop = event.target.scrollTop + event.target.offsetHeight; @@ -252,6 +267,7 @@ } } } else if (event.target.scrollTop < this.previousScrollTop) { + this.handleAudio() // 鍚戜笂 const currentScrollTop = event.target.scrollTop; if (currentScrollTop <= this.loadThreshold) { @@ -639,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, + // observer: true, + // observeParents: true // // 濡傛灉闇�瑕佸垎椤靛櫒 // pagination: { // el: (this.container ? this.container : document).querySelector( @@ -678,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, @@ -702,8 +718,8 @@ var paginationInfoEl = dom.querySelector(".pageBox"); if (paginationInfoEl) paginationInfoEl.textContent = currentPage + "/" + totalPages; - }, - }, + } + } }); } }, @@ -834,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, @@ -843,6 +924,7 @@ chapterFour, chapterFive, chapterSix, + miniAudio }, }; </script> -- Gitblit v1.9.1