546 行
12 KiB
Vue
546 行
12 KiB
Vue
<template>
|
||
<view class="report-page fc-page">
|
||
<!-- 顶部统一渐变沉浸式导航栏 -->
|
||
<fc-navbar title="我的举报" theme="gradient" :show-back="true" />
|
||
|
||
<!-- 状态筛选栏 -->
|
||
<view class="report-tabs">
|
||
<view
|
||
v-for="tab in tabs"
|
||
:key="tab.value"
|
||
class="report-tabs__item"
|
||
:class="{ 'report-tabs__item--active': activeStatus === tab.value }"
|
||
@click="switchTab(tab.value)"
|
||
>
|
||
<text>{{ tab.label }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 首屏骨架加载态 -->
|
||
<view v-if="loading && !list.length" class="report-page__loading">
|
||
<view v-for="i in 3" :key="i" class="fc-skeleton report-page__skeleton"></view>
|
||
</view>
|
||
|
||
<!-- 空数据提示 -->
|
||
<fc-empty
|
||
v-else-if="!list.length"
|
||
icon="inbox"
|
||
:text="emptyText"
|
||
btn-text="返回个人中心"
|
||
@action="goBack"
|
||
/>
|
||
|
||
<!-- 举报卡片列表 -->
|
||
<view v-else class="report-page__list">
|
||
<view
|
||
v-for="item in list"
|
||
:key="item.id"
|
||
class="report-card fc-card"
|
||
@click="goReportDetail(item)"
|
||
>
|
||
<!-- 卡片头部:对象类型徽章 + 原因 + 状态胶囊 -->
|
||
<view class="report-card__header">
|
||
<view class="report-card__tags">
|
||
<text class="report-card__type-tag" :class="'report-card__type-tag--' + item.targetType">
|
||
{{ item.targetType === 'post' ? '信息举报' : '评价举报' }}
|
||
</text>
|
||
<text class="report-card__reason-tag">{{ item.reason }}</text>
|
||
</view>
|
||
<view
|
||
class="report-card__status"
|
||
:class="item.status === 'handled' ? 'report-card__status--handled' : 'report-card__status--pending'"
|
||
>
|
||
<view class="report-card__status-dot"></view>
|
||
<text>{{ item.statusText }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 被举报对象摘要 -->
|
||
<view
|
||
class="report-card__target"
|
||
:class="{ 'report-card__target--link': canJumpTarget(item) }"
|
||
@click.stop="handleTargetClick(item)"
|
||
>
|
||
<text class="report-card__target-title fc-ellipsis-2">{{ item.targetTitle }}</text>
|
||
<view v-if="canJumpTarget(item)" class="report-card__target-link">
|
||
<text>原信息</text>
|
||
<text class="report-card__target-arrow">›</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 补充说明(单行精简展示) -->
|
||
<view v-if="item.detail" class="report-card__detail">
|
||
<text class="report-card__detail-label">说明:</text>
|
||
<text class="report-card__detail-text fc-ellipsis">{{ item.detail }}</text>
|
||
</view>
|
||
|
||
<!-- 凭证缩略图(最多展示 3 张,避免卡片过长) -->
|
||
<view v-if="item.images && item.images.length" class="report-card__images">
|
||
<image
|
||
v-for="(img, imgIdx) in item.images.slice(0, 3)"
|
||
:key="imgIdx"
|
||
class="report-card__img"
|
||
:src="assetUrl(img)"
|
||
mode="aspectFill"
|
||
@click.stop="previewImage(item.images, imgIdx)"
|
||
/>
|
||
<view v-if="item.images.length > 3" class="report-card__img-more">
|
||
<text>+{{ item.images.length - 3 }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 已处理简报 -->
|
||
<view v-if="item.status === 'handled'" class="report-card__result">
|
||
<image class="fc-icon fc-icon--xs" :src="iconUrl('verify')" mode="aspectFit" />
|
||
<text class="report-card__result-text fc-ellipsis">
|
||
{{ item.handleRemark || '平台已核实并完成处置' }}
|
||
</text>
|
||
</view>
|
||
|
||
<!-- 底部元信息:格式化时间 + 详情入口 -->
|
||
<view class="report-card__footer">
|
||
<text class="report-card__time">{{ formatTime(item.createdAt) }}</text>
|
||
<view class="report-card__more">
|
||
<text>查看详情</text>
|
||
<text class="report-card__more-arrow">›</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 分页底线 -->
|
||
<view class="report-page__more">
|
||
<text v-if="loading">加载中…</text>
|
||
<text v-else-if="!hasMore">— 没有更多了 —</text>
|
||
<text v-else @click="loadMore">点击加载更多</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
|
||
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
|
||
import reportApi from '@/common/api/report.js'
|
||
import { safeNavigateTo, safeBack } from '@/common/utils/nav.js'
|
||
import { iconUrl } from '@/common/store/ui.js'
|
||
import { assetUrl, formatTime } from '@/common/utils/format.js'
|
||
|
||
export default {
|
||
components: { FcNavbar, FcEmpty },
|
||
data() {
|
||
return {
|
||
tabs: [
|
||
{ label: '全部', value: '' },
|
||
{ label: '核实中', value: 'pending' },
|
||
{ label: '已处理', value: 'handled' },
|
||
],
|
||
activeStatus: '',
|
||
list: [],
|
||
page: 1,
|
||
size: 10,
|
||
total: 0,
|
||
hasMore: true,
|
||
loading: false,
|
||
}
|
||
},
|
||
computed: {
|
||
/**
|
||
* 根据当前筛选状态返回空状态提示文案
|
||
* @returns {string}
|
||
*/
|
||
emptyText() {
|
||
if (this.activeStatus === 'pending') return '暂无核实中的举报'
|
||
if (this.activeStatus === 'handled') return '暂无已处理的举报'
|
||
return '暂无举报记录'
|
||
},
|
||
},
|
||
/**
|
||
* 页面加载生命周期
|
||
*/
|
||
onLoad() {
|
||
this.fetchList(true)
|
||
},
|
||
/**
|
||
* 下拉刷新生命周期
|
||
*/
|
||
onPullDownRefresh() {
|
||
this.fetchList(true)
|
||
},
|
||
/**
|
||
* 页面上拉触底生命周期
|
||
*/
|
||
onReachBottom() {
|
||
if (this.hasMore && !this.loading) {
|
||
this.loadMore()
|
||
}
|
||
},
|
||
methods: {
|
||
iconUrl,
|
||
assetUrl,
|
||
formatTime,
|
||
/**
|
||
* 切换顶部状态筛选标签
|
||
* @param {string} status 状态值
|
||
*/
|
||
switchTab(status) {
|
||
if (this.activeStatus === status) return
|
||
this.activeStatus = status
|
||
this.fetchList(true)
|
||
},
|
||
/**
|
||
* 拉取我的举报列表数据
|
||
* @param {boolean} [reset=false] 是否重置为第一页
|
||
*/
|
||
async fetchList(reset = false) {
|
||
if (reset) {
|
||
this.page = 1
|
||
this.hasMore = true
|
||
}
|
||
if (this.loading) return
|
||
this.loading = true
|
||
try {
|
||
const params = { page: this.page, size: this.size }
|
||
if (this.activeStatus) {
|
||
params.status = this.activeStatus
|
||
}
|
||
const res = await reportApi.my(params)
|
||
const rows = (res && res.list) || []
|
||
this.total = (res && res.total) || 0
|
||
this.list = reset ? rows : [...this.list, ...rows]
|
||
this.hasMore = !!(res && res.hasMore)
|
||
} catch (e) {
|
||
uni.showToast({ title: e.message || '加载失败', icon: 'none' })
|
||
} finally {
|
||
this.loading = false
|
||
uni.stopPullDownRefresh()
|
||
}
|
||
},
|
||
/**
|
||
* 加载更多数据
|
||
*/
|
||
loadMore() {
|
||
if (!this.hasMore || this.loading) return
|
||
this.page += 1
|
||
this.fetchList(false)
|
||
},
|
||
/**
|
||
* 判断是否支持直接跳转到被举报原信息
|
||
* @param {Object} item 举报项对象
|
||
* @returns {boolean}
|
||
*/
|
||
canJumpTarget(item) {
|
||
return !!(
|
||
item &&
|
||
item.targetType === 'post' &&
|
||
item.targetId > 0 &&
|
||
item.targetExists !== false
|
||
)
|
||
},
|
||
/**
|
||
* 预览凭证图片
|
||
* @param {string[]} images 图片数组
|
||
* @param {number} current 当前选中的图片索引
|
||
*/
|
||
previewImage(images, current) {
|
||
if (!images || !images.length) return
|
||
const fullUrls = images.map((u) => assetUrl(u))
|
||
uni.previewImage({
|
||
urls: fullUrls,
|
||
current: fullUrls[current] || fullUrls[0],
|
||
})
|
||
},
|
||
/**
|
||
* 跳转至举报记录详情页
|
||
* @param {Object} item 举报项对象
|
||
*/
|
||
goReportDetail(item) {
|
||
if (!item || !item.id) return
|
||
safeNavigateTo(`/pages/mine/report-detail?id=${item.id}`)
|
||
},
|
||
/**
|
||
* 点击被举报对象(如果是信息且未删除,可跳转查看)
|
||
* @param {Object} item 举报项对象
|
||
*/
|
||
handleTargetClick(item) {
|
||
if (this.canJumpTarget(item)) {
|
||
safeNavigateTo(`/pages/detail/detail?id=${item.targetId}`)
|
||
return
|
||
}
|
||
this.goReportDetail(item)
|
||
},
|
||
/**
|
||
* 返回上一页
|
||
*/
|
||
goBack() {
|
||
safeBack()
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.report-page {
|
||
min-height: 100vh;
|
||
background: #F2FEF7;
|
||
padding-bottom: 40rpx;
|
||
|
||
&__loading {
|
||
padding: 24rpx;
|
||
}
|
||
|
||
&__skeleton {
|
||
height: 220rpx;
|
||
border-radius: $fc-radius;
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
&__list {
|
||
padding: 20rpx 24rpx 24rpx;
|
||
}
|
||
|
||
&__more {
|
||
text-align: center;
|
||
padding: 24rpx 0 10rpx;
|
||
font-size: $fc-font-xs;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
}
|
||
|
||
.report-tabs {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16rpx;
|
||
padding: 16rpx 24rpx 4rpx;
|
||
|
||
&__item {
|
||
padding: 10rpx 26rpx;
|
||
border-radius: 999rpx;
|
||
font-size: $fc-font-sm;
|
||
color: #64748B;
|
||
background: rgba(255, 255, 255, 0.85);
|
||
border: 1rpx solid #E2E8F0;
|
||
transition: all 0.2s;
|
||
|
||
&--active {
|
||
background: #00D26A;
|
||
color: #FFFFFF;
|
||
border-color: #00D26A;
|
||
font-weight: 600;
|
||
box-shadow: 0 4rpx 12rpx rgba(0, 210, 106, 0.22);
|
||
}
|
||
}
|
||
}
|
||
|
||
.report-card {
|
||
background: #FFFFFF;
|
||
border-radius: $fc-radius;
|
||
padding: 24rpx;
|
||
margin-bottom: 20rpx;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
|
||
|
||
&:active {
|
||
transform: scale(0.992);
|
||
}
|
||
|
||
&__header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 16rpx;
|
||
}
|
||
|
||
&__tags {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10rpx;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
&__type-tag {
|
||
font-size: 20rpx;
|
||
font-weight: 600;
|
||
padding: 4rpx 12rpx;
|
||
border-radius: 6rpx;
|
||
background: #E8F9F0;
|
||
color: #00A854;
|
||
|
||
&--comment {
|
||
background: #EFF6FF;
|
||
color: #2563EB;
|
||
}
|
||
}
|
||
|
||
&__reason-tag {
|
||
font-size: 20rpx;
|
||
padding: 4rpx 12rpx;
|
||
border-radius: 6rpx;
|
||
background: #F1F5F9;
|
||
color: #475569;
|
||
}
|
||
|
||
&__status {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 8rpx;
|
||
padding: 4rpx 14rpx;
|
||
border-radius: 999rpx;
|
||
font-size: 22rpx;
|
||
font-weight: 600;
|
||
flex-shrink: 0;
|
||
|
||
&-dot {
|
||
width: 10rpx;
|
||
height: 10rpx;
|
||
border-radius: 50%;
|
||
}
|
||
|
||
&--pending {
|
||
background: #FEF3C7;
|
||
color: #D97706;
|
||
|
||
.report-card__status-dot {
|
||
background: #F59E0B;
|
||
}
|
||
}
|
||
|
||
&--handled {
|
||
background: #E8F9F0;
|
||
color: #00A854;
|
||
|
||
.report-card__status-dot {
|
||
background: #00D26A;
|
||
}
|
||
}
|
||
}
|
||
|
||
&__target {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16rpx;
|
||
background: #F8FAFC;
|
||
border-radius: 10rpx;
|
||
padding: 16rpx 18rpx;
|
||
margin-bottom: 14rpx;
|
||
|
||
&--link:active {
|
||
background: #F1F5F9;
|
||
}
|
||
|
||
&-title {
|
||
font-size: $fc-font;
|
||
font-weight: 500;
|
||
color: #1E293B;
|
||
line-height: 1.45;
|
||
flex: 1;
|
||
}
|
||
|
||
&-link {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-shrink: 0;
|
||
font-size: $fc-font-xs;
|
||
color: #00A854;
|
||
font-weight: 500;
|
||
}
|
||
|
||
&-arrow {
|
||
font-size: 28rpx;
|
||
margin-left: 4rpx;
|
||
line-height: 1;
|
||
}
|
||
}
|
||
|
||
&__detail {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 14rpx;
|
||
font-size: $fc-font-sm;
|
||
line-height: 1.4;
|
||
|
||
&-label {
|
||
color: #64748B;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
&-text {
|
||
color: #334155;
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
}
|
||
|
||
&__images {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12rpx;
|
||
margin-bottom: 14rpx;
|
||
}
|
||
|
||
&__img {
|
||
width: 104rpx;
|
||
height: 104rpx;
|
||
border-radius: 8rpx;
|
||
background: #E2E8F0;
|
||
}
|
||
|
||
&__img-more {
|
||
width: 104rpx;
|
||
height: 104rpx;
|
||
border-radius: 8rpx;
|
||
background: #F1F5F9;
|
||
color: #64748B;
|
||
font-size: $fc-font-sm;
|
||
font-weight: 600;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
&__result {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10rpx;
|
||
padding: 12rpx 16rpx;
|
||
margin-bottom: 14rpx;
|
||
background: #F2FEF7;
|
||
border-radius: 8rpx;
|
||
border-left: 4rpx solid #00D26A;
|
||
|
||
&-text {
|
||
flex: 1;
|
||
min-width: 0;
|
||
font-size: $fc-font-xs;
|
||
color: #00A854;
|
||
}
|
||
}
|
||
|
||
&__footer {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding-top: 12rpx;
|
||
border-top: 1rpx solid #F1F5F9;
|
||
}
|
||
|
||
&__time {
|
||
font-size: $fc-font-xs;
|
||
color: $fc-text-placeholder;
|
||
}
|
||
|
||
&__more {
|
||
display: flex;
|
||
align-items: center;
|
||
font-size: $fc-font-xs;
|
||
color: #00A854;
|
||
font-weight: 600;
|
||
|
||
&-arrow {
|
||
font-size: 28rpx;
|
||
margin-left: 4rpx;
|
||
line-height: 1;
|
||
}
|
||
}
|
||
}
|
||
</style>
|