| | |
| | | placement="top-start" |
| | | > |
| | | <img |
| | | :src="chapterData.isCollectImg ? collectCheck : collectImg" |
| | | :src="collectResourceList.findIndex(item => item.id == '722FE833') > -1 ? collectCheck : collectImg" |
| | | alt="" |
| | | class="collect-btn" |
| | | @click="handleCollect('img')" |
| | |
| | | placement="top-start" |
| | | > |
| | | <img |
| | | :src="chapterData.isCollectVideo ? collectCheck : collectImg" |
| | | :src="collectResourceList.findIndex(item => item.id == 'a28cd862d61b5df2201406b76e9f01b0') > -1 ? collectCheck : collectImg" |
| | | alt="" |
| | | class="collect-btn" |
| | | @click="handleCollect('video')" |
| | |
| | | </p> |
| | | <div class="bj"> |
| | | <examinations |
| | | :cardList="questionData" |
| | | :cardList="questionData[9]" |
| | | :hideCollect="true" |
| | | sourceType="json" |
| | | inputBc="#d3edfa" |
| | | v-if="questionData" |
| | | :isReal="false" |
| | |
| | | <script> |
| | | import examinations from "@/components/examinations/index.vue"; |
| | | import { getResourcePath } from "@/assets/methods/resources"; |
| | | import axios from "axios"; |
| | | import { getCollectResource,setCollectResource } from "@/assets/methods/resources"; |
| | | export default { |
| | | name: "chapter-one", |
| | | components: { examinations }, |
| | |
| | | type: Array, |
| | | default: [], |
| | | }, |
| | | questionData:{ |
| | | type:Object |
| | | } |
| | | }, |
| | | mounted() { |
| | | async mounted() { |
| | | const data = localStorage.getItem("math-chapterData"); |
| | | if (data) { |
| | | this.chapterData = JSON.parse(data); |
| | | } |
| | | this.getPath(); |
| | | this.getQuestionData(); |
| | | this.collectResourceList = await getCollectResource(this.config.activeBook.bookId) |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | thinkingDialog: false, |
| | | stepDialog: false, |
| | | videoPath: "", |
| | | questionData: [], |
| | | stepIndex: 1, |
| | | thinkIndex: 1, |
| | | collectResourceList:[], |
| | | chapterData: { |
| | | isCollectImg: false, |
| | | isCollectVideo: false, |
| | |
| | | "a28cd862d61b5df2201406b76e9f01b0" |
| | | ); |
| | | }, |
| | | getQuestionData() { |
| | | axios |
| | | .get(this.config.activeBook.resourceUrl + "/question.json") |
| | | .then((res) => { |
| | | let oldAnswer = localStorage.getItem( |
| | | this.config.activeBook.name + "oldAnswerData" |
| | | ); |
| | | if (oldAnswer) { |
| | | oldAnswer = JSON.parse(oldAnswer); |
| | | console.log("旧数据", oldAnswer); |
| | | if (oldAnswer[9]) { |
| | | for (let index = 0; index < res.data.data.length; index++) { |
| | | const item = res.data.data[index]; |
| | | if (item.infoList.length) { |
| | | for ( |
| | | let cindex = 0; |
| | | cindex < item.infoList.length; |
| | | cindex++ |
| | | ) { |
| | | const citem = item.infoList[cindex]; |
| | | const question = oldAnswer[9].find( |
| | | (ditem) => ditem.id == citem.id |
| | | ); |
| | | if (question) { |
| | | citem.userAnswer = question.userAnswer; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | this.questionData = res.data.data; |
| | | }); |
| | | }, |
| | | // getQuestionData() { |
| | | // axios |
| | | // .get(this.config.activeBook.resourceUrl + "/question.json") |
| | | // .then((res) => { |
| | | // let oldAnswer = localStorage.getItem( |
| | | // this.config.activeBook.name + "oldAnswerData" |
| | | // ); |
| | | // if (oldAnswer) { |
| | | // oldAnswer = JSON.parse(oldAnswer); |
| | | // console.log("旧数据", oldAnswer); |
| | | // if (oldAnswer[9]) { |
| | | // for (let index = 0; index < res.data.data.length; index++) { |
| | | // const item = res.data.data[index]; |
| | | // if (item.infoList.length) { |
| | | // for ( |
| | | // let cindex = 0; |
| | | // cindex < item.infoList.length; |
| | | // cindex++ |
| | | // ) { |
| | | // const citem = item.infoList[cindex]; |
| | | // const question = oldAnswer[9].find( |
| | | // (ditem) => ditem.id == citem.id |
| | | // ); |
| | | // if (question) { |
| | | // citem.userAnswer = question.userAnswer; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // this.questionData = res.data.data; |
| | | // }); |
| | | // }, |
| | | handleCollect(type) { |
| | | if (type == "img") { |
| | | this.chapterData.isCollectImg = !this.chapterData.isCollectImg; |
| | | this.handleCollectResource("722FE833","",'images/0101-1.jpg',"图片","json",'图3-15') |
| | | } else if (type == "video") { |
| | | this.chapterData.isCollectVideo = !this.chapterData.isCollectVideo; |
| | | this.handleCollectResource("a28cd862d61b5df2201406b76e9f01b0","a28cd862d61b5df2201406b76e9f01b0",'',"视频","bits",'视频:判数函数奇偶性的方法和步骤') |
| | | // setCollectResource(this.config.activeBook.bookId,[]) |
| | | } |
| | | this.handleChapterData(); |
| | | }, |
| | |
| | | this.stepIndex++; |
| | | } |
| | | }, |
| | | //资源收藏事件 |
| | | handleCollectResource(id,md5,resourcePath,resourceType,source,resourceName){ |
| | | console.log(this.collectResourceList); |
| | | let list = this.collectResourceList |
| | | if(list.findIndex(item => item.id == id) > -1) { |
| | | list = list.filter(item => item.id != id) |
| | | } else { |
| | | list.push({ |
| | | id, |
| | | md5, |
| | | resourcePath, |
| | | resourceType, |
| | | source, |
| | | resourceName, |
| | | }) |
| | | } |
| | | this.collectResourceList = list |
| | | setCollectResource(this.config.activeBook.bookId,this.collectResourceList) |
| | | } |
| | | }, |
| | | }; |
| | | </script> |