164 lines
3.0 KiB
Vue
164 lines
3.0 KiB
Vue
<script setup>
|
|
// 我的评论
|
|
import {
|
|
ref,
|
|
reactive,
|
|
computed,
|
|
getCurrentInstance,
|
|
} from 'vue';
|
|
import {
|
|
onLoad,
|
|
onReady,
|
|
onUnload,
|
|
onPageScroll,
|
|
onReachBottom,
|
|
onPullDownRefresh
|
|
} from '@dcloudio/uni-app'
|
|
import {
|
|
useStore,
|
|
} from 'vuex'
|
|
import api from '@/api/index.js'
|
|
// 工具库
|
|
import util from '@/common/js/util';
|
|
|
|
// 仓库
|
|
const store = useStore()
|
|
// 数据列表
|
|
const list = reactive({
|
|
data: [],
|
|
pageSize: 20,
|
|
pageNum: 1,
|
|
total: 0,
|
|
})
|
|
// 用户信息
|
|
const userinfo = computed(() => {
|
|
return store.state.userinfo
|
|
})
|
|
|
|
onLoad((option) => {
|
|
if (option.userId) {
|
|
uni.setNavigationBarTitle({
|
|
title: '他的评论'
|
|
})
|
|
getList(option.userId)
|
|
} else {
|
|
getList()
|
|
}
|
|
})
|
|
|
|
onReachBottom(() => {
|
|
// 获取更多列表
|
|
getMoreVideoList()
|
|
})
|
|
|
|
onPullDownRefresh(() => {
|
|
// 刷新
|
|
refreshVideoList()
|
|
})
|
|
|
|
// 重载视频列表
|
|
function refreshVideoList() {
|
|
list.pageNum = 1
|
|
list.total = 0
|
|
getLst()
|
|
}
|
|
|
|
// 获取更多视频列表
|
|
function getMoreVideoList() {
|
|
if (list.data.length >= list.total) return
|
|
list.pageNum++
|
|
getLst()
|
|
}
|
|
|
|
// 获取我的评论
|
|
function getLst() {
|
|
api.mine.myComment({
|
|
query: {
|
|
userId: userinfo.value.id,
|
|
pageNum: list.pageNum,
|
|
pageSize: list.pageSize,
|
|
}
|
|
}).then(rs => {
|
|
if (rs.code == 200) {
|
|
if (list.pageNum) list.data.length = 0
|
|
// 追加视频列表
|
|
list.data.push(...rs.rows.map(item => {
|
|
return item
|
|
}))
|
|
// 视频列表
|
|
list.total = rs.total
|
|
console.log('list', list.data)
|
|
return
|
|
}
|
|
util.alert({
|
|
content: rs.msg,
|
|
showCancel: false,
|
|
})
|
|
}).finally(() => {
|
|
uni.stopPullDownRefresh()
|
|
})
|
|
}
|
|
|
|
// 获取我的评论
|
|
function getList(id) {
|
|
api.mine.myComment({
|
|
query: {
|
|
userId: id ? id : userinfo.value.id,
|
|
pageNum: list.pageNum,
|
|
pageSize: list.pageSize,
|
|
}
|
|
}).then(rs => {
|
|
if (rs.code == 200) {
|
|
if (list.pageNum) list.data.length = 0
|
|
// 追加视频列表
|
|
list.data.push(...rs.data[0].CommentVo.map(item => {
|
|
return item
|
|
}))
|
|
// 视频列表
|
|
list.total = rs.total
|
|
console.log('list', list.data)
|
|
return
|
|
}
|
|
util.alert({
|
|
content: rs.msg,
|
|
showCancel: false,
|
|
})
|
|
}).finally(() => {
|
|
uni.stopPullDownRefresh()
|
|
})
|
|
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<view class="appbw">
|
|
<view class="listBox plr30 ">
|
|
<view class="list ptb30 plr10" v-for="(item, index) in list.data" :key="index">
|
|
<view class="rows">
|
|
<view class="message">
|
|
<view class="title f32 c333">评论了{{ item.commentType }}</view>
|
|
<view class="content t2hd mtb15 c333 f32">{{ item.content }}</view>
|
|
<view class="time mt15 f28 c999">{{ item.createTime }}</view>
|
|
</view>
|
|
<view class="image ml20" v-if="item.imageUrl">
|
|
<image class="wh120 br10" :src="item.imageUrl" mode="aspectFill" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 暂无评论 -->
|
|
<view class="nomore mtb30" v-if="!list.data[0]">暂无内容~</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<style scoped lang="scss">
|
|
//
|
|
.listBox {
|
|
|
|
// 列表
|
|
.list+.list {
|
|
border-top: 2rpx solid #eee;
|
|
}
|
|
}
|
|
</style> |