yiming
2024-08-07 e89d2f02233370260faa26eae68819f94e906e14
src/books/artAndDrama/view/components/chapter004.vue
@@ -133,7 +133,7 @@
                    <h3 class="lefth3" id="c038" style="margin-top: 7%;"><img class="img-gn1" alt=""
                            src="../../assets/images/czysj.jpg" /></h3>
                    <p class="text"><span class="hs1">◇</span>邀请同伴共同完成《一块奶酪》的展演吧!</p>
                    <p class="center openImgBox"><img class="img-e" alt="" src="../../assets/images/4-2.gif" /></p>
                    <p class="center openImgBox"><img class="img-e" alt="" src="../../assets/images/0036-2.jpg" /></p>
                </div>
                <!-- 此次为页脚部分(需要设置页码) -->
                <div class="page-footer">
@@ -212,8 +212,8 @@
                        <span>视频:团结就是力量 </span>
                        <el-tooltip class="item" effect="dark" :content="chapterData.isCollectVideo ? '点击取消' : '点击收藏'"
                            placement="top-start">
                            <img :src="chapterData.isCollectVideo ? collectCheck : collectImg" alt=""
                                class="collect-btn" @click="handleCollect('video')" />
                            <img :src="collectResourceList.findIndex(item => item.id == '691cbd2c13198d04afc7800d0f2cafb0') > -1 ? collectCheck : collectImg"
                                alt="" class="collect-btn" @click="handleCollect('video')" />
                        </el-tooltip>
                    </p>
                </div>
@@ -229,6 +229,7 @@
<script>
import { getResourcePath } from "@/assets/methods/resources";
import graffiti from '@/components/graffiti/index.vue'
import { getCollectResource, setCollectResource } from "@/assets/methods/resources";
export default {
    name: "chapterFour",
    props: {
@@ -238,12 +239,18 @@
    },
    components: { graffiti },
    //在这里对调用的方法进行挂载
    mounted() {
    async mounted() {
        this.getVidoePath();
        const bookQuestion = localStorage.getItem("artAndDrama-book-question-four");
        if (bookQuestion) {
            this.questionData = JSON.parse(bookQuestion);
        }
        const data = localStorage.getItem("artAndDrama-chapter04-Data");
        if (data) {
            this.chapterData = JSON.parse(data);
        }
        this.collectResourceList = await getCollectResource(this.config.activeBook.bookId)
    },
    data() {
        return {
@@ -256,6 +263,7 @@
            audioPathFour: "",
            audioPathFive: "",
            isFocused: null, // 用于跟踪textarea的聚焦状态
            collectResourceList: [],
            chapterData: {
                isCollectImg: false,
                isCollectVideo: false,
@@ -319,7 +327,6 @@
            this.isFocused = null; // 当textarea失去焦点时,设置为false  
        },
        setBookQuestion() {
            console.log("保存");
            localStorage.setItem(
                "artAndDrama-book-question-four",
                JSON.stringify(this.questionData)
@@ -327,18 +334,34 @@
        },
        handleChapterData() {
            localStorage.setItem(
                "math-chapterData",
                "artAndDrama-chapter04-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("09de7704eeaaf3a210b8c6af0a94d545", "09de7704eeaaf3a210b8c6af0a94d545", '', "视频", "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>