zhongshujie
2024-08-06 924121953fb670fd3c2278fffc26b65b57620110
src/books/artAndDrama/view/components/chapter002.vue
@@ -249,7 +249,7 @@
            <span>视频:惟妙惟肖的人物 </span>
            <el-tooltip class="item" effect="dark" :content="chapterData.isCollectVideo ? '点击取消' : '点击收藏'"
              placement="top-start">
              <img :src="chapterData.isCollectVideo ? collectCheck : collectImg" alt="" class="collect-btn"
              <img :src="collectResourceList.findIndex(item => item.id == 'a3c9b55ac8227e4c885384ff2fc6c0e7') > -1 ? collectCheck : collectImg" alt="" class="collect-btn"
                @click="handleCollect('video')" />
            </el-tooltip>
          </p>
@@ -267,6 +267,7 @@
<script>
import drag from "@/components/dragQuestion/index.vue"
import { getResourcePath } from "@/assets/methods/resources";
import { getCollectResource, setCollectResource } from "@/assets/methods/resources";
export default {
  name: "chapterTwo",
  components: { drag },
@@ -276,12 +277,17 @@
    },
  },
  //在这里对调用的方法进行挂载
  mounted() {
  async mounted() {
    this.getVidoePath();
    const bookQuestion = localStorage.getItem("artAndDrama-book-question-two");
    if (bookQuestion) {
      this.questionData = JSON.parse(bookQuestion);
    }
    const data = localStorage.getItem("artAndDrama-chapter02-Data");
    if (data) {
      this.chapterData = JSON.parse(data);
    }
    this.collectResourceList = await getCollectResource(this.config.activeBook.bookId)
  },
  data() {
    return {
@@ -294,6 +300,7 @@
      auidoPathFour: "",
      auidoPathFive: "",
      isFocused: null, // 用于跟踪textarea的聚焦状态
      collectResourceList:[],
      chapterData: {
        isCollectImg: false,
        isCollectVideo: false,
@@ -476,7 +483,6 @@
      this.isFocused = null; // 当textarea失去焦点时,设置为false  
    }, 
    setBookQuestion() {
      console.log("保存");
      localStorage.setItem(
        "artAndDrama-book-question-two",
        JSON.stringify(this.questionData)
@@ -484,18 +490,34 @@
    },
    handleChapterData() {
      localStorage.setItem(
        "math-chapterData",
        "artAndDrama-chapter02-Data",
        JSON.stringify(this.chapterData)
      );
    },
    handleCollect(type) {
      if (type == "img") {
        this.chapterData.isCollectImg = !this.chapterData.isCollectImg;
      } else if (type == "video") {
        this.chapterData.isCollectVideo = !this.chapterData.isCollectVideo;
      if (type == "video") {
        this.handleCollectResource("a3c9b55ac8227e4c885384ff2fc6c0e7","a3c9b55ac8227e4c885384ff2fc6c0e7",'',"视频","bits",'视频:惟妙惟肖的人物')
      }
      this.handleChapterData();
    },
      //资源收藏事件
      handleCollectResource(id, md5, resourcePath, resourceType, source, resourceName) {
      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>