闫增涛
2024-06-26 172199d84e17b2285aef2c1112fbed3c6f25f27c
src/books/mathBook/view/components/chapter001.vue
@@ -156,7 +156,7 @@
              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')"
@@ -184,7 +184,7 @@
              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')"
@@ -575,7 +575,6 @@
        </div>
      </div>
    </div>
    <!-- 函数控件弹窗 -->
    <el-dialog
      :visible.sync="dialogVisible"
@@ -819,7 +818,7 @@
<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 },
@@ -832,13 +831,13 @@
      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 {
@@ -855,6 +854,7 @@
      videoPath: "",
      stepIndex: 1,
      thinkIndex: 1,
      collectResourceList:[],
      chapterData: {
        isCollectImg: false,
        isCollectVideo: false,
@@ -885,6 +885,80 @@
          isShow: false,
        },
      ],
      dragQuestion:[
          {
          analysisCon: null,
          answer: ['A','B','C'],
          difficulty: 0,
          id: "7BC7B760",
          isCollect: false,
          isComplete: false,
          isRight: null,
          isUnfold: "",
          isUserAnswer: false,
          number: 1,
          option: [
            {
              img: "",
              index: "010311",
              txt: "胆小的",
              value: "A",
              isShow:true
            },
            {
              img: "",
              index: "010312",
              txt: "善良的",
              value: "B",
              isShow:true
            },
            {
              img: "",
              index: "010313",
              txt: "沉稳的",
              value: "C",
              isShow:true
            },
          ],
          optionStyle: "Txt",
          questionType: "drag",
          score: 2,
          stem: {
            0: "蚂蚁队长走路昂首挺胸、步伐坚定,它是一只(",
            1:{
              data: "span",
              num: 0
            },
            2: ")蚂蚁;小蚂蚁走起路来小心翼翼,眼神飘忽不定,它是一只(",
            3:{
              data:"span",
              num:1
            },
            4:")蚂蚁;蚂蚁小妹面带微笑,时刻愿意帮助大家,它是一只(",
            5:{
              data:"span",
              num:2,
            },
            6:" )蚂蚁"
          },
          stemStyle: "RichTxt",
          type: "拖拽题",
          userAnswer:[
            {
              vlaue:'',
              txt:''
            },
            {
              vlaue:'',
              txt:''
            },
            {
              vlaue:'',
              txt:''
            },
          ]
        },
      ]
    };
  },
  methods: {
@@ -935,9 +1009,10 @@
    // },
    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();
    },
@@ -962,6 +1037,25 @@
        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>