like.vue
1.92 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
<template>
<div class="book-video-list">
<template v-for="item in prodList" :key="item" style="height: 3rem;">
<video-card :item="item"></video-card>
</template>
<div style="height: 2rem;"></div>
</div>
<van-empty v-if="emptyStatus"
class="custom-image"
:image="no_image"
description="暂无点赞"
/>
</template>
<script setup>
import VideoCard from '@/components/VideoCard/index.vue'
import Cookies from 'js-cookie'
import no_image from '@images/que-shuju@2x.png'
import { ref } from 'vue'
import axios from '@/utils/axios';
import { Toast } from 'vant';
import $ from 'jquery'
import _ from 'lodash'
/******************** 返回点击位置 ********************/
window.addEventListener('scroll', () => {
if (window.scrollY) {
Cookies.set('scrollTopLike', window.scrollY);
}
})
const scrollTopLike = Cookies.get('scrollTopLike') ? Number(Cookies.get('scrollTopLike')) : 0;
if (scrollTopLike) {
setTimeout(() => {
$("html,body").animate({ "scrollTop": scrollTopLike })
}, 500)
}
/*****************************************************/
// 处理书籍下作品列表
const prodList = ref([])
// 因为不能让空图标提前出来的写法
const emptyStatus = ref(false);
axios.get('/srv/?a=my_like')
.then(res => {
if (res.data.code === 1) {
prodList.value = res.data.data.prod;
_.each(prodList.value, (item) => {
item.type = 'read-only'; // 特殊标识,判断入口 为keepAlive使用
})
if (!res.data.data.prod.length) {
emptyStatus.value = true;
}
} else {
console.warn(res);
if (!res.data.show) return false;
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
});
</script>
<script>
import mixin from 'common/mixin';
export default {
mixins: [mixin.init],
data () {
return {
}
},
mounted () {
},
methods: {
}
}
</script>
<style lang="less" scoped>
</style>