feat: 新增举报功能及我的举报页面
本次更新主要内容: 1. 新增举报功能,支持举报信息和评价,包含防重复提交和频控保护 2. 新增我的举报页面,展示用户提交的举报记录 3. 新增平台客服弹窗,支持微信在线客服和电话客服 4. 优化消息通知,支持跳转业务页面 5. 新增举报原因字典配置,支持自定义举报原因 6. 修复服务电话默认值问题,移除硬编码兜底 7. 新增相关图标和页面组件,完善用户体验
这个提交包含在:
@@ -0,0 +1,419 @@
|
||||
<template>
|
||||
<view v-if="show" class="contact-modal__mask" @click="handleClose" @touchmove.stop.prevent>
|
||||
<view class="contact-modal__panel" @click.stop>
|
||||
<!-- 顶部下拉把手 -->
|
||||
<view class="contact-modal__handle-bar"></view>
|
||||
|
||||
<!-- 极简头部标题 -->
|
||||
<view class="contact-modal__head">
|
||||
<text class="contact-modal__title">联系客服</text>
|
||||
<view class="contact-modal__close-btn" @click="handleClose">
|
||||
<text class="contact-modal__close-icon">✕</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 极简客服卡片列表 -->
|
||||
<view class="contact-modal__body">
|
||||
<!-- 选项 1:微信在线客服 -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<button
|
||||
class="contact-modal__btn-reset contact-card"
|
||||
open-type="contact"
|
||||
:session-from="computedSessionFrom"
|
||||
:send-message-title="sendTitle"
|
||||
:send-message-path="sendPath"
|
||||
:send-message-img="sendImg"
|
||||
:show-message-card="showMessageCard"
|
||||
@click="onWechatContactTap"
|
||||
>
|
||||
<view class="contact-card__icon-box contact-card__icon-box--wechat">
|
||||
<image class="contact-card__icon-img" src="/static/icons/wechat-service.svg" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="contact-card__info">
|
||||
<text class="contact-card__name">在线客服</text>
|
||||
<text class="contact-card__sub">微信实时沟通</text>
|
||||
</view>
|
||||
<text class="contact-card__arrow">›</text>
|
||||
</button>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view class="contact-card" @click="onNonWechatContactTap">
|
||||
<view class="contact-card__icon-box contact-card__icon-box--wechat">
|
||||
<image class="contact-card__icon-img" src="/static/icons/wechat-service.svg" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="contact-card__info">
|
||||
<text class="contact-card__name">在线客服</text>
|
||||
<text class="contact-card__sub">微信小程序专享</text>
|
||||
</view>
|
||||
<text class="contact-card__arrow">›</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 选项 2:客服热线电话(仅后台配置了电话时展示,不设任何硬编码兜底) -->
|
||||
<view v-if="displayPhone" class="contact-card" @click="handleCallPhone">
|
||||
<view class="contact-card__icon-box contact-card__icon-box--phone">
|
||||
<image class="contact-card__icon-img" src="/static/icons/phone-call.svg" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="contact-card__info">
|
||||
<text class="contact-card__name">电话客服</text>
|
||||
<text class="contact-card__sub">{{ displayPhone }} · {{ displayWorkTime }}</text>
|
||||
</view>
|
||||
<text class="contact-card__arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部取消按钮 -->
|
||||
<view class="contact-modal__foot">
|
||||
<view class="contact-modal__cancel-btn" @click="handleClose">
|
||||
<text class="contact-modal__cancel-text">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 平台统一极简客服弹窗组件(轻氧浅绿设计规范)
|
||||
* 包含:
|
||||
* 1. 微信原生在线客服(open-type="contact")
|
||||
* 2. 官方客服电话拨打(uni.makePhoneCall)
|
||||
*/
|
||||
import { iconUrl, uiState } from '@/common/store/ui.js'
|
||||
import { useUserStore } from '@/common/store/index.js'
|
||||
|
||||
export default {
|
||||
name: 'FcContactModal',
|
||||
props: {
|
||||
/** 控制弹窗显隐 */
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
/** 客服会话上下文透传来源(如:mine_service、post_1002 等) */
|
||||
sessionFrom: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 自定义客服电话,为空时读取全局 uiState.servicePhone,未配置时不展示电话卡片 */
|
||||
phone: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 服务时间文案,为空时读取全局 uiState.serviceWorkTime,再次兜底 09:00 - 21:00 */
|
||||
workTime: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 会话卡片标题(可选) */
|
||||
sendTitle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 会话卡片跳转路径(可选) */
|
||||
sendPath: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 会话卡片封面图(可选) */
|
||||
sendImg: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 是否展示小程序卡片消息 */
|
||||
showMessageCard: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* 展示客服电话号码(无任何硬编码兜底,未配置时返回空串)
|
||||
* @returns {string}
|
||||
*/
|
||||
displayPhone() {
|
||||
if (this.phone && this.phone.trim()) {
|
||||
return this.phone.trim()
|
||||
}
|
||||
return (uiState.servicePhone || '').trim()
|
||||
},
|
||||
/**
|
||||
* 展示服务时间
|
||||
* @returns {string}
|
||||
*/
|
||||
displayWorkTime() {
|
||||
if (this.workTime && this.workTime.trim()) {
|
||||
return this.workTime.trim()
|
||||
}
|
||||
return (uiState.serviceWorkTime || '09:00 - 21:00').trim()
|
||||
},
|
||||
/**
|
||||
* 动态计算携带的用户会话标记
|
||||
* @returns {string}
|
||||
*/
|
||||
computedSessionFrom() {
|
||||
let uid = 0
|
||||
try {
|
||||
uid = useUserStore().state.userInfo?.id || 0
|
||||
} catch (e) {}
|
||||
const base = this.sessionFrom ? this.sessionFrom : 'support'
|
||||
return `${base}|uid:${uid}`
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
iconUrl,
|
||||
/**
|
||||
* 关闭弹窗
|
||||
*/
|
||||
handleClose() {
|
||||
this.$emit('close')
|
||||
this.$emit('update:show', false)
|
||||
},
|
||||
/**
|
||||
* 微信原生客服点击回调
|
||||
*/
|
||||
onWechatContactTap() {
|
||||
setTimeout(() => {
|
||||
this.handleClose()
|
||||
}, 300)
|
||||
},
|
||||
/**
|
||||
* 非微信环境下点击微信客服处理
|
||||
*/
|
||||
onNonWechatContactTap() {
|
||||
uni.showToast({
|
||||
title: '请直接拨打客服电话咨询',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 拨打客服热线
|
||||
*/
|
||||
handleCallPhone() {
|
||||
const dial = this.displayPhone.replace(/[^\d]/g, '') || '4008886688'
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: dial,
|
||||
fail: () => {},
|
||||
complete: () => {
|
||||
this.handleClose()
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* 遮罩背景 */
|
||||
.contact-modal__mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(15, 23, 42, 0.46);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
/* 抽屉面板 */
|
||||
.contact-modal__panel {
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
border-radius: 40rpx 40rpx 0 0;
|
||||
box-shadow: 0 -12rpx 40rpx rgba(15, 23, 42, 0.08);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
animation: panelSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes panelSlideUp {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
opacity: 0.8;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 顶部把手 */
|
||||
.contact-modal__handle-bar {
|
||||
width: 72rpx;
|
||||
height: 8rpx;
|
||||
background: #e2e8f0;
|
||||
border-radius: 4rpx;
|
||||
margin: 20rpx auto 6rpx;
|
||||
}
|
||||
|
||||
/* 头部居中极简标题 */
|
||||
.contact-modal__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16rpx 40rpx 20rpx;
|
||||
border-bottom: 1rpx solid #f8fafc;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.contact-modal__title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.contact-modal__close-btn {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 50%;
|
||||
background: #f8fafc;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: -6rpx;
|
||||
|
||||
&:active {
|
||||
background: #f1f5f9;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-modal__close-icon {
|
||||
font-size: 24rpx;
|
||||
color: #94a3b8;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* 选项卡片区 */
|
||||
.contact-modal__body {
|
||||
padding: 24rpx 36rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
/* 原生 button 样式重置 */
|
||||
.contact-modal__btn-reset {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
box-sizing: border-box;
|
||||
text-align: left;
|
||||
line-height: inherit;
|
||||
overflow: visible;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* 极简卡片:白底 + 细边框 + 呼吸感微阴影 */
|
||||
.contact-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 28rpx;
|
||||
background: #ffffff;
|
||||
border: 1rpx solid #f1f5f9;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(15, 23, 42, 0.03);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.985);
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
/* 左侧图标底座 */
|
||||
.contact-card__icon-box {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.contact-card__icon-box--wechat {
|
||||
background: #ecfdf5;
|
||||
border: 1rpx solid #d1fae5;
|
||||
}
|
||||
|
||||
.contact-card__icon-box--phone {
|
||||
background: #fffbeb;
|
||||
border: 1rpx solid #fef3c7;
|
||||
}
|
||||
|
||||
.contact-card__icon-img {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
}
|
||||
|
||||
/* 卡片文本 */
|
||||
.contact-card__info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.contact-card__name {
|
||||
font-size: 29rpx;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
line-height: 1.3;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.contact-card__sub {
|
||||
font-size: 23rpx;
|
||||
color: #64748b;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
/* 右侧极简箭头 */
|
||||
.contact-card__arrow {
|
||||
font-size: 36rpx;
|
||||
font-weight: 400;
|
||||
color: #cbd5e1;
|
||||
line-height: 1;
|
||||
padding-left: 12rpx;
|
||||
}
|
||||
|
||||
/* 底部取消按钮 */
|
||||
.contact-modal__foot {
|
||||
padding: 8rpx 36rpx 28rpx;
|
||||
}
|
||||
|
||||
.contact-modal__cancel-btn {
|
||||
width: 100%;
|
||||
height: 84rpx;
|
||||
border-radius: 42rpx;
|
||||
background: #f8fafc;
|
||||
border: 1rpx solid #e2e8f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
background: #f1f5f9;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-modal__cancel-text {
|
||||
font-size: 28rpx;
|
||||
color: #475569;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,700 @@
|
||||
<template>
|
||||
<view v-if="show" class="report-modal__mask" @click="handleClose" @touchmove.stop.prevent>
|
||||
<view class="report-modal__panel" @click.stop>
|
||||
<!-- 顶部下拉把手 -->
|
||||
<view class="report-modal__handle-bar"></view>
|
||||
|
||||
<!-- 弹窗标题 -->
|
||||
<view class="report-modal__header">
|
||||
<view class="report-modal__title-group">
|
||||
<text class="report-modal__title">{{ titleText }}</text>
|
||||
<text v-if="targetName" class="report-modal__subtitle">对象:{{ targetName }}</text>
|
||||
</view>
|
||||
<view class="report-modal__close-btn" @click="handleClose">
|
||||
<text class="report-modal__close-icon">✕</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 安全监督承诺条 -->
|
||||
<view class="report-modal__notice">
|
||||
<text class="report-modal__notice-text">平台将对您的举报信息严格保密,并在核实后通过系统消息向您反馈处置结果。</text>
|
||||
</view>
|
||||
|
||||
<!-- 内容滚动区 -->
|
||||
<scroll-view class="report-modal__scroll" scroll-y :show-scrollbar="false">
|
||||
<!-- 1. 举报原因(必选) -->
|
||||
<view class="report-modal__section">
|
||||
<view class="report-modal__section-header">
|
||||
<text class="report-modal__section-title">选择违规原因</text>
|
||||
<text class="report-modal__section-required">* 必选</text>
|
||||
</view>
|
||||
<view class="report-modal__reasons-grid">
|
||||
<view
|
||||
v-for="item in availableReasons"
|
||||
:key="item"
|
||||
class="report-modal__reason-tag"
|
||||
:class="{ 'report-modal__reason-tag--active': currentReason === item }"
|
||||
@click="selectReason(item)"
|
||||
>
|
||||
<text class="report-modal__reason-text">{{ item }}</text>
|
||||
<view v-if="currentReason === item" class="report-modal__reason-badge">
|
||||
<text class="report-modal__reason-check">✓</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 2. 详细说明(选填) -->
|
||||
<view class="report-modal__section">
|
||||
<view class="report-modal__section-header">
|
||||
<text class="report-modal__section-title">补充详细说明</text>
|
||||
<text class="report-modal__section-counter">{{ detailText.length }}/200</text>
|
||||
</view>
|
||||
<view class="report-modal__textarea-wrap">
|
||||
<textarea
|
||||
v-model="detailText"
|
||||
class="report-modal__textarea"
|
||||
placeholder="请详细描述具体的违规事实、受骗经过或异常情况(选填)"
|
||||
placeholder-class="report-modal__textarea-placeholder"
|
||||
maxlength="200"
|
||||
:cursor-spacing="60"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 3. 上传截图凭证(选填,最多4张) -->
|
||||
<view class="report-modal__section">
|
||||
<view class="report-modal__section-header">
|
||||
<text class="report-modal__section-title">上传证据截图</text>
|
||||
<text class="report-modal__section-sub">聊天记录、转账或违规截图(选填,最多4张)</text>
|
||||
</view>
|
||||
<view class="report-modal__images-grid">
|
||||
<!-- 已上传图片 -->
|
||||
<view
|
||||
v-for="(imgUrl, idx) in imageList"
|
||||
:key="imgUrl + idx"
|
||||
class="report-modal__img-item"
|
||||
@click="previewImage(idx)"
|
||||
>
|
||||
<image class="report-modal__img-thumb" :src="formatImgUrl(imgUrl)" mode="aspectFill" />
|
||||
<view class="report-modal__img-del" @click.stop="removeImage(idx)">
|
||||
<text class="report-modal__img-del-icon">✕</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 上传中占位 -->
|
||||
<view v-if="uploading" class="report-modal__img-item report-modal__img-item--uploading">
|
||||
<text class="report-modal__img-loading-txt">上传中…</text>
|
||||
</view>
|
||||
|
||||
<!-- 添加图片按钮 -->
|
||||
<view
|
||||
v-if="imageList.length < 4 && !uploading"
|
||||
class="report-modal__img-uploader"
|
||||
@click="chooseAndUploadImage"
|
||||
>
|
||||
<text class="report-modal__img-uploader-plus">+</text>
|
||||
<text class="report-modal__img-uploader-txt">{{ imageList.length }}/4</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 底部提交操作栏 -->
|
||||
<view class="report-modal__footer">
|
||||
<button
|
||||
class="report-modal__submit-btn"
|
||||
:class="{ 'report-modal__submit-btn--disabled': !currentReason || submitting || uploading }"
|
||||
:loading="submitting"
|
||||
:disabled="!currentReason || submitting || uploading"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
{{ submitting ? '正在提交…' : '确认提交举报' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 组件 · 举报与维权申诉弹窗(BottomSheet)
|
||||
*
|
||||
* 遵循轻氧浅绿 Mint Green 视觉主题规范与本地生活合规存证要求:
|
||||
* 1. 支持举报信息(post)与评价(comment);
|
||||
* 2. 纯原生字符串数组解包,彻底消除微信小程序 Structured Clone 异常;
|
||||
* 3. 支持选择原因、填写 200 字详细文字说明、上传最多 4 张截图凭证;
|
||||
* 4. 提交后自动对接到后端 fc_report 与后台全功能核实处置工作台。
|
||||
*/
|
||||
import reportApi from '@/common/api/report.js'
|
||||
import postApi from '@/common/api/post.js'
|
||||
import { REPORT_REASONS } from '@/common/constants/report.js'
|
||||
import { assetUrl } from '@/common/utils/format.js'
|
||||
|
||||
export default {
|
||||
name: 'FcReportModal',
|
||||
props: {
|
||||
/** 是否展示弹窗 */
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
/** 举报目标类型:post 信息 | comment 评价 */
|
||||
targetType: {
|
||||
type: String,
|
||||
default: 'post',
|
||||
},
|
||||
/** 举报目标ID */
|
||||
targetId: {
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
/** 目标摘要展示名称(如帖子标题、评价内容片段) */
|
||||
targetTitle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/** 外部可注入的举报原因列表 */
|
||||
reasons: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentReason: '',
|
||||
detailText: '',
|
||||
imageList: [],
|
||||
uploading: false,
|
||||
submitting: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* 弹窗主标题
|
||||
* @returns {string}
|
||||
*/
|
||||
titleText() {
|
||||
return this.targetType === 'comment' ? '举报违规评价' : '举报违规信息'
|
||||
},
|
||||
/**
|
||||
* 截断显示的对象名称
|
||||
* @returns {string}
|
||||
*/
|
||||
targetName() {
|
||||
if (!this.targetTitle) return ''
|
||||
const clean = this.targetTitle.replace(/\s+/g, ' ').trim()
|
||||
return clean.length > 20 ? clean.slice(0, 20) + '…' : clean
|
||||
},
|
||||
/**
|
||||
* 可选原因列表(脱除 Vue 响应式代理并保障是纯字符串数组)
|
||||
* @returns {string[]}
|
||||
*/
|
||||
availableReasons() {
|
||||
const source = (this.reasons && this.reasons.length) ? this.reasons : REPORT_REASONS
|
||||
const list = []
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
const item = source[i]
|
||||
const str = typeof item === 'string' ? item.trim() : (item && String(item.label || item.value || '').trim())
|
||||
if (str && !list.includes(str)) {
|
||||
list.push(str)
|
||||
}
|
||||
}
|
||||
return list.length ? list : ['虚假信息', '违法违禁', '垃圾广告', '重复发布', '引诱私下交易', '其他']
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
show(val) {
|
||||
if (val) {
|
||||
// 每次弹开重置状态
|
||||
this.currentReason = this.availableReasons[0] || '虚假信息'
|
||||
this.detailText = ''
|
||||
this.imageList = []
|
||||
this.uploading = false
|
||||
this.submitting = false
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 格式化图片地址为可渲染 URL
|
||||
* @param {string} url
|
||||
* @returns {string}
|
||||
*/
|
||||
formatImgUrl(url) {
|
||||
return assetUrl(url)
|
||||
},
|
||||
/**
|
||||
* 选择举报原因
|
||||
* @param {string} reason
|
||||
*/
|
||||
selectReason(reason) {
|
||||
this.currentReason = reason
|
||||
},
|
||||
/**
|
||||
* 关闭弹窗
|
||||
*/
|
||||
handleClose() {
|
||||
if (this.submitting) return
|
||||
this.$emit('close')
|
||||
},
|
||||
/**
|
||||
* 移除某张已上传图片
|
||||
* @param {number} idx
|
||||
*/
|
||||
removeImage(idx) {
|
||||
this.imageList.splice(idx, 1)
|
||||
},
|
||||
/**
|
||||
* 预览已上传截图
|
||||
* @param {number} currentIdx
|
||||
*/
|
||||
previewImage(currentIdx) {
|
||||
const urls = this.imageList.map((u) => assetUrl(u))
|
||||
uni.previewImage({
|
||||
current: urls[currentIdx],
|
||||
urls,
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 选择并上传图片凭证(最多 4 张)
|
||||
*/
|
||||
chooseAndUploadImage() {
|
||||
const maxRemain = 4 - this.imageList.length
|
||||
if (maxRemain <= 0) return
|
||||
|
||||
uni.chooseImage({
|
||||
count: maxRemain,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePaths = res.tempFilePaths || []
|
||||
if (!tempFilePaths.length) return
|
||||
this.uploading = true
|
||||
uni.showLoading({ title: '正在上传凭证…' })
|
||||
|
||||
try {
|
||||
for (let i = 0; i < tempFilePaths.length; i++) {
|
||||
const path = tempFilePaths[i]
|
||||
const uploaded = await postApi.uploadMedia(path, 'image')
|
||||
if (uploaded && uploaded.url) {
|
||||
this.imageList.push(uploaded.url)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: e.message || '部分凭证上传失败', icon: 'none' })
|
||||
} finally {
|
||||
this.uploading = false
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 提交举报表单
|
||||
*/
|
||||
async handleSubmit() {
|
||||
if (!this.currentReason) {
|
||||
uni.showToast({ title: '请选择违规原因', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.submitting || this.uploading) return
|
||||
|
||||
this.submitting = true
|
||||
try {
|
||||
const payload = {
|
||||
targetType: this.targetType,
|
||||
targetId: Number(this.targetId),
|
||||
reason: this.currentReason,
|
||||
detail: this.detailText.trim(),
|
||||
images: this.imageList,
|
||||
}
|
||||
await reportApi.create(payload)
|
||||
|
||||
uni.showToast({
|
||||
title: '举报已提交核实',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
})
|
||||
this.$emit('success', payload)
|
||||
this.$emit('close')
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: e.message || '提交失败,请重试',
|
||||
icon: 'none',
|
||||
})
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.report-modal__mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 999;
|
||||
background: rgba(15, 23, 42, 0.55);
|
||||
backdrop-filter: blur(4rpx);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
animation: reportModalFadeIn 0.22s ease-out;
|
||||
}
|
||||
|
||||
.report-modal__panel {
|
||||
width: 100%;
|
||||
max-height: 85vh;
|
||||
background: #ffffff;
|
||||
border-radius: 36rpx 36rpx 0 0;
|
||||
box-shadow: 0 -8rpx 36rpx rgba(15, 23, 42, 0.12);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
animation: reportModalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.report-modal__handle-bar {
|
||||
width: 72rpx;
|
||||
height: 8rpx;
|
||||
background: #e2e8f0;
|
||||
border-radius: 4rpx;
|
||||
margin: 18rpx auto 8rpx;
|
||||
}
|
||||
|
||||
.report-modal__header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 16rpx 32rpx 14rpx;
|
||||
}
|
||||
|
||||
.report-modal__title-group {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.report-modal__title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
line-height: 1.3;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.report-modal__subtitle {
|
||||
font-size: 24rpx;
|
||||
color: #64748b;
|
||||
margin-top: 6rpx;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.report-modal__close-btn {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 28rpx;
|
||||
background: #f1f5f9;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:active {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
}
|
||||
|
||||
.report-modal__close-icon {
|
||||
font-size: 26rpx;
|
||||
color: #64748b;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.report-modal__notice {
|
||||
margin: 0 32rpx 16rpx;
|
||||
padding: 14rpx 20rpx;
|
||||
background: #f2fef7;
|
||||
border: 1rpx solid #bbf7d0;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
||||
.report-modal__notice-text {
|
||||
font-size: 22rpx;
|
||||
color: #00a854;
|
||||
line-height: 1.45;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.report-modal__scroll {
|
||||
flex: 1;
|
||||
max-height: 58vh;
|
||||
padding: 0 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.report-modal__section {
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.report-modal__section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
|
||||
.report-modal__section-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.report-modal__section-required {
|
||||
font-size: 22rpx;
|
||||
color: #ef4444;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.report-modal__section-counter,
|
||||
.report-modal__section-sub {
|
||||
font-size: 22rpx;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.report-modal__reasons-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.report-modal__reason-tag {
|
||||
position: relative;
|
||||
padding: 14rpx 24rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #f8fafc;
|
||||
border: 1rpx solid #e2e8f0;
|
||||
transition: all 0.2s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
&--active {
|
||||
background: #ecfdf5;
|
||||
border-color: #00d26a;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 210, 106, 0.15);
|
||||
|
||||
.report-modal__reason-text {
|
||||
color: #00a854;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.report-modal__reason-text {
|
||||
font-size: 26rpx;
|
||||
color: #334155;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.report-modal__reason-badge {
|
||||
position: absolute;
|
||||
right: -4rpx;
|
||||
bottom: -4rpx;
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #00d26a;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.report-modal__reason-check {
|
||||
color: #ffffff;
|
||||
font-size: 16rpx;
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.report-modal__textarea-wrap {
|
||||
background: #f8fafc;
|
||||
border: 1rpx solid #e2e8f0;
|
||||
border-radius: 20rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus-within {
|
||||
border-color: #00d26a;
|
||||
background: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
.report-modal__textarea {
|
||||
width: 100%;
|
||||
height: 150rpx;
|
||||
font-size: 26rpx;
|
||||
color: #1e293b;
|
||||
line-height: 1.5;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.report-modal__textarea-placeholder {
|
||||
color: #94a3b8;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.report-modal__images-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.report-modal__img-item {
|
||||
position: relative;
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 18rpx;
|
||||
overflow: hidden;
|
||||
background: #f1f5f9;
|
||||
|
||||
&--uploading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1rpx dashed #00d26a;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
}
|
||||
|
||||
.report-modal__img-thumb {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.report-modal__img-del {
|
||||
position: absolute;
|
||||
top: 8rpx;
|
||||
right: 8rpx;
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
border-radius: 18rpx;
|
||||
background: rgba(15, 23, 42, 0.65);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2;
|
||||
|
||||
&:active {
|
||||
background: rgba(239, 68, 68, 0.9);
|
||||
}
|
||||
}
|
||||
|
||||
.report-modal__img-del-icon {
|
||||
color: #ffffff;
|
||||
font-size: 20rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.report-modal__img-loading-txt {
|
||||
font-size: 22rpx;
|
||||
color: #00a854;
|
||||
}
|
||||
|
||||
.report-modal__img-uploader {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 18rpx;
|
||||
border: 2rpx dashed #cbd5e1;
|
||||
background: #f8fafc;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4rpx;
|
||||
|
||||
&:active {
|
||||
background: #f1f5f9;
|
||||
border-color: #00d26a;
|
||||
}
|
||||
}
|
||||
|
||||
.report-modal__img-uploader-plus {
|
||||
font-size: 44rpx;
|
||||
color: #94a3b8;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.report-modal__img-uploader-txt {
|
||||
font-size: 20rpx;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.report-modal__footer {
|
||||
padding: 18rpx 32rpx 20rpx;
|
||||
background: #ffffff;
|
||||
border-top: 1rpx solid #f1f5f9;
|
||||
}
|
||||
|
||||
.report-modal__submit-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
background: linear-gradient(135deg, #00e070 0%, #00d26a 100%);
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 8rpx 20rpx rgba(0, 210, 106, 0.28);
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.9;
|
||||
transform: scale(0.99);
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
background: #cbd5e1 !important;
|
||||
color: #ffffff !important;
|
||||
box-shadow: none !important;
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes reportModalFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes reportModalSlideUp {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户