jiuyiUniapp/jiuyi/components/mine/like.vue

105 lines
1.7 KiB
Vue

<script setup>
/**
* 我的作品组件
*/
import {
ref,
reactive,
onMounted,
computed
} from 'vue'
import {
useStore
} from 'vuex'
// 工具库
import util from '@/common/js/util';
// api
import api from '@/api/index.js'
// 视频菜单
import videoMenu from '@/components/index/videoMenu.vue';
// 列表数据
const list = reactive({
data: [],
pageSize: 10,
pageNum: 1,
total: 0,
})
// 仓库
const store = useStore()
// 用户信息
const userinfo = computed(() => {
let result = store.state.userinfo
return result
})
onMounted(() => {
getList()
})
// 刷新列表
function refreshList() {
list.pageNum = 1
list.total = 0
getList()
}
// 获取更多列表
function getMoreList() {
if (list.data.length >= list.total) return
list.pageNum++
getList()
}
// 获取列表
function getList() {
//
api.video.myLikeVideoList({
query: {
userId: userinfo.value.userId,
pageSize: list.pageSize,
pageNum: list.pageNum,
}
}).then(rs => {
if (rs.code == 200) {
if (list.pageNum == 1) list.data.length = []
list.data.push(...rs.rows.map(item => {
item.format_videoUrl = util.format_url(item.videoUrl, 'video')
item.format_imageUrl = util.format_url(item.imageUrl, 'img')
return item
}))
list.total = rs.total
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
/**
* 点击我的作品
* @param {Object} item
*/
function handleItem(item) {
console.log(item)
}
//
defineExpose({
getList,
getMoreList,
refreshList,
})
</script>
<template>
<view class="">
<videoMenu :list="list.data" />
</view>
</template>
<style lang="scss" scoped>
//
</style>