From 3fb594dc317848107fd7bbb51631cfb763c19f5f Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期三, 05 六月 2024 18:47:03 +0800
Subject: [PATCH] 舞蹈分页

---
 src/books/English/view/components/index.vue |  127 +++++++++++++++++++++++++++++++-----------
 1 files changed, 93 insertions(+), 34 deletions(-)

diff --git a/src/books/English/view/components/index.vue b/src/books/English/view/components/index.vue
index bb1feca..7729adb 100644
--- a/src/books/English/view/components/index.vue
+++ b/src/books/English/view/components/index.vue
@@ -18,12 +18,18 @@
         :showPageList="loadPageList"
       ></chapterOne>
     </div>
+    <miniAudio
+      :path="audioPath"
+      :currentTime="currentTime"
+      ref="audioPlayer"
+    ></miniAudio>
   </div>
 </template>
 
 <script>
 import pageHeader from "./header.vue";
 import chapterOne from "./chapter001.vue";
+import miniAudio from "@/components/miniAudio/index.vue";
 import NoteIcon from "@/assets/images/biji.png";
 import _ from "lodash";
 import Swiper from "swiper/bundle";
@@ -31,9 +37,10 @@
 import Viewer from "viewerjs";
 import "viewerjs/dist/viewer.css";
 export default {
+  name: "page-main",
   data() {
     return {
-      catalogLength: 13, // 鎬荤珷鑺傛暟
+      catalogLength: 2, // 鎬荤珷鑺傛暟
       showCatalogList: [], // 鏄剧ず鐨勭珷鑺�
       loadThreshold: 300, // 瑙﹀彂鍔犺浇闃堝��
       throttleThreshold: 100, // 鑺傛祦闃堝��
@@ -44,6 +51,9 @@
       loadPageList: [],
       questionData: {},
       renderSignMap: {},
+      audioPath: "",
+      currentTime: null,
+      videoList: [],
     };
   },
   computed: {
@@ -78,6 +88,7 @@
         setTimeout(() => {
           this.initSwiper();
           this.initViewer();
+          // this.getAduio();
         }, 200);
       },
     },
@@ -155,6 +166,7 @@
     scrollFun(event) {
       // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩
       if (event.target.scrollTop > this.previousScrollTop) {
+        this.getAduio();
         // 鍚戜笅
         const currentScrollTop =
           event.target.scrollTop + event.target.offsetHeight;
@@ -178,6 +190,7 @@
           }
         }
       } else if (event.target.scrollTop < this.previousScrollTop) {
+        this.handleAudio();
         // 鍚戜笂
         const currentScrollTop = event.target.scrollTop;
         if (currentScrollTop <= this.loadThreshold) {
@@ -565,40 +578,40 @@
       for (let i = 0; i < pptDoms.length; i++) {
         const dom = pptDoms[i];
         new Swiper(dom, {
-        loop: false, // 鏃犵紳
-        autoplay: false,
-        paginationClickable: true,
-        slidesPerView: 1, // 涓�缁勪笁涓�
-        spaceBetween: 30, // 闂撮殧
-        // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳
-        navigation: {
-          nextEl: (this.container ? this.container : document).querySelector(
-            ".swiper-button-next"
-          ),
-          prevEl: (this.container ? this.container : document).querySelector(
-            ".swiper-button-prev"
-          ),
-        },
-        // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔�
-        observer: true,
-        observeParents: true,
-        on: {
-          init:(value) => {
-            let currentPage = value.activeIndex + 1; // 鑾峰彇褰撳墠椤碉紙浠�1寮�濮嬭鏁帮級
-            let totalPages = value.slides.length; // 鑾峰彇鎬婚〉鏁�
-            var paginationInfoEl = dom.querySelector('.pageBox');
-            if(paginationInfoEl)
-              paginationInfoEl.textContent = currentPage + '/' + totalPages;
+          loop: false, // 鏃犵紳
+          autoplay: false,
+          paginationClickable: true,
+          slidesPerView: 1, // 涓�缁勪笁涓�
+          spaceBetween: 30, // 闂撮殧
+          // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳
+          navigation: {
+            nextEl: (this.container ? this.container : document).querySelector(
+              ".swiper-button-next"
+            ),
+            prevEl: (this.container ? this.container : document).querySelector(
+              ".swiper-button-prev"
+            ),
           },
-          slideChange:(value) => {
-            let currentPage = value.activeIndex + 1; // 鑾峰彇褰撳墠椤碉紙浠�1寮�濮嬭鏁帮級
-            let totalPages = value.slides.length; // 鑾峰彇鎬婚〉鏁�
-            var paginationInfoEl = dom.querySelector('.pageBox');
-            if(paginationInfoEl)
-              paginationInfoEl.textContent = currentPage + '/' + totalPages;
+          // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔�
+          observer: true,
+          observeParents: true,
+          on: {
+            init: (value) => {
+              let currentPage = value.activeIndex + 1; // 鑾峰彇褰撳墠椤碉紙浠�1寮�濮嬭鏁帮級
+              let totalPages = value.slides.length; // 鑾峰彇鎬婚〉鏁�
+              var paginationInfoEl = dom.querySelector(".pageBox");
+              if (paginationInfoEl)
+                paginationInfoEl.textContent = currentPage + "/" + totalPages;
+            },
+            slideChange: (value) => {
+              let currentPage = value.activeIndex + 1; // 鑾峰彇褰撳墠椤碉紙浠�1寮�濮嬭鏁帮級
+              let totalPages = value.slides.length; // 鑾峰彇鎬婚〉鏁�
+              var paginationInfoEl = dom.querySelector(".pageBox");
+              if (paginationInfoEl)
+                paginationInfoEl.textContent = currentPage + "/" + totalPages;
+            },
           },
-        },
-      });
+        });
       }
     },
     initViewer() {
@@ -622,7 +635,7 @@
       console.log("鐢熷兓瀛�", event, word);
       if (this.$store.state.qiankun && this.$store.state.qiankun.chooseWords) {
         this.$store.state.qiankun.chooseWords({
-          type:"word",
+          type: "word",
           word,
           x: event.pageX,
           y: event.pageY,
@@ -630,10 +643,56 @@
       }
       // chooseWords
     },
+    // 椤甸潰鍚戜笅婊氬姩锛岄煶棰戝皬绐楁挱鏀惧姛鑳�
+    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();
+            }
+          }
+        }
+      }
+    },
   },
   components: {
     pageHeader,
     chapterOne,
+    miniAudio,
   },
 };
 </script>

--
Gitblit v1.9.1