hookehuyr

✨ feat: 我的作品新增分页功能

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-18 22:16:10 3 * @Date: 2022-05-18 22:16:10
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-24 22:18:36 5 + * @LastEditTime: 2022-09-06 11:32:16
6 * @FilePath: /tswj/src/api/C/me.js 6 * @FilePath: /tswj/src/api/C/me.js
7 * @Description: 我的页面接口操作 7 * @Description: 我的页面接口操作
8 */ 8 */
...@@ -19,6 +19,7 @@ const Api = { ...@@ -19,6 +19,7 @@ const Api = {
19 DEL_COMMENT: '/srv/?a=del_comment', 19 DEL_COMMENT: '/srv/?a=del_comment',
20 MY_SUBSCRIBE: '/srv/?a=my_subscribe', 20 MY_SUBSCRIBE: '/srv/?a=my_subscribe',
21 MY_FOLLOW: '/srv/?a=my_follow', 21 MY_FOLLOW: '/srv/?a=my_follow',
22 + MY_PROD: '/srv/?a=my_prod',
22 } 23 }
23 24
24 /** 25 /**
...@@ -90,3 +91,9 @@ export const mySubscribeAPI = (params) => fn(fetch.get(Api.MY_SUBSCRIBE, params) ...@@ -90,3 +91,9 @@ export const mySubscribeAPI = (params) => fn(fetch.get(Api.MY_SUBSCRIBE, params)
90 * @returns 91 * @returns
91 */ 92 */
92 export const myFollowAPI = (params) => fn(fetch.get(Api.MY_FOLLOW, params)); 93 export const myFollowAPI = (params) => fn(fetch.get(Api.MY_FOLLOW, params));
94 +
95 +/**
96 + * @description: 我的作品
97 + * @returns
98 + */
99 +export const myProdAPI = (params) => fn(fetch.get(Api.MY_PROD, params));
......
1 <template> 1 <template>
2 <div class="book-video-list"> 2 <div class="book-video-list">
3 - <template v-for="item in prodList" :key="item" style="height: 3rem;"> 3 + <van-list
4 + v-model:loading="loading"
5 + :finished="finished"
6 + :finished-text="finishedTextStatus ? '没有更多了' : ''"
7 + @load="onLoad"
8 + >
9 + <template v-for="item in prodList" :key="item" style="height: 3rem">
4 <audit-video-card :item="item"></audit-video-card> 10 <audit-video-card :item="item"></audit-video-card>
5 </template> 11 </template>
6 - <div style="height: 2rem;"></div> 12 + </van-list>
13 + <!-- <template v-for="item in prodList" :key="item" style="height: 3rem">
14 + <audit-video-card :item="item"></audit-video-card>
15 + </template> -->
16 + <div style="height: 2rem"></div>
7 </div> 17 </div>
8 - <van-empty v-if="emptyStatus" 18 + <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无作品" />
9 - class="custom-image"
10 - :image="no_image"
11 - description="暂无作品"
12 - />
13 </template> 19 </template>
14 20
15 <script setup> 21 <script setup>
16 -import no_image from '@images/que-shuju@2x.png' 22 + import no_image from '@images/que-shuju@2x.png';
17 -import AuditVideoCard from '@/components/AuditVideoCard/index.vue' 23 + import AuditVideoCard from '@/components/AuditVideoCard/index.vue';
24 + import _ from 'lodash';
18 25
19 -import { ref } from 'vue' 26 + import { myProdAPI } from '@/api/C/me.js';
20 -import axios from '@/utils/axios';
21 -import { Toast } from 'vant';
22 27
23 -// 处理书籍下作品列表 28 + // 处理书籍下作品列表
24 -const prodList = ref([]) 29 + const prodList = ref([]);
25 -// 因为不能让空图标提前出来的写法 30 + // 因为不能让空图标提前出来的写法
26 -const emptyStatus = ref(false); 31 + const emptyStatus = ref(false);
27 -axios.get('/srv/?a=my_prod') 32 +
28 -.then(res => { 33 + const limit = ref(10);
29 - if (res.data.code === 1) { 34 + const offset = ref(0);
30 - res.data.data.prod.forEach(v => { 35 +
31 - v.status = v.status.toUpperCase(); 36 + // 处理书籍下作品列表
32 - v.path = 'myVideoList' 37 + const loading = ref(false);
33 - }) 38 + const finished = ref(false);
34 - prodList.value = res.data.data.prod; 39 +
35 - if (!res.data.data.prod.length) { 40 + // 因为不能让空图标提前出来的写法
36 - emptyStatus.value = true; 41 + const finishedTextStatus = ref(false);
37 - } else { 42 +
38 - emptyStatus.value = false; 43 + /**
39 - } 44 + * 向下滚动查询数据
40 - } else { 45 + */
41 - console.warn(res); 46 + const onLoad = async () => {
42 - if (!res.data.show) return false; 47 + // 异步更新数据
43 - Toast({ 48 + const { data, code } = await myProdAPI({ limit: limit.value, offset: offset.value });
44 - icon: 'close', 49 + if (code === 1) {
45 - message: res.data.msg 50 + _.each(data.prod, (item) => {
51 + item.status = item.status.toUpperCase();
52 + item.path = 'myVideoList';
46 }); 53 });
54 + prodList.value = _.concat(prodList.value, data.prod);
55 + // prodList.value = _.uniqBy(prodList.value, 'id');
56 + offset.value = prodList.value.length;
57 + loading.value = false;
58 + // 数据全部加载完成
59 + if (prodList.value.length === data.prod_num) {
60 + // 加载状态结束
61 + finished.value = true;
62 + }
63 + // 空数据提示
64 + if (!prodList.value.length) {
65 + finishedTextStatus.value = false;
47 } 66 }
48 -}) 67 + emptyStatus.value = Object.is(prodList.value.length, 0);
49 -.catch(err => { 68 + }
50 - console.error(err); 69 + };
51 -})
52 </script> 70 </script>
53 71
54 <script> 72 <script>
55 -import mixin from 'common/mixin'; 73 + import mixin from 'common/mixin';
56 74
57 -export default { 75 + export default {
58 mixins: [mixin.init], 76 mixins: [mixin.init],
59 - data () { 77 + data() {
60 - return { 78 + return {};
61 - }
62 - },
63 - mounted () {
64 -
65 }, 79 },
66 - methods: { 80 + mounted() {},
67 - 81 + methods: {},
68 - } 82 + };
69 -}
70 </script> 83 </script>
71 84
72 -<style lang="less" scoped> 85 +<style lang="less" scoped></style>
73 -
74 -</style>
......