hookehuyr

✨ feat(我的作品): 完善列表状态显示

1 +<template>
2 + <div class="video-wrapper" style="position: relative;">
3 + <div class="status">
4 + <van-image v-if="item.status === 'ENABLE'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_enable" />
5 + <van-image v-if="item.status === 'REFUSE'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_refuse" />
6 + <van-image v-if="item.status === 'APPLY'" round width="6rem" height="6rem" style="vertical-align: bottom;" :src="icon_apply" />
7 + </div>
8 + <div class="video-div" :id="'mui-player-' + item.case_id">
9 + </div>
10 + <div v-if="item.status === 'ENABLE'" >
11 + <div class="video-bar">
12 + <van-row>
13 + <van-col span="12" @click="goTo">
14 + <van-image round width="2rem" height="2rem" style="vertical-align: bottom;"
15 + src="https://cdn.jsdelivr.net/npm/@vant/assets/cat.jpeg" />&nbsp;
16 + <span style="font-size: 1.05rem;">王忆慈</span>
17 + </van-col>
18 + <van-col span="12">
19 + <div style="padding: 0.25rem; padding-top: 0.75rem; text-align: right;">
20 + <span @click="setComment">
21 + <van-icon :name="icon_liuyan" size="1.2rem" style="vertical-align: bottom;" />
22 + 67
23 + </span>
24 + &nbsp;&nbsp;&nbsp;
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 + </div>
31 + </van-col>
32 + </van-row>
33 + </div>
34 + <div @click="goTo" style="color: #999999; padding: 0px 1rem 0.5rem;">杨浦民办科技幼稚园 | 藏语</div>
35 + </div>
36 + <div v-else style="margin-top: 1rem;">
37 + <div style="color: #222222; padding: 0px 1rem 0.5rem;">杨浦民办科技幼稚园 | 藏语</div>
38 + <div v-if="item.status === 'REFUSE'" style="padding: 0 1rem 1rem 1rem; font-size: 0.85rem;">
39 + <p style="color: #999999; margin-bottom: 0.25rem;">老师留言:</p>
40 + <p>下次我们继续加油,争取有更好的表现哦~</p>
41 + </div>
42 + </div>
43 + </div>
44 +</template>
45 +
46 +<script setup>
47 +import icon_dianzan1 from '@images/icon-dianzan01@2x.png'
48 +import icon_dianzan2 from '@images/icon-dianzan02@2x.png'
49 +import icon_liuyan from '@images/icon-liuyan@2x.png'
50 +import icon_refuse from '@images/icon-jujue@2x.png'
51 +import icon_apply from '@images/icon-shenhe@2x.png'
52 +import icon_enable from '@images/icon-tongguo@2x.png'
53 +
54 +import { ref, reactive, onMounted } from 'vue'
55 +import 'mui-player/dist/mui-player.min.css'
56 +import MuiPlayer from 'mui-player'
57 +import _ from 'lodash';
58 +
59 +import { useRoute, useRouter } from 'vue-router'
60 +const $route = useRoute();
61 +const $router = useRouter();
62 +
63 +const goTo = () => { // 跳转作品详情页
64 + $router.push({
65 + path: '/client/videoDetail'
66 + });
67 +}
68 +
69 +onMounted(() => {
70 +})
71 +
72 +</script>
73 +
74 +<script>
75 +export default {
76 + props: ['item'],
77 + data() {
78 + return {
79 + detail: {}
80 + }
81 + },
82 + created() {
83 + },
84 + mounted() {
85 + var mp = new MuiPlayer({
86 + container: '#mui-player-' + this.item.case_id,
87 + title: this.item.title,
88 + src: this.item.video.url,
89 + poster: this.item.cover.url,
90 + autoFit: false,
91 + videoAttribute: [ // 声明启用同层播放, 不让会自动全屏播放
92 + {attrKey:'webkit-playsinline',attrValue:'webkit-playsinline'},
93 + {attrKey:'playsinline',attrValue:'playsinline'},
94 + {attrKey:'x5-video-player-type',attrValue:'h5-page'},
95 + ]
96 + })
97 + this.detail = _.cloneDeep(this.item)
98 + },
99 + methods: {
100 + setLike() {
101 + this.detail.liked = !this.detail.liked
102 + },
103 + setComment() {
104 + console.warn('跳转详情页,移动到留言页');
105 + console.warn(this.detail.case_id);
106 + }
107 + }
108 +}
109 +</script>
110 +
111 +<style lang="less" scoped>
112 +.video-wrapper {
113 + margin: 1rem;
114 + border-bottom-left-radius: 5px;
115 + border-bottom-right-radius: 5px;
116 + box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.13);
117 + .status {
118 + position: absolute;
119 + top: 0;
120 + right: 0;
121 + z-index: 999;
122 + }
123 + .video-div {
124 + border-top-left-radius: 5px;
125 + border-top-right-radius: 5px;
126 + }
127 + .video-bar {
128 + color: #713610;
129 + padding: 1rem;
130 + padding-bottom: 0.5rem;
131 + }
132 +}
133 +</style>
...\ No newline at end of file ...\ No newline at end of file
...@@ -44,7 +44,7 @@ const data = [ ...@@ -44,7 +44,7 @@ const data = [
44 "uid": 1564543218846, 44 "uid": 1564543218846,
45 "status": "success" 45 "status": "success"
46 }, 46 },
47 - "status": "ENABLE", 47 + "status": "APPLY",
48 "public_vote": 3346, 48 "public_vote": 3346,
49 "score": 0, 49 "score": 0,
50 "award": null, 50 "award": null,
...@@ -71,7 +71,7 @@ const data = [ ...@@ -71,7 +71,7 @@ const data = [
71 "uid": 1564543218846, 71 "uid": 1564543218846,
72 "status": "success" 72 "status": "success"
73 }, 73 },
74 - "status": "ENABLE", 74 + "status": "REFUSE",
75 "public_vote": 4125, 75 "public_vote": 4125,
76 "score": 0, 76 "score": 0,
77 "award": null, 77 "award": null,
......
1 <template> 1 <template>
2 - <div class=""></div> 2 + <div class="book-video-list">
3 + <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
4 + <template v-for="item in dataList" :key="item" style="height: 3rem;">
5 + <audit-video-card :item="item"></audit-video-card>
6 + </template>
7 + </van-list>
8 + </div>
3 </template> 9 </template>
4 10
5 <script setup> 11 <script setup>
12 +import dataList from '@/mock/video_list'
13 +import AuditVideoCard from '@/components/AuditVideoCard/index.vue'
14 +
6 import { ref, reactive, onMounted } from 'vue' 15 import { ref, reactive, onMounted } from 'vue'
7 import { useRoute, useRouter } from 'vue-router' 16 import { useRoute, useRouter } from 'vue-router'
8 import axios from '@/utils/axios'; 17 import axios from '@/utils/axios';
...@@ -11,6 +20,29 @@ import { Toast } from 'vant'; ...@@ -11,6 +20,29 @@ import { Toast } from 'vant';
11 const $route = useRoute(); 20 const $route = useRoute();
12 const $router = useRouter(); 21 const $router = useRouter();
13 22
23 +// 处理书籍下作品列表
24 +const list = ref([]);
25 +const loading = ref(false);
26 +const finished = ref(false);
27 +
28 +const onLoad = () => {
29 + // 异步更新数据
30 + // setTimeout 仅做示例,真实场景中一般为 ajax 请求
31 + setTimeout(() => {
32 + for (let i = 0; i < 20; i++) {
33 + list.value.push(list.value.length + 1);
34 + }
35 +
36 + // 加载状态结束
37 + loading.value = false;
38 +
39 + // 数据全部加载完成
40 + if (list.value.length >= 100) {
41 + finished.value = true;
42 + }
43 + }, 1000);
44 +};
45 +
14 onMounted(() => { 46 onMounted(() => {
15 47
16 }) 48 })
......