QYF-GitLab1
12 小时以前 b5d1cc7fde9823f39c0c9595f21c7aee2582ac59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
    <div class="video-box">
        <div class="video-title">
            <p class="video-title-name">
                配套视频: {{ videoName }}
            </p>
            <p class="video-title-img">
                <img @click="isDisplay = !isDisplay" :src=videoIcon alt="">
                <el-tooltip class="item" effect="dark" :content="localIsCollectVideo ? '点击取消' : '点击收藏'"
                    placement="top-start">
                    <img :src="collectResourceList.findIndex(
                        (item) => item.id == videoPath
                    ) > -1
                        ? collectCheck
                        : collectImg
                        " alt="" class="collect-btn" @click="handleCollect()" />
                </el-tooltip>
            </p>
        </div>
        <div class="video-main" v-if="isDisplay">
            <video :src="videoPathSrc" webkit-playsinline="true" x-webkit-airplay="true" playsinline="true"
                x5-video-orientation="h5" x5-video-player-fullscreen="true" x5-playsinline="" controls
                controlslist="nodownload" class="w100 video"></video>
 
        </div>
    </div>
</template>
 
<script>
import { getResourcePath } from "@/assets/methods/resources";
import { getCollectResource, setCollectResource } from "@/assets/methods/resources";
export default {
    data() {
        return {
            videoIcon: require("../../assets/images/videoLogo.png"),
            collectCheck: require("../../assets/images/heart-check.png"),
            collectImg: require("../../assets/images/heart.png"),
            videoPathSrc: "",
            collectResourceList: [],
            localIsCollectVideo: this.isCollectVideo,
            isDisplay: true,
        };
    },
    props: {
        videoPath: {
            type: String,
            required: "",
        },
        videoName: {
            type: String,
            required: "",// 默认值
        },
        BookId: {
            type: String,
            required: "",// 默认值
        },
        isCollectVideo: {
            type: Boolean,
            required: false,// 默认值
        }
    },
    computed: {
        // currentQuestion() {
        //     return this.questions[this.currentIndex];
        // },
        // setHoverStyles() {
        //     return {
        //         "--hover-bg-color": this.hoverBackgroundColor,
        //         "--hover-color": this.hoverColor,
        //     };
        // },
        // mergedStyles() {
        //     // 合并直接样式和计算属性样式
        //     return {
        //         borderColor: this.primaryColor,
        //         ...this.setHoverStyles,
        //     };
        // },
    },
    async mounted() {
        this.getVidoePath();
        this.collectResourceList = await getCollectResource(
            this.BookId
        );
    },
    methods: {
        async getVidoePath() {
            this.videoPathSrc = await getResourcePath(
                this.videoPath
            );
            debugger
        },
 
        handleCollect() {
            this.handleCollectResource(
                this.videoPath,
                this.videoPath,
                "",
                "视频",
                "bits",
                "视频:" + this.videoName
            );
            this.localIsCollectVideo = !this.localIsCollectVideo;
            this.$emit('saveVideoStatus')
        },
        //资源收藏事件
        // resourcePath  文件路径,
        // resourceType  文件类型
        // source        文件来源
        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.BookId,
                this.collectResourceList
            );
        },
    },
};
</script>
 
<style lang="less" scoped>
.video-box {
    margin: 20px 0 20px 0;
    border: 1px solid #40C7F4;
 
}
 
.video-title {
    display: flex;
    justify-content: space-between;
    background-color: #c7eaf9;
    border-bottom: 1px solid #40C7F4;
    min-height: 25px;
}
 
.video-title-name {
    padding: 0 2%;
    display: flex;
    text-indent: 0em;
    margin: 0 !important;
    border-right: 1px solid #40C7F4;
}
 
.video-title-img {
    padding-right: 2%;
    text-indent: 0em;
    display: flex;
 
    img {
        cursor: pointer;
    }
}
 
.video-main {
    margin: 5% 5%;
    border: 1px dashed #40C7F4;
}
 
.collect-btn {
    cursor: pointer;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    margin-top: 0.3%;
}
 
.w100 {
    width: 100%;
}
 
</style>