| | |
| | | :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"; |
| | |
| | | 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, // 节流阈值 |
| | |
| | | loadPageList: [], |
| | | questionData: {}, |
| | | renderSignMap: {}, |
| | | audioPath: "", |
| | | currentTime: null, |
| | | videoList: [], |
| | | }; |
| | | }, |
| | | computed: { |
| | |
| | | scrollFun(event) { |
| | | // 判断向上滚动还是向下滚动 |
| | | if (event.target.scrollTop > this.previousScrollTop) { |
| | | this.getAduio(); |
| | | // 向下 |
| | | const currentScrollTop = |
| | | event.target.scrollTop + event.target.offsetHeight; |
| | |
| | | } |
| | | } |
| | | } else if (event.target.scrollTop < this.previousScrollTop) { |
| | | this.handleAudio(); |
| | | // 向上 |
| | | const currentScrollTop = event.target.scrollTop; |
| | | if (currentScrollTop <= this.loadThreshold) { |
| | |
| | | // } |
| | | }); |
| | | } |
| | | const pptDoms = ( |
| | | this.container ? this.container : document |
| | | ).querySelectorAll(".swiper_ppt"); |
| | | 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; |
| | | }, |
| | | 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() { |
| | | const doms = ( |
| | |
| | | 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, |
| | |
| | | } |
| | | // 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> |