| | |
| | | <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: { |
| | |
| | | |
| | | // 测试页面跳转 |
| | | // setTimeout(() => { |
| | | // this.gotoPage(1, 10); |
| | | // this.gotoPage(1, 9); |
| | | // setTimeout(() => { |
| | | // this.renderSign("Highlight", { |
| | | // id: "2ACA9359", |
| | |
| | | // txt: " 运动系统是由骨、骨连结和骨骼肌三部分组成的。全身的骨通过骨连结组成人体骨骼(见图1-1)。骨骼是人体的支架,具有保护内脏器官、供肌肉附着和作为肌肉运动的杠杆等作用。在神经系统的支配下,肌肉收缩牵动所附着的骨绕着关节转动,使身体产生各种动作。所以,运动系统具有运动、支持和保护等功能,幼年时期的骨骼还具有造血功能。 ", |
| | | // txtIndex: 57 |
| | | // }); |
| | | // }, 5000); |
| | | // }, 500); |
| | | |
| | | // 获取题目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(); |
| | |
| | | spaceBetween: 30, // 间隔 |
| | | // 如果需要前进后退按钮 |
| | | navigation: { |
| | | nextEl: (this.container ? this.container : document).querySelector( |
| | | ".swiper-button-next" |
| | | ), |
| | | prevEl: (this.container ? this.container : document).querySelector( |
| | | ".swiper-button-prev" |
| | | ), |
| | | nextEl: dom.querySelector(".swiper-button-next"), |
| | | prevEl: dom.querySelector(".swiper-button-prev"), |
| | | }, |
| | | // 窗口变化,重新init,针对F11全屏和放大缩小,必须加 |
| | | observer: true, |
| | |
| | | spaceBetween: 30, // 间隔 |
| | | // 如果需要前进后退按钮 |
| | | navigation: { |
| | | nextEl: (this.container ? this.container : document).querySelector( |
| | | ".swiper-button-next" |
| | | ), |
| | | prevEl: (this.container ? this.container : document).querySelector( |
| | | ".swiper-button-prev" |
| | | ), |
| | | nextEl: dom.querySelector(".swiper-button-next"), |
| | | prevEl: dom.querySelector(".swiper-button-prev"), |
| | | }, |
| | | // 窗口变化,重新init,针对F11全屏和放大缩小,必须加 |
| | | observer: true, |
| | |
| | | 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 |
| | | } |
| | | } 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]; |
| | | // 数学公式加类名去修改样式 |
| | | if(item.type && item.type == 'material') { |
| | | if(!item.infoList.length) return false |
| | | item.infoList.forEach(citem => { |
| | | if(citem.answer) citem.answer = citem.answer.replace(/\<math/gi, '<math class="examination-math"') |
| | | }) |
| | | } else { |
| | | if(item.answer) item.answer = item.answer.replace(/\<math/gi, '<math class="examination-math"') |
| | | } |
| | | item.isCollect = this.collectId.indexOf(item.id) > -1 ? true :false |
| | | 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, |