hookehuyr

✨ feat(作品详情页): 新增视频播放控件

1 +<template>
2 + <div class="video-wrapper">
3 + <div class="video-div" :id="'mui-player-' + item.case_id"></div>
4 + <div class="video-bar">
5 + <van-row style="text-align: center;">
6 + <van-col span="7">
7 + <span style="color: #777777;">
8 + 3068次播放
9 + </span>
10 + </van-col>
11 + <van-col span="1" style="color: #EEEDED;">
12 + |
13 + </van-col>
14 + <van-col span="8">
15 + <span @click="setCollect">
16 + <van-icon v-if="!detail.collected" :name="icon_shoucang1" size="1.2rem" style="vertical-align: bottom;" />
17 + <van-icon v-else :name="icon_shoucang2" size="1.2rem" style="vertical-align: bottom;" />
18 + 10086
19 + </span>
20 + </van-col>
21 + <van-col span="1" style="color: #EEEDED;">
22 + |
23 + </van-col>
24 + <van-col span="7">
25 + <span @click="setLike()">
26 + <van-icon v-if="!detail.liked" :name="icon_dianzan1" size="1.2rem" style="vertical-align: bottom;" />
27 + <van-icon v-else :name="icon_dianzan2" size="1.2rem" style="vertical-align: bottom;" />
28 + 10086
29 + </span>
30 + </van-col>
31 + </van-row>
32 + </div>
33 + </div>
34 +</template>
35 +
36 +<script setup>
37 +import icon_dianzan1 from '@images/icon-dianzan01@2x.png'
38 +import icon_dianzan2 from '@images/icon-dianzan02@2x.png'
39 +import icon_shoucang1 from '@images/icon-shoucang01@2x.png'
40 +import icon_shoucang2 from '@images/icon-shoucang02@2x.png'
41 +
42 +import { ref, reactive, onMounted } from 'vue'
43 +import 'mui-player/dist/mui-player.min.css'
44 +import MuiPlayer from 'mui-player'
45 +import _ from 'lodash';
46 +
47 +import { useRoute, useRouter } from 'vue-router'
48 +const $route = useRoute();
49 +const $router = useRouter();
50 +
51 +const goTo = () => { // 跳转作品详情页
52 + $router.push({
53 + path: '/client/videoDetail'
54 + });
55 +}
56 +
57 +onMounted(() => {
58 +})
59 +
60 +</script>
61 +
62 +<script>
63 +export default {
64 + props: ['item'],
65 + data() {
66 + return {
67 + detail: {}
68 + }
69 + },
70 + created() {
71 + },
72 + mounted() {
73 + var mp = new MuiPlayer({
74 + container: '#mui-player-' + this.item.case_id,
75 + title: this.item.title,
76 + src: this.item.video.url,
77 + poster: this.item.cover.url,
78 + autoFit: false,
79 + videoAttribute: [ // 声明启用同层播放, 不让会自动全屏播放
80 + {attrKey:'webkit-playsinline',attrValue:'webkit-playsinline'},
81 + {attrKey:'playsinline',attrValue:'playsinline'},
82 + {attrKey:'x5-video-player-type',attrValue:'h5-page'},
83 + ]
84 + })
85 + this.detail = _.cloneDeep(this.item)
86 + },
87 + methods: {
88 + setCollect() {
89 + this.detail.collected = !this.detail.collected
90 + },
91 + setLike() {
92 + this.detail.liked = !this.detail.liked
93 + },
94 + setCommit() {
95 + console.warn('跳转详情页,移动到留言页');
96 + console.warn(this.detail.case_id);
97 + }
98 + }
99 +}
100 +</script>
101 +
102 +<style lang="less" scoped>
103 +.video-wrapper {
104 + .video-bar {
105 + color: #713610;
106 + padding: 1rem;
107 + padding-bottom: 0.5rem;
108 + }
109 +}
110 +</style>
...\ No newline at end of file ...\ No newline at end of file