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 |  104 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 93 insertions(+), 11 deletions(-)

diff --git a/src/books/artAndDance/view/components/index.vue b/src/books/artAndDance/view/components/index.vue
index 5574cf3..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,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: {
@@ -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,
+          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