jiuyiUniapp/jiuyi2/components/mine/product.vue

108 lines
1.8 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<script setup>
/**
* 我的作品组件
*/
import {
ref,
reactive,
2025-01-19 13:55:21 +08:00
onMounted,
computed
2024-12-18 15:46:27 +08:00
} from 'vue'
2025-01-19 13:55:21 +08:00
//
import {
useStore,
} from 'vuex'
2024-12-18 15:46:27 +08:00
// 工具库
import util from '@/common/js/util';
// api
import api from '@/api/index.js'
// 视频菜单
import videoMenu from '@/components/index/videoMenu.vue';
// 列表数据
const list = reactive({
data: [],
2025-01-19 13:55:21 +08:00
pageSize: 9,
2024-12-18 15:46:27 +08:00
pageNum: 1,
total: 0,
})
2025-01-19 13:55:21 +08:00
const store = useStore()
// 用户信息
const userinfo = computed(() => store.state.userinfo)
2024-12-18 15:46:27 +08:00
onMounted(() => {
getList()
// 删除视频
uni.$on('deleteVideo', (videoId) => {
const findIndex = list.data.findIndex(node => node.videoId == videoId)
if (findIndex > 0) list.data.splice(findIndex, 1)
})
})
// 刷新列表
function refreshList() {
list.pageNum = 1
list.total = 0
getList()
}
// 获取更多列表
function getMoreList() {
if (list.data.length >= list.total) return
list.pageNum++
getList()
}
// 获取列表
function getList() {
//
2025-01-19 13:55:21 +08:00
api.video.myWorks({
2024-12-18 15:46:27 +08:00
query: {
2025-01-19 13:55:21 +08:00
userId: userinfo.value.id,
2024-12-18 15:46:27 +08:00
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" isMine="1" />
</view>
</template>
<style lang="scss" scoped>
//
</style>