videoBar.vue
3.52 KB
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
<!--
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-23 14:30:57
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-07 15:26:03
* @FilePath: /tswj/src/components/MuiVideo/videoBar.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div v-if="barType === 1" class="video-bar">
<van-row>
<van-col span="12" @click="goToDetail(item, $router)">
<van-image round width="2rem" height="2rem" style="vertical-align: middle;"
:src="item.avatar ? item.avatar : icon_avatar" />
<span style="font-size: 1.05rem;vertical-align: middle;">{{ item.name }}</span>
</van-col>
<van-col span="12">
<div style="padding: 0.25rem; padding-top: 0.75rem; text-align: right;">
<span @click="setComment(item, $router)">
<van-icon :name="icon_liuyan" size="1.2rem" style="vertical-align: bottom;" />
{{ item.comment_num }}
</span>
<span @click="handleAction('like', detail.id)">
<van-icon v-if="!detail.is_like" :name="icon_dianzan1" size="1.2rem" style="vertical-align: bottom;" />
<van-icon v-else :name="icon_dianzan2" size="1.2rem" style="vertical-align: bottom;" />
{{ detail.like_num }}
</span>
</div>
</van-col>
</van-row>
</div>
<div v-if="barType === 2" class="video-bar">
<van-row style="text-align: center;">
<van-col span="7">
<span style="color: #777777;">
{{ item.play_num }}次播放
</span>
</van-col>
<van-col span="1" style="color: #EEEDED;">
|
</van-col>
<van-col span="8">
<span @click="handleAction('favor', detail.id)">
<van-icon v-if="!detail.is_favor" :name="icon_shoucang1" size="1.2rem" style="vertical-align: bottom;" />
<van-icon v-else :name="icon_shoucang2" size="1.2rem" style="vertical-align: bottom;" />
{{ detail.favor_num }}
</span>
</van-col>
<van-col span="1" style="color: #EEEDED;">
|
</van-col>
<van-col span="7">
<span @click="handleAction('like', detail.id)">
<van-icon v-if="!detail.is_like" :name="icon_dianzan1" size="1.2rem" style="vertical-align: bottom;" />
<van-icon v-else :name="icon_dianzan2" size="1.2rem" style="vertical-align: bottom;" />
{{ detail.like_num }}
</span>
</van-col>
</van-row>
</div>
</template>
<script setup>
import { icon_shoucang1, icon_shoucang2, icon_dianzan1, icon_dianzan2, icon_liuyan, icon_avatar } from '@/utils/generateIcons.js'
import { ref } from 'vue';
import { goToDetail, setComment, prodAction } from './methods';
import _ from 'lodash';
import { prodInfoAPI } from '@/api/C/prod.js'
const props = defineProps({
item: Object,
barType: Number
});
const detail = ref({});
detail.value = _.cloneDeep(props.item);
const handleAction = async (type, id) => {
if (await prodAction(type, id)) {
getProductDetail(type, id)
}
}
// 查询作品详情
async function getProductDetail(action_type, prod_id) {
const { data } = await prodInfoAPI({ prod_id });
// 更新详情显示
detail.value[`is_${action_type}`] = data[`is_${action_type}`];
detail.value[`${action_type}_num`] = data[`${action_type}_num`];
}
</script>
<style lang="less" scoped>
.video-bar {
color: #713610;
padding: 1rem;
padding-bottom: 0.5rem;
}
</style>