| | |
| | | <chapterOne |
| | | v-if="showCatalogList.indexOf(2) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionDataMap" |
| | | ></chapterOne> |
| | | </div> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import axios from "axios"; |
| | | import pageHeader from "./header.vue"; |
| | | import chapterOne from "./chapter001.vue"; |
| | | // import chapterTwo from "./chapter002.vue"; |
| | |
| | | import "swiper/swiper-bundle.css"; |
| | | import Viewer from "viewerjs"; |
| | | import "viewerjs/dist/viewer.css"; |
| | | import getQuestionList from "@/assets/methods/examination"; |
| | | export default { |
| | | name:"pageContent", |
| | | name: "pageContent", |
| | | data() { |
| | | return { |
| | | catalogLength: 2, // 总章节数 |
| | |
| | | questionDataMap: {}, |
| | | renderSignMap: {}, |
| | | highlightData: null, |
| | | questionId: {}, |
| | | collectId:[] |
| | | }; |
| | | }, |
| | | computed: { |
| | |
| | | // txtIndex: 57 |
| | | // }); |
| | | // }, 5000); |
| | | |
| | | // 获取题目id列表 |
| | | this.getQuestionId(); |
| | | this.getCollect() |
| | | }, |
| | | methods: { |
| | | // setZoom1() { |
| | |
| | | this.container ? this.container : document |
| | | ).querySelector(`[page="${data.page}"]`); |
| | | // 创建 createTreeWalker 迭代器,用于遍历文本节点,保存到一个数组 |
| | | const treeWalker = document.createTreeWalker(pageDom, NodeFilter.SHOW_TEXT); |
| | | const treeWalker = document.createTreeWalker( |
| | | pageDom, |
| | | NodeFilter.SHOW_TEXT |
| | | ); |
| | | const allTextNodes = []; |
| | | let currentNode = treeWalker.nextNode(); |
| | | while (currentNode) { |
| | |
| | | // 添加页码 |
| | | this.loadPageList.push(Number(page)); |
| | | const catalog = catalogDom.getAttribute("num"); |
| | | // if (!this.questionDataMap[page]) { |
| | | // if (testData && testData[catalog]) { |
| | | // if (testData[catalog][page]) { |
| | | // if (Array.isArray(testData[catalog][page])) { |
| | | // this.questionDataMap[page] = await getQuestionList( |
| | | // page, |
| | | // testData[catalog][page], |
| | | // this.config.activeBook |
| | | // ); |
| | | // } else { |
| | | // const obj = {}; |
| | | // for (let key in testData[catalog][page]) { |
| | | // obj[key] = await getQuestionList( |
| | | // [], |
| | | // testData[catalog][page][key], |
| | | // this.config.activeBook |
| | | // ); |
| | | // } |
| | | // this.questionDataMap[page] = obj; |
| | | // } |
| | | // console.log("题目", this.questionDataMap); |
| | | // } |
| | | // } |
| | | // } |
| | | if (!this.questionDataMap[page]) { |
| | | if (this.questionId && this.questionId[catalog]) { |
| | | if (this.questionId[catalog][page]) { |
| | | this.questionDataMap[page] = await this.getQuestion(catalog, page); |
| | | console.log("题目", this.questionDataMap); |
| | | } |
| | | } |
| | | } |
| | | // 渲染这一页的标记 |
| | | for (const key in this.renderSignMap) { |
| | | if (this.renderSignMap[key][page]) { |
| | |
| | | // 高亮行 |
| | | setTimeout(() => { |
| | | // 获取页面所有text节点 |
| | | const pageTextList = document.createTreeWalker(target, NodeFilter.SHOW_TEXT); |
| | | const pageTextList = document.createTreeWalker( |
| | | target, |
| | | NodeFilter.SHOW_TEXT |
| | | ); |
| | | // 匹配关键字 |
| | | const allPageTextNodes = []; |
| | | let currentNode = pageTextList.nextNode(); |
| | |
| | | autoplay: { |
| | | //自动开始 |
| | | delay: 3000, //时间间隔 |
| | | disableOnInteraction: false //*手动操作轮播图后不会暂停* |
| | | disableOnInteraction: false, //*手动操作轮播图后不会暂停* |
| | | }, |
| | | paginationClickable: true, |
| | | slidesPerView: 1, // 一组三个 |
| | | spaceBetween: 30, // 间隔 |
| | | // 如果需要前进后退按钮 |
| | | navigation: { |
| | | nextEl: dom.querySelector( |
| | | ".swiper-button-next" |
| | | ), |
| | | prevEl: dom.querySelector( |
| | | ".swiper-button-prev" |
| | | ) |
| | | nextEl: dom.querySelector(".swiper-button-next"), |
| | | prevEl: dom.querySelector(".swiper-button-prev"), |
| | | }, |
| | | // 窗口变化,重新init,针对F11全屏和放大缩小,必须加 |
| | | observer: true, |
| | | observeParents: true |
| | | observeParents: true, |
| | | // // 如果需要分页器 |
| | | // pagination: { |
| | | // el: (this.container ? this.container : document).querySelector( |
| | |
| | | spaceBetween: 30, // 间隔 |
| | | // 如果需要前进后退按钮 |
| | | navigation: { |
| | | nextEl: dom.querySelector( |
| | | ".swiper-button-next" |
| | | ), |
| | | prevEl: dom.querySelector( |
| | | ".swiper-button-prev" |
| | | ) |
| | | nextEl: dom.querySelector(".swiper-button-next"), |
| | | prevEl: dom.querySelector(".swiper-button-prev"), |
| | | }, |
| | | // 窗口变化,重新init,针对F11全屏和放大缩小,必须加 |
| | | observer: true, |
| | |
| | | var paginationInfoEl = dom.querySelector(".pageBox"); |
| | | if (paginationInfoEl) |
| | | paginationInfoEl.textContent = currentPage + "/" + totalPages; |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | }); |
| | | } |
| | | }, |
| | |
| | | propsData: { |
| | | showPageList: [], |
| | | questionData: {}, |
| | | isSearch: true |
| | | isSearch: true, |
| | | }, |
| | | }); |
| | | pageExample.$mount( |
| | |
| | | propsData: { |
| | | showPageList: [pageNum], |
| | | questionData: {}, |
| | | isSearch: true |
| | | isSearch: true, |
| | | }, |
| | | }); |
| | | pageExample.$mount( |
| | |
| | | .querySelector(`[page="${pageNum}"]`); |
| | | if (thisPageDom) { |
| | | // 获取页面所有text节点 |
| | | const pageTextList = document.createTreeWalker(thisPageDom, NodeFilter.SHOW_TEXT); |
| | | const pageTextList = document.createTreeWalker( |
| | | thisPageDom, |
| | | NodeFilter.SHOW_TEXT |
| | | ); |
| | | // 匹配关键字 |
| | | const allPageTextNodes = []; |
| | | let currentNode = pageTextList.nextNode(); |
| | |
| | | // 跳转 |
| | | this.gotoPage(data.catalog, data.page, () => {}); |
| | | }, |
| | | // 获取题目列表 |
| | | getQuestionId() { |
| | | axios |
| | | .get(this.config.activeBook.resourceUrl + "/question.json") |
| | | .then((res) => { |
| | | this.questionId = res.data.data; |
| | | }); |
| | | }, |
| | | // 获取题目收藏id列表 |
| | | getCollect() { |
| | | this.MG.identity |
| | | .getUserKey({ |
| | | domain: "collectData", |
| | | keys: [this.config.activeBook.bookId], |
| | | }) |
| | | .then((res) => { |
| | | try { |
| | | const collect = JSON.parse(res[0].value); |
| | | if (collect.length) { |
| | | this.collectId = collect.find(item => item.type == 'json').collectList |
| | | console.log('收藏列表',this.collectId); |
| | | } |
| | | } catch (error) { |
| | | console.log("暂无数据"); |
| | | } |
| | | }).catch(res => { |
| | | console.log('index 请求题目收藏id报错'); |
| | | }) |
| | | }, |
| | | // 获取章节题目 |
| | | async getQuestion(num, page) { |
| | | let cardList = [ |
| | | { |
| | | catalogName: "单选题", |
| | | infoList: [], |
| | | }, |
| | | { |
| | | catalogName: "判断题", |
| | | infoList: [], |
| | | }, |
| | | { |
| | | catalogName: "多选题", |
| | | infoList: [], |
| | | }, |
| | | { |
| | | catalogName: "填空题", |
| | | infoList: [], |
| | | }, |
| | | { |
| | | catalogName: "简答题", |
| | | infoList: [], |
| | | }, |
| | | ]; |
| | | if (this.questionId) { |
| | | if (this.questionId[num] && this.questionId[num][page]) { |
| | | const res = await axios.get( |
| | | this.config.activeBook.resourceUrl + "/question-" + num + ".json" |
| | | ); |
| | | if (!res.data.data) return []; |
| | | for (let index = 0; index < res.data.data.length; index++) { |
| | | const item = res.data.data[index]; |
| | | item.isCollect = this.collectId.indexOf(item.id) > -1 ? true :false |
| | | console.log(item.id ,this.collectId.indexOf(item.id)); |
| | | if (this.questionId[num][page].indexOf(item.id) > -1) { |
| | | if (item.type && item.type == "material") { |
| | | cardList.push(item); |
| | | } else { |
| | | if (item.questionType == "judge") { |
| | | cardList[1].infoList.push(item); |
| | | } else if (item.questionType == "singleChoice") { |
| | | cardList[0].infoList.push(item); |
| | | } else if (item.questionType == "multipleChoice") { |
| | | cardList[2].infoList.push(item); |
| | | } else if (item.questionType == "completion") { |
| | | cardList[3].infoList.push(item); |
| | | } else if (item.questionType == "shortAnswer") { |
| | | cardList[4].infoList.push(item); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return cardList.filter((item) => item.infoList.length > 0); |
| | | } |
| | | } else { |
| | | return []; |
| | | } |
| | | }, |
| | | }, |
| | | components: { |
| | | pageHeader, |