fix:修复bug

This commit is contained in:
2026-02-06 18:09:23 +08:00
parent f476cee76d
commit bb5a6dd100
51 changed files with 4491 additions and 2630 deletions
@@ -0,0 +1,378 @@
<template>
<view class="express-form-container">
<!-- 订单摘要卡片 -->
<view class="order-summary-card" v-if="orderInfo.orderNo">
<view class="summary-row">
<view class="label">{{ $t('order.orderNo') }}</view>
<view class="value">{{ orderInfo.orderNo }}</view>
</view>
<view class="summary-row" v-if="orderInfo.deviceNo">
<view class="label">{{ $t('order.deviceNo') }}</view>
<view class="value">{{ orderInfo.deviceNo }}</view>
</view>
<view class="summary-row" v-if="orderInfo.startTime">
<view class="label">{{ $t('express.openTime') }}</view>
<view class="value">{{ orderInfo.startTime }}</view>
</view>
</view>
<!-- 表单区域 -->
<view class="form-section">
<view class="form-title">{{ $t('express.fillExpressInfo') }}</view>
<view class="input-wrapper">
<view class="input-label">{{ $t('express.contactPhone') }}</view>
<input class="input-field" type="number" v-model="phone" maxlength="20" />
</view>
<view class="input-wrapper">
<view class="input-label">{{ $t('express.expressNo') }}</view>
<input class="input-field" type="text" v-model="trackingNumber"
:placeholder="isFillMode ? $t('express.fillTrackingPlaceholder') : $t('express.trackingPlaceholder')" maxlength="40" />
</view>
<view class="tips" v-if="tipsText">{{ tipsText }}</view>
</view>
<!-- 提交按钮 -->
<view class="submit-btn" :class="{ disabled: submitting }" @click="!submitting && handleSubmit()">
{{ isFillMode ? $t('express.confirmFill') : $t('express.submitInfo') }}
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
getCurrentInstance,
onMounted
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import {
queryById
} from '@/config/api/order.js'
import {
applyExpressReturn,
getExpressReturnByOrder,
getExpressReturnDetail,
fillExpressTrackingNumber
} from '@/config/api/expressReturn.js'
import { useI18n } from '@/utils/i18n.js'
const { t } = useI18n()
onMounted(() => {
uni.setNavigationBarTitle({
title: t('express.fillExpress')
})
})
const orderId = ref('')
const recordId = ref('')
const isFillMode = ref(false)
const orderInfo = reactive({
orderNo: '',
deviceNo: '',
startTime: ''
})
const phone = ref('')
const trackingNumber = ref('')
const tipsText = ref('')
const submitting = ref(false)
onLoad(async (options) => {
orderId.value = options?.orderId || ''
recordId.value = options?.id || ''
isFillMode.value = !!recordId.value
if (isFillMode.value) {
await loadRecordAndOrderByRecord()
return
}
if (!orderId.value) {
uni.showToast({
title: t('express.orderNoMissing'),
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 1200)
return
}
await loadOrder()
await checkExistingExpressReturn()
})
const loadOrder = async () => {
try {
uni.showLoading({
title: t('common.loading')
})
const res = await queryById(orderId.value)
if (res?.code === 200 && res.data) {
orderInfo.orderNo = res.data.orderNo || res.data.orderId || ''
orderInfo.deviceNo = res.data.deviceNo || ''
orderInfo.startTime = res.data.startTime || res.data.createTime || ''
// 默认联系电话可回填订单上的手机号(若有)
if (res.data.phone && !phone.value) phone.value = res.data.phone
} else {
throw new Error(res?.msg || t('order.getOrderFailed'))
}
} catch (e) {
uni.showToast({
title: e.message || t('express.loadFailed'),
icon: 'none'
})
} finally {
uni.hideLoading()
}
}
const loadRecordAndOrderByRecord = async () => {
try {
uni.showLoading({
title: t('common.loading')
})
const res = await getExpressReturnDetail(recordId.value)
if (res?.code === 200 && res.data) {
if (res.data.orderId) {
orderId.value = res.data.orderId
await loadOrder()
}
if (res.data.userPhone && !phone.value) phone.value = res.data.userPhone
} else {
throw new Error(res?.msg || t('express.getRecordFailed'))
}
} catch (e) {
uni.showToast({
title: e.message || t('express.loadFailed'),
icon: 'none'
})
} finally {
uni.hideLoading()
}
}
const checkExistingExpressReturn = async () => {
try {
const res = await getExpressReturnByOrder(orderId.value)
if (res && res.code === 200 && res.data) {
const rec = res.data
if (rec.status === 0) {
recordId.value = rec.id
uni.showModal({
title: t('common.tips'),
content: t('express.existingReturnNotice'),
confirmText: t('express.goToFill'),
cancelText: t('common.cancel'),
success: (r) => {
if (r.confirm) {
uni.redirectTo({
url: `/pages/expressReturn/addExpressReturn?id=${rec.id}`
})
}
}
})
return
} else {
uni.showToast({
title: t('express.alreadyHasRecord'),
icon: 'none'
})
setTimeout(() => {
uni.redirectTo({
url: `/pages/expressReturn/detail?id=${rec.id}`
})
}, 800)
}
}
} catch (e) {
// 无记录则忽略
}
}
const validate = () => {
// 简单手机检查(兼容座机/国际号,放宽到至少 5 位数字)
const digits = (phone.value || '').replace(/\D/g, '')
if (!digits || digits.length < 5) {
uni.showToast({
title: t('express.pleaseEnterValidPhone'),
icon: 'none'
})
return false
}
if (isFillMode.value && !trackingNumber.value) {
uni.showToast({
title: t('express.pleaseEnterTrackingNo'),
icon: 'none'
})
return false
}
return true
}
const handleSubmit = async () => {
if (!validate() || submitting.value) return
submitting.value = true
try {
uni.showLoading({
title: isFillMode.value ? t('common.filling') : t('common.submitting')
})
let res
if (isFillMode.value) {
res = await fillExpressTrackingNumber({
id: Number(recordId.value),
logisticsTrackingNumber: trackingNumber.value
})
} else {
res = await applyExpressReturn({
orderId: orderId.value,
logisticsTrackingNumber: trackingNumber.value,
remark: ''
})
}
if (res && res.code === 200) {
uni.showToast({
title: isFillMode.value ? t('express.fillSuccess') : t('express.submitSuccess'),
icon: 'success'
})
setTimeout(() => {
uni.navigateBack()
}, 800)
} else {
throw new Error(res?.msg || (isFillMode.value ? t('express.fillFailed') : t('express.submitFailed')))
}
} catch (e) {
uni.showToast({
title: e.message || (isFillMode.value ? t('express.fillFailed') : t('express.submitFailed')),
icon: 'none'
})
} finally {
submitting.value = false
uni.hideLoading()
}
}
</script>
<style lang="scss" scoped>
.express-form-container {
min-height: 100vh;
background: #f5f5f5;
padding: 40rpx 32rpx 180rpx;
}
/* 订单摘要卡片 - 淡绿色背景 */
.order-summary-card {
background: linear-gradient(135deg, #d4f4dd 0%, #e8f8ed 100%);
border-radius: 24rpx;
padding: 40rpx 32rpx;
margin-bottom: 40rpx;
.summary-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
.label {
font-size: 28rpx;
color: #333333;
font-weight: 400;
}
.value {
font-size: 28rpx;
color: #333333;
font-weight: 500;
}
}
}
/* 表单区域 */
.form-section {
background: transparent;
margin-bottom: 40rpx;
.form-title {
font-size: 32rpx;
font-weight: 600;
color: #333333;
margin-bottom: 32rpx;
}
.input-wrapper {
position: relative;
margin-bottom: 32rpx;
.input-label {
position: absolute;
top: -14rpx;
left: 32rpx;
font-size: 24rpx;
color: #666666;
background: #ffffff;
padding: 0 12rpx;
z-index: 1;
}
.input-field {
width: 100%;
height: 100rpx;
background: #ffffff;
border: 2rpx solid #333333;
border-radius: 48rpx;
padding: 0 32rpx;
font-size: 28rpx;
color: #333333;
line-height: 100rpx;
box-sizing: border-box;
}
.input-field::placeholder {
color: #cccccc;
}
}
.tips {
margin-top: 16rpx;
padding: 0 16rpx;
font-size: 24rpx;
color: #999999;
}
}
/* 提交按钮 */
.submit-btn {
position: fixed;
left: 32rpx;
right: 32rpx;
bottom: 60rpx;
bottom: calc(60rpx + env(safe-area-inset-bottom));
height: 96rpx;
background: linear-gradient(135deg, #7cd89f 0%, #6bc98c 100%);
border-radius: 48rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 600;
color: #ffffff;
box-shadow: 0 8rpx 24rpx rgba(124, 216, 159, 0.3);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
box-shadow: 0 4rpx 16rpx rgba(124, 216, 159, 0.2);
}
&.disabled {
opacity: 0.5;
pointer-events: none;
}
}
</style>
@@ -0,0 +1,404 @@
<template>
<view class="express-detail-container">
<!-- 状态卡片 -->
<view class="status-card">
<view class="status-header">
<view class="status-icon" :class="getStatusClass(detailData.status)">
<text class="icon-text">{{ getStatusIcon(detailData.status) }}</text>
</view>
<view class="status-info">
<text class="status-title">{{ getStatusText(detailData.status) }}</text>
<text class="status-desc">{{ getStatusDesc(detailData.status) }}</text>
</view>
</view>
</view>
<!-- 快递信息卡片 -->
<view class="info-card">
<view class="card-title">
<text class="title-text">{{ $t('express.expressInfo') }}</text>
</view>
<view class="info-list">
<view class="info-item">
<text class="label">{{ $t('express.expressCompany') }}</text>
<text class="value">{{ detailData.expressCompany }}</text>
</view>
<view class="info-item">
<text class="label">{{ $t('express.trackingNo') }}</text>
<text class="value tracking-number">{{ detailData.trackingNumber }}</text>
</view>
<view class="info-item">
<text class="label">{{ $t('express.packageType') }}</text>
<text class="value">{{ detailData.packageType }}</text>
</view>
<view class="info-item">
<text class="label">{{ $t('express.packageWeight') }}</text>
<text class="value">{{ detailData.weight }}</text>
</view>
</view>
</view>
<!-- 归还信息卡片 -->
<view class="info-card">
<view class="card-title">
<text class="title-text">{{ $t('express.returnInfo') }}</text>
</view>
<view class="info-list">
<view class="info-item">
<text class="label">{{ $t('express.returnAddress') }}</text>
<text class="value address">{{ detailData.returnAddress }}</text>
</view>
<view class="info-item">
<text class="label">{{ $t('express.returnTime') }}</text>
<text class="value">{{ detailData.returnTime }}</text>
</view>
<view class="info-item">
<text class="label">{{ $t('express.processTime') }}</text>
<text class="value">{{ detailData.processTime || '--' }}</text>
</view>
<view class="info-item">
<text class="label">{{ $t('express.completeTime') }}</text>
<text class="value">{{ detailData.completeTime || '--' }}</text>
</view>
</view>
</view>
<!-- 备注信息卡片 -->
<view class="info-card" v-if="detailData.remark">
<view class="card-title">
<text class="title-text">{{ $t('express.remarkInfo') }}</text>
</view>
<view class="remark-content">
<text class="remark-text">{{ detailData.remark }}</text>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<button class="action-btn primary" @click="handleCopyTracking">
<text class="btn-text">{{ $t('express.copyTrackingNo') }}</text>
</button>
<button class="action-btn secondary" @click="handleContactService">
<text class="btn-text">{{ $t('user.customerService') }}</text>
</button>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getExpressReturnDetail } from '@/config/api/expressReturn.js'
import { getCustomerPhone } from '@/util/index.js'
import { useI18n } from '@/utils/i18n.js'
const { t } = useI18n()
// 详情数据
const detailData = ref({
id: '',
expressCompany: '-',
trackingNumber: '-',
returnAddress: '-',
returnTime: '-',
processTime: '-',
completeTime: '-',
packageType: '-',
weight: '-',
status: 'pending',
remark: ''
})
// 获取状态样式类
const getStatusClass = (status) => {
const statusMap = {
'completed': 'status-completed',
'processing': 'status-processing',
'pending': 'status-pending'
}
return statusMap[status] || 'status-pending'
}
// 获取状态图标
const getStatusIcon = (status) => {
const iconMap = {
'completed': '✓',
'processing': '⏳',
'pending': '⏸'
}
return iconMap[status] || '⏸'
}
// 获取状态文本
const getStatusText = (status) => {
const textMap = {
'completed': t('express.returnCompleted'),
'processing': t('express.processing'),
'pending': t('express.pending')
}
return textMap[status] || t('express.pending')
}
// 获取状态描述
const getStatusDesc = (status) => {
const descMap = {
'completed': t('express.returnCompletedDesc'),
'processing': t('express.processingDesc'),
'pending': t('express.pendingDesc')
}
return descMap[status] || t('express.pendingDesc')
}
// 复制运单号
const handleCopyTracking = () => {
uni.setClipboardData({
data: detailData.value.trackingNumber,
success: () => {
uni.showToast({
title: t('express.trackingNoCopied'),
icon: 'success'
})
}
})
}
// 联系客服
const handleContactService = () => {
const customerPhone = getCustomerPhone()
uni.showModal({
title: t('user.customerService'),
content: `${t('help.phone')}${customerPhone}\n${t('help.workingHours')}${t('express.workingHours')}`,
confirmText: t('express.call'),
cancelText: t('common.cancel'),
success: (res) => {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: customerPhone
})
}
}
})
}
// 页面加载时获取详情数据
onMounted(async () => {
uni.setNavigationBarTitle({
title: t('express.returnDetail')
})
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const options = currentPage.options || {}
if (!options.id) return
try {
uni.showLoading({ title: t('common.loading') })
const res = await getExpressReturnDetail(options.id)
if (res && res.code === 200 && res.data) {
const r = res.data
detailData.value = {
id: r.id,
expressCompany: r.expressCompany || r.company || '-',
trackingNumber: r.logisticsTrackingNumber || r.trackingNumber || '-',
returnAddress: r.returnAddress || r.address || '-',
returnTime: r.createTime || r.returnTime || '-',
processTime: r.processTime || '-',
completeTime: r.completeTime || '-',
packageType: r.packageType || '-',
weight: r.weight || '-',
status: mapStatus(r.status),
remark: r.remark || ''
}
} else {
throw new Error(res?.msg || t('express.getDetailFailed'))
}
} catch (e) {
uni.showToast({ title: e.message || t('express.loadFailed'), icon: 'none' })
} finally {
uni.hideLoading()
}
})
// 状态映射
const mapStatus = (status) => {
if (status === 5) return 'completed'
if (status === 3 || status === 1) return 'processing'
if (status === 4 || status === 2 || status === 0) return 'pending'
return 'pending'
}
</script>
<style lang="scss">
.express-detail-container {
min-height: 100vh;
background-color: #f8f9fa;
padding: 20rpx;
}
.status-card {
background-color: #ffffff;
border-radius: 16rpx;
padding: 40rpx 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
}
.status-header {
display: flex;
align-items: center;
}
.status-icon {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
font-weight: bold;
margin-right: 24rpx;
&.status-completed {
background-color: #e8f5e8;
color: #27ae60;
}
&.status-processing {
background-color: #fff3cd;
color: #f39c12;
}
&.status-pending {
background-color: #f8f9fa;
color: #6c757d;
}
}
.status-info {
flex: 1;
}
.status-title {
display: block;
font-size: 36rpx;
font-weight: 600;
color: #2c3e50;
margin-bottom: 8rpx;
}
.status-desc {
display: block;
font-size: 28rpx;
color: #7f8c8d;
}
.info-card {
background-color: #ffffff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
}
.card-title {
margin-bottom: 24rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f1f3f4;
}
.title-text {
font-size: 32rpx;
font-weight: 600;
color: #2c3e50;
}
.info-list {
.info-item {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding: 16rpx 0;
border-bottom: 1rpx solid #f8f9fa;
&:last-child {
border-bottom: none;
}
}
}
.label {
font-size: 28rpx;
color: #7f8c8d;
min-width: 160rpx;
}
.value {
font-size: 28rpx;
color: #2c3e50;
flex: 1;
text-align: right;
&.tracking-number {
font-family: 'Courier New', monospace;
font-weight: 500;
}
&.address {
text-align: right;
line-height: 1.4;
}
}
.remark-content {
padding: 16rpx 0;
}
.remark-text {
font-size: 28rpx;
color: #34495e;
line-height: 1.5;
}
.action-buttons {
display: flex;
gap: 20rpx;
margin-top: 40rpx;
padding: 0 20rpx;
}
.action-btn {
flex: 1;
height: 88rpx;
border-radius: 44rpx;
border: none;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 500;
transition: all 0.2s ease;
&.primary {
background-color: #1976D2;
color: #ffffff;
&:active {
background-color: #1565C0;
}
}
&.secondary {
background-color: #ffffff;
color: #1976D2;
border: 2rpx solid #1976D2;
&:active {
background-color: #f8f9fa;
}
}
}
.btn-text {
font-size: 32rpx;
font-weight: 500;
}
</style>
+325
View File
@@ -0,0 +1,325 @@
<template>
<view class="express-return-container">
<!-- 收件信息卡片 -->
<view class="recipient-info-card">
<view class="info-header">{{ $t('express.recipientInfo') }}</view>
<view class="info-content">
<text class="recipient-name">{{ $t('express.recipientName') }}</text>
<text class="recipient-address">{{ $t('express.recipientAddress') }}</text>
</view>
<view class="copy-all-btn" @click="copyAllInfo">
<text class="btn-text">{{ $t('express.copyAllInfo') }}</text>
</view>
</view>
<!-- 列表容器 -->
<view class="list-container">
<view class="return-item" v-for="(item, index) in returnList" :key="index" @click="handleItemClick(item)">
<!-- 左侧图标区域 -->
<view class="item-left">
<view class="avatar-placeholder"></view>
</view>
<!-- 中间内容区域 -->
<view class="item-content">
<view class="content-header">
<text class="status-label">{{ getStatusText(item.status) }}</text>
</view>
<view class="content-body">
<text class="info-text">{{ $t('order.orderNo') }}{{ item.orderId || '' }}</text>
<text class="info-text">{{ $t('express.expressNo') }}{{ item.trackingNumber || $t('express.toFill') }}</text>
<text class="info-text">{{ $t('express.userPhone') }}{{ item.userPhone || '' }}</text>
</view>
</view>
<!-- 右侧状态标签 -->
<view class="item-right">
<view class="status-badge" :class="getStatusClass(item.status)">
{{ getStatusBadge(item.status) }}
</view>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="returnList.length === 0">
<view class="empty-icon">📦</view>
<text class="empty-text">{{ $t('express.noReturnRecord') }}</text>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getExpressReturnList } from '@/config/api/expressReturn.js'
import { useI18n } from '@/utils/i18n.js'
const { t } = useI18n()
const returnList = ref([])
const loading = ref(false)
const query = ref({ pageNum: 1, pageSize: 20 })
onMounted(() => {
uni.setNavigationBarTitle({
title: t('express.returnRecord')
})
loadList()
})
// 收件信息
const recipientName = '风电者 18163601305'
const recipientAddress = '湖南省长沙市岳麓区麓谷街道新长海尖科技园A2栋623'
const loadList = async () => {
try {
loading.value = true
const res = await getExpressReturnList(query.value)
if (res && res.code === 200) {
// 将后端字段映射到前端展示字段
const rows = (res.data && (res.data.rows || res.data)) || []
returnList.value = rows.map(r => ({
id: r.id,
expressCompany: r.expressCompany || r.company || t('express.toFill'),
trackingNumber: r.logisticsTrackingNumber || r.trackingNumber || t('express.toFill'),
returnAddress: r.returnAddress || r.address || t('express.toFill'),
returnTime: r.expressFillTime || r.createTime || r.returnTime || t('express.toFill'),
packageType: r.packageType || t('express.toFill'),
weight: r.weight || t('express.toFill'),
status: mapStatus(r.status),
rawStatus: r.status,
userPhone: r.userPhone,
orderId: r.orderId,
remark: r.remark
}))
} else {
throw new Error(res?.msg || t('express.getListFailed'))
}
} catch (e) {
uni.showToast({ title: e.message || t('express.loadFailed'), icon: 'none' })
} finally {
loading.value = false
}
}
// 状态映射
const mapStatus = (status) => {
// 文档:0-未填写 1-已填写 2-已取消 3-审批通过 4-审批拒绝 5-订单完成
if (status === 5) return 'completed'
if (status === 3 || status === 1) return 'processing'
if (status === 4 || status === 2 || status === 0) return 'pending'
return 'pending'
}
const getStatusClass = (status) => ({
'completed': 'status-completed',
'processing': 'status-processing',
'pending': 'status-pending'
}[status] || 'status-pending')
const getStatusText = (status) => ({
'completed': t('express.billingPaused'),
'processing': t('express.billingPaused'),
'pending': t('express.billingPaused')
}[status] || t('express.billingPaused'))
const getStatusBadge = (status) => ({
'completed': t('express.completed'),
'processing': t('express.processing'),
'pending': t('express.pending')
}[status] || t('express.pending'))
// 一键复制全部信息
const copyAllInfo = () => {
const allInfo = `${t('express.recipient')}${recipientName}\n${t('express.recipientAddressLabel')}${recipientAddress}`
uni.setClipboardData({
data: allInfo,
success: () => {
uni.showToast({ title: t('express.copySuccess'), icon: 'success' })
},
fail: () => {
uni.showToast({ title: t('express.copyFailed'), icon: 'none' })
}
})
}
// 点击列表项
const handleItemClick = (item) => {
// 未填写(status=0 -> mapped 'pending')时跳转到补填页,其它跳详情
if (item && item.rawStatus === 0) {
uni.navigateTo({ url: `/pages/expressReturn/addExpressReturn?id=${item.id}` })
} else {
uni.navigateTo({ url: `/pages/expressReturn/detail?id=${item.id}` })
}
}
</script>
<style lang="scss">
.express-return-container {
min-height: 100vh;
background-color: #f5f5f5;
padding: 20rpx;
}
// 收件信息卡片
.recipient-info-card {
background: linear-gradient(135deg, #D1FFE1 0%, #B8F5D0 100%);
border-radius: 16rpx;
padding: 24rpx 28rpx;
margin-bottom: 20rpx;
}
.info-header {
font-size: 28rpx;
font-weight: 600;
color: #2c3e50;
margin-bottom: 16rpx;
}
.info-content {
display: flex;
flex-direction: column;
margin-bottom: 16rpx;
}
.recipient-name {
font-size: 30rpx;
font-weight: 600;
color: #1a1a1a;
margin-bottom: 8rpx;
}
.recipient-address {
font-size: 26rpx;
color: #333333;
line-height: 1.6;
}
.copy-all-btn {
padding: 16rpx;
background-color: #ffffff;
border-radius: 12rpx;
text-align: center;
}
.btn-text {
font-size: 28rpx;
color: #27ae60;
font-weight: 500;
}
// 列表容器
.list-container {
background-color: transparent;
}
.return-item {
display: flex;
align-items: flex-start;
padding: 28rpx 24rpx;
background-color: #ffffff;
border-radius: 16rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
position: relative;
&:last-child {
margin-bottom: 0;
}
&:active {
background-color: #fafafa;
}
}
// 左侧头像区域
.item-left {
margin-right: 20rpx;
}
.avatar-placeholder {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
background-color: #e0e0e0;
}
// 中间内容区域
.item-content {
flex: 1;
display: flex;
flex-direction: column;
}
.content-header {
margin-bottom: 12rpx;
}
.status-label {
font-size: 32rpx;
font-weight: 600;
color: #1a1a1a;
}
.content-body {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.info-text {
font-size: 26rpx;
color: #666666;
line-height: 1.4;
}
// 右侧状态标签
.item-right {
position: absolute;
top: 28rpx;
right: 24rpx;
}
.status-badge {
padding: 8rpx 20rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 500;
white-space: nowrap;
&.status-completed {
background-color: #e8f5e8;
color: #27ae60;
}
&.status-processing {
background-color: #fff3cd;
color: #f39c12;
}
&.status-pending {
background-color: #f0f0f0;
color: #999999;
}
}
// 空状态
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 40rpx;
}
.empty-icon {
font-size: 80rpx;
margin-bottom: 20rpx;
}
.empty-text {
font-size: 28rpx;
color: #999999;
}
</style>
+645
View File
@@ -0,0 +1,645 @@
<template>
<view class="feedback-detail-container">
<!-- 投诉详情卡片 -->
<view class="detail-card">
<!-- 第一行问题类型和状态 -->
<view class="card-header">
<view class="type-badge" :class="getTypeClass(detail.type)">
{{ getTypeText(detail.type) }}
</view>
<view class="status-badge" :class="getStatusClass(detail.status)">
{{ getStatusText(detail.status) }}
</view>
</view>
<!-- 标题 -->
<view class="title-section">
<text class="title-text">{{ detail.title || '-' }}</text>
</view>
<!-- 问题描述 -->
<view class="content-section">
<view class="content-text">{{ detail.content || '-' }}</view>
</view>
<!-- 联系电话 -->
<view class="contact-section" v-if="detail.phone">
<text class="contact-label">{{ $t('feedback.contactPhone') }}</text>
<text class="contact-value">{{ detail.phone }}</text>
</view>
<!-- 上传图片 -->
<view class="image-section" v-if="getImageList(detail).length > 0">
<view class="image-list">
<image v-for="(img, index) in getImageList(detail)" :key="index" :src="img" mode="aspectFill" class="detail-image"
@click="previewImage(img, index)"></image>
</view>
</view>
<!-- 提交时间 -->
<view class="time-section">
<text class="time-text">{{ formatTime(detail.createTime) }}</text>
</view>
</view>
<!-- 回复列表合并平台和用户回复按时间排序 -->
<view class="reply-section" v-if="allReplies.length > 0">
<view class="section-divider">
<view class="divider-line"></view>
<text class="divider-text">{{ $t('feedback.replyHistory') }}</text>
<view class="divider-line"></view>
</view>
<view class="reply-list">
<view class="reply-item" v-for="(reply, index) in allReplies" :key="reply.id || index"
:class="{ 'reply-platform': reply.isPlatform, 'reply-user': !reply.isPlatform }">
<view class="reply-avatar" :class="{ 'avatar-platform': reply.isPlatform, 'avatar-user': !reply.isPlatform }">
<text class="avatar-text">{{ reply.isPlatform ? '平台' : '我' }}</text>
</view>
<view class="reply-content-wrapper">
<view class="reply-name-time">
<text class="reply-name">{{ reply.senderName || (reply.isPlatform ? $t('feedback.platform') : $t('feedback.me')) }}</text>
<text class="reply-time">{{ formatTime(reply.createTime) }}</text>
</view>
<view class="reply-content">{{ reply.content || '-' }}</view>
</view>
</view>
</view>
</view>
<!-- 底部输入框 -->
<view class="bottom-input-bar" v-if="canSendMessage">
<view class="input-wrapper">
<textarea class="reply-input" v-model="replyContent" :placeholder="$t('feedback.replyPlaceholder')"
maxlength="500" :auto-height="true"></textarea>
</view>
<view class="submit-btn" @click="submitReply" :class="{ disabled: !replyContent.trim() }">
{{ $t('feedback.submitReply') }}
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
onMounted,
computed
} from 'vue';
import {
onLoad
} from '@dcloudio/uni-app';
import {
getFeedbackDetail,
getFeedbackMessages,
sendFeedbackMessage
} from '@/config/api/feedback.js';
import {
useI18n
} from '@/utils/i18n.js'
const {
t
} = useI18n()
// 设置页面标题
onMounted(() => {
uni.setNavigationBarTitle({
title: t('feedback.detail')
})
})
// 初始化状态
const detail = ref({});
const allReplies = ref([]);
const replyContent = ref('');
const feedbackId = ref('');
const canSendMessage = computed(() => {
const status = detail.value?.status
return ['pending', 'in_progress'].includes(status)
})
// 页面加载
onLoad(async (options) => {
if (options.id) {
feedbackId.value = options.id;
await loadDetail();
} else {
uni.showToast({
title: t('feedback.idRequired'),
icon: 'none'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
});
const normalizeMessages = (messages = []) => {
return (messages || [])
.map(message => ({
...message,
isPlatform: message.senderType === 'staff' || message.senderType === 'platform' || message.isPlatform === true
}))
.sort((a, b) => {
const timeA = new Date(a.createTime || 0).getTime();
const timeB = new Date(b.createTime || 0).getTime();
return timeA - timeB;
});
}
const loadMessages = async (initialMessages) => {
try {
if (Array.isArray(initialMessages)) {
allReplies.value = normalizeMessages(initialMessages);
return;
}
if (!feedbackId.value) return;
const res = await getFeedbackMessages(feedbackId.value);
if (res.code === 200) {
allReplies.value = normalizeMessages(res.data || []);
}
} catch (error) {
console.error('获取对话消息失败:', error);
}
}
// 加载详情
const loadDetail = async (options = {}) => {
const shouldShowLoading = options.showLoading !== false;
try {
if (shouldShowLoading) {
uni.showLoading({
title: t('common.loading')
});
}
const res = await getFeedbackDetail(feedbackId.value);
if (res.code === 200 && res.data) {
detail.value = res.data;
await loadMessages(res.data.messages);
} else {
uni.showToast({
title: res.msg || t('feedback.getDetailFailed'),
icon: 'none'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
} catch (error) {
console.error('获取投诉详情失败:', error);
uni.showToast({
title: t('feedback.getDetailFailed'),
icon: 'none'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
} finally {
if (shouldShowLoading) {
uni.hideLoading();
}
}
};
// 提交回复
const submitReply = async () => {
if (!replyContent.value.trim()) {
uni.showToast({
title: t('feedback.pleaseEnterReply'),
icon: 'none'
});
return;
}
try {
uni.showLoading({
title: t('common.submitting')
});
const res = await sendFeedbackMessage(feedbackId.value, {
content: replyContent.value.trim()
});
if (res.code === 200) {
uni.showToast({
title: t('feedback.replySuccess'),
icon: 'success'
});
replyContent.value = '';
// 重新加载详情和对话
await loadDetail({
showLoading: false
});
} else {
uni.showToast({
title: res.msg || t('feedback.replyFailed'),
icon: 'none'
});
}
} catch (error) {
console.error('提交回复失败:', error);
uni.showToast({
title: t('feedback.replyFailed'),
icon: 'none'
});
} finally {
uni.hideLoading();
}
};
// 获取状态文本
const getStatusText = (status) => {
const statusMap = {
'pending': t('feedback.pending'),
'in_progress': t('feedback.processing'),
'resolved': t('feedback.completed')
};
return statusMap[status] || t('feedback.pending');
};
// 获取状态样式类
const getStatusClass = (status) => {
const classMap = {
'pending': 'status-pending',
'in_progress': 'status-processing',
'resolved': 'status-completed'
};
return classMap[status] || 'status-pending';
};
// 获取类型文本
const getTypeText = (type) => {
const typeMap = {
'complain': t('feedback.complain'),
'suggestion': t('feedback.suggestion')
};
return typeMap[type] || type || '-';
};
// 获取类型样式类
const getTypeClass = (type) => {
const classMap = {
'complain': 'type-complain',
'suggestion': 'type-suggestion'
};
return classMap[type] || 'type-default';
};
// 格式化时间
const formatTime = (timeStr) => {
if (!timeStr) return '-';
try {
const date = new Date(timeStr);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}`;
} catch (e) {
return timeStr;
}
};
// 获取图片列表(支持字符串或数组)
const getImageList = (item) => {
if (!item) return [];
const pictureSource = item.pictureUrls ?? item.picturePath;
if (!pictureSource) return [];
if (Array.isArray(pictureSource)) {
return pictureSource.filter(img => !!img);
}
if (typeof pictureSource === 'string') {
if (pictureSource.includes(',')) {
return pictureSource.split(',').map(img => img.trim()).filter(img => img);
}
return pictureSource.trim() ? [pictureSource.trim()] : [];
}
return [];
};
// 预览图片
const previewImage = (url, index) => {
const imageList = getImageList(detail.value);
uni.previewImage({
urls: imageList,
current: index !== undefined ? index : 0
});
};
</script>
<style lang="scss" scoped>
.feedback-detail-container {
min-height: 100vh;
background: #f5f5f5;
padding: 20rpx;
padding-bottom: 200rpx;
box-sizing: border-box;
// 详情卡片
.detail-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
// 第一行:问题类型和状态
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f0f0f0;
.type-badge {
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 24rpx;
font-weight: 500;
&.type-complain {
background: #fff3e0;
color: #ff9800;
}
&.type-suggestion {
background: #e8f5e9;
color: #4caf50;
}
&.type-default {
background: #f5f5f5;
color: #666;
}
}
.status-badge {
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 24rpx;
font-weight: 500;
&.status-processing {
background: #fff3e0;
color: #ff9800;
}
&.status-completed {
background: #e8f5e9;
color: #4caf50;
}
&.status-pending {
background: #f5f5f5;
color: #999;
}
}
}
// 标题
.title-section {
margin-bottom: 16rpx;
.title-text {
font-size: 32rpx;
font-weight: 600;
color: #111;
}
}
// 问题描述
.content-section {
margin-bottom: 20rpx;
.content-text {
font-size: 28rpx;
color: #333;
line-height: 1.8;
word-break: break-all;
}
}
// 联系方式
.contact-section {
display: flex;
align-items: center;
margin-bottom: 20rpx;
padding: 16rpx;
background: #fafafa;
border-radius: 12rpx;
.contact-label {
font-size: 24rpx;
color: #999;
margin-right: 16rpx;
}
.contact-value {
font-size: 28rpx;
color: #333;
font-weight: 500;
}
}
// 图片区域
.image-section {
margin-bottom: 20rpx;
.image-list {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
.detail-image {
width: 200rpx;
height: 200rpx;
border-radius: 8rpx;
background: #f5f5f5;
}
}
}
// 提交时间
.time-section {
padding-top: 16rpx;
border-top: 1rpx solid #f0f0f0;
.time-text {
font-size: 24rpx;
color: #999;
}
}
}
// 回复区域
.reply-section {
margin-bottom: 30rpx;
.section-divider {
display: flex;
align-items: center;
margin: 30rpx 0 20rpx 0;
.divider-line {
flex: 1;
height: 1rpx;
background: #e0e0e0;
}
.divider-text {
padding: 0 20rpx;
font-size: 24rpx;
color: #999;
}
}
.reply-list {
.reply-item {
display: flex;
margin-bottom: 24rpx;
&.reply-platform {
.reply-content-wrapper {
background: #f5f5f5;
}
}
&.reply-user {
flex-direction: row-reverse;
.reply-content-wrapper {
background: #07c160;
color: #fff;
margin-right: 16rpx;
margin-left: 0;
.reply-name-time {
.reply-name,
.reply-time {
color: rgba(255, 255, 255, 0.9);
}
}
.reply-content {
color: #fff;
}
}
}
.reply-avatar {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
&.avatar-platform {
background: #ff9800;
}
&.avatar-user {
background: #07c160;
}
.avatar-text {
font-size: 22rpx;
color: #fff;
font-weight: 500;
}
}
.reply-content-wrapper {
flex: 1;
background: #f5f5f5;
border-radius: 12rpx;
padding: 16rpx 20rpx;
margin-left: 16rpx;
max-width: calc(100% - 72rpx);
.reply-name-time {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8rpx;
.reply-name {
font-size: 24rpx;
color: #666;
font-weight: 500;
}
.reply-time {
font-size: 22rpx;
color: #999;
}
}
.reply-content {
font-size: 28rpx;
color: #333;
line-height: 1.6;
word-break: break-all;
}
}
}
}
}
// 底部输入栏
.bottom-input-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 30rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
z-index: 10;
display: flex;
align-items: flex-end;
gap: 20rpx;
.input-wrapper {
flex: 1;
background: #f5f5f5;
border-radius: 20rpx;
padding: 16rpx 20rpx;
max-height: 200rpx;
.reply-input {
width: 100%;
font-size: 28rpx;
color: #333;
min-height: 40rpx;
max-height: 200rpx;
}
}
.submit-btn {
padding: 16rpx 40rpx;
background: #07c160;
color: #fff;
border-radius: 20rpx;
font-size: 28rpx;
font-weight: 500;
white-space: nowrap;
&.disabled {
background: #ccc;
opacity: 0.6;
}
&:active:not(.disabled) {
opacity: 0.8;
}
}
}
}
</style>
+457
View File
@@ -0,0 +1,457 @@
<template>
<view class="feedback-container">
<!-- 投诉记录入口 -->
<view class="record-entry" @click="navigateToRecord">
<view class="entry-left">
<image class="entry-icon" src="/static/complaint.png" mode="aspectFit"></image>
<text class="entry-text">{{ $t('feedback.recordList') }}</text>
</view>
<view class="entry-right">
<text class="entry-desc">{{ $t('feedback.viewRecords') }}</text>
<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
</view>
</view>
<!-- <form> -->
<!-- 问题类型选择 -->
<view class="type-section">
<view class="section-title">{{ $t('feedback.issueType') }}</view>
<view class="type-grid">
<view v-for="(type, index) in types" :key="index" class="type-item"
:class="{ active: selectedType === index }" @click="selectType(index)">
{{ $t(type) }}
</view>
</view>
</view>
<!-- 问题描述 -->
<view class="description-section">
<view class="section-title">{{ $t('feedback.issueDescription') }}</view>
<textarea class="description-input" v-model="description" :placeholder="$t('feedback.placeholder')"
maxlength="500" name="description" />
<view class="word-count">{{ description.length }}/500</view>
</view>
<!-- 图片上传 -->
<view class="upload-section">
<view class="section-title">{{ $t('feedback.imageUpload') }}</view>
<view class="upload-grid">
<view class="upload-item" v-for="(img, index) in images" :key="index">
<image :src="img" mode="aspectFill" />
<view class="delete-btn" @click="deleteImage(index)">×</view>
</view>
<view class="upload-btn" @click="chooseImage" v-if="images.length < 3">
<text class="plus">+</text>
<text class="tip">{{ $t('feedback.uploadImage') }}</text>
</view>
</view>
</view>
<!-- 联系方式 -->
<view class="contact-section">
<view class="section-title">{{ $t('feedback.contactInfo') }}</view>
<input class="contact-input" v-model="contact" :placeholder="$t('feedback.contactPlaceholder')"
type="number" maxlength="11" name="contact" />
</view>
<!-- 提交按钮 -->
<view class="submit-section">
<view class="submit-btn" @click="submitFeedback">{{ $t('feedback.submit') }}</view>
</view>
<!-- </form> -->
</view>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue'
import {
onLoad
} from "@dcloudio/uni-app"
import {
addUserFeedback
} from '@/config/api/feedback'
import {
uploadOssResource
} from '@/config/api/user'
import {
useI18n
} from '@/utils/i18n.js'
const {
t
} = useI18n()
// 跳转到投诉记录列表
const navigateToRecord = () => {
uni.navigateTo({
url: '/pages/feedback/list'
})
}
onMounted(() => {
uni.setNavigationBarTitle({
title: t('feedback.title')
})
})
onLoad((options) => {
if (uni.getStorageSync("userInfo").phone) {
contact.value = uni.getStorageSync('userInfo').phone;
}
if(options.selectedType) {
selectedType.value = parseInt(options.selectedType);
}
})
// 响应式数据
const types = ref(['feedback.deviceFault', 'feedback.chargingIssue', 'feedback.usageSuggestion', 'feedback.other'])
const selectedType = ref(-1)
const paramsType = ref('')
const description = ref('')
const images = ref([])
const contact = ref('')
// 方法
const selectType = (index) => {
selectedType.value = index
}
const chooseImage = () => {
uni.chooseImage({
count: 3 - images.value.length,
success: (res) => {
// 直接保存本地路径,不上传
const toUpload = res.tempFilePaths || []
images.value.push(...toUpload)
}
})
}
const deleteImage = (index) => {
images.value.splice(index, 1)
}
const submitFeedback = async () => {
if (selectedType.value === -1) {
uni.showToast({
title: t('feedback.pleaseSelectType'),
icon: 'none'
})
return
}
if (!description.value.trim()) {
uni.showToast({
title: t('feedback.pleaseDescribe'),
icon: 'none'
})
return
}
if (!contact.value) {
uni.showToast({
title: t('feedback.pleaseContact'),
icon: 'none'
})
return
}
if (types.value[selectedType.value] === 'feedback.deviceFault' || types.value[selectedType.value] ===
'feedback.chargingIssue') {
paramsType.value = 'complain'
} else {
paramsType.value = 'suggestion'
}
try {
// 显示上传进度
uni.showLoading({
title: t('feedback.uploading') || '上传中...',
mask: true
})
// 先逐步上传所有文件到OSS
const files = []
if (images.value.length > 0) {
for (let i = 0; i < images.value.length; i++) {
const filePath = images.value[i]
try {
const remoteUrl = await uploadOssResource(filePath)
files.push(remoteUrl)
} catch (err) {
console.error(`文件 ${i + 1} 上传失败:`, err)
uni.hideLoading()
uni.showToast({
title: t('feedback.imageUploadFailed'),
icon: 'none'
})
return
}
}
}
// 构建反馈数据
const feedbackData = {
type: paramsType.value,
content: description.value,
phone: contact.value,
files: files
}
// 调用API提交反馈(使用 hideLoading 避免重复显示loading
const res = await addUserFeedback(feedbackData)
uni.hideLoading()
// 处理响应
if (res && (res.code === 200 || res === true || res?.success === true)) {
uni.showToast({
title: t('feedback.submitSuccess'),
icon: 'success'
})
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: (res && (res.msg || res.message)) || t('feedback.submitFailed'),
icon: 'none'
})
}
} catch (err) {
console.error('feedback submit failed:', err)
uni.hideLoading()
uni.showToast({
title: t('error.networkError') || '网络错误,请重试',
icon: 'none'
})
}
}
</script>
<style lang="scss" scoped>
.feedback-container {
min-height: 100vh;
background: #f7f8fa;
padding: 30rpx;
// 投诉记录入口
.record-entry {
background: #fff;
border-radius: 20rpx;
padding: 28rpx 30rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.entry-left {
display: flex;
align-items: center;
flex: 1;
.entry-icon {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
}
.entry-text {
font-size: 30rpx;
color: #333;
font-weight: 500;
}
}
.entry-right {
display: flex;
align-items: center;
gap: 8rpx;
.entry-desc {
font-size: 24rpx;
color: #999;
}
}
&:active {
opacity: 0.8;
}
}
.section-title {
font-size: 30rpx;
color: #333;
font-weight: 500;
margin-bottom: 20rpx;
}
.type-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.type-grid {
display: flex;
flex-wrap: wrap;
margin: 0 -10rpx;
.type-item {
width: calc(50% - 20rpx);
margin: 10rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f5f5f5;
border-radius: 10rpx;
font-size: 28rpx;
color: #666;
transition: all 0.3s;
&.active {
background: #E8F5EE;
color: #07c160;
}
}
}
}
.description-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.description-input {
width: 100%;
height: 240rpx;
background: #f8f8f8;
border-radius: 10rpx;
padding: 20rpx;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
.word-count {
text-align: right;
font-size: 24rpx;
color: #999;
margin-top: 10rpx;
}
}
.upload-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.upload-grid {
display: flex;
flex-wrap: wrap;
.upload-item {
width: 180rpx;
height: 180rpx;
margin-right: 20rpx;
margin-bottom: 20rpx;
position: relative;
image {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
.delete-btn {
position: absolute;
right: -10rpx;
top: -10rpx;
width: 40rpx;
height: 40rpx;
background: rgba(0, 0, 0, 0.5);
color: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
}
}
.upload-btn {
width: 180rpx;
height: 180rpx;
background: #f5f5f5;
border-radius: 10rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #999;
.plus {
font-size: 60rpx;
line-height: 1;
margin-bottom: 10rpx;
}
.tip {
font-size: 24rpx;
}
}
}
}
.contact-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.contact-input {
width: 100%;
height: 80rpx;
background: #f8f8f8;
border-radius: 10rpx;
padding: 0 20rpx;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
}
.submit-section {
padding: 20rpx 0 40rpx 0;
.submit-btn {
width: 100%;
height: 88rpx;
background: #07c160;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.3);
&:active {
opacity: 0.8;
transform: scale(0.98);
}
}
}
}
</style>
+493
View File
@@ -0,0 +1,493 @@
<template>
<view class="feedback-list-container">
<!-- 状态切换 -->
<view class="status-tabs">
<view v-for="(tab, index) in statusTabs" :key="index" class="tab-item"
:class="{ active: currentTab === index }" @click="switchTab(index)">
{{ tab.text }}
</view>
</view>
<!-- 投诉列表 -->
<scroll-view class="feedback-list" scroll-y @scrolltolower="loadMore" :refresher-enabled="true"
:refresher-triggered="refreshing" @refresherrefresh="onRefresh">
<view class="empty-state" v-if="feedbackList.length === 0 && !loading">
<view class="empty-icon">
<image src="/static/suggess.png" mode="aspectFill" class="empty-icon"></image>
</view>
<text class="empty-text">{{ $t('feedback.noRecord') }}</text>
</view>
<view class="feedback-item" v-for="(item, index) in feedbackList" :key="index"
@click="navigateToDetail(item)">
<view class="item-header">
<view class="header-left">
<view class="status-chip" :class="getStatusClass(item.status)">
{{ getStatusText(item.status) }}
</view>
<view class="type-text">{{ getTypeText(item.type) }}</view>
</view>
<view class="header-right">
<text class="time-text">{{ formatTime(item.createTime) }}</text>
</view>
</view>
<view class="item-content">
<view class="content-text">{{ item.content || '-' }}</view>
<view class="content-images" v-if="getImageList(item).length > 0">
<image v-for="(img, imgIndex) in getImageList(item)" :key="imgIndex" :src="img" mode="aspectFill" class="content-image"></image>
</view>
</view>
<view class="item-footer">
<view class="footer-left">
<text class="phone-text">{{ $t('feedback.contactPhone') }}{{ item.phone || '-' }}</text>
</view>
<view class="footer-right">
<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
</view>
</view>
</view>
<!-- 加载更多 -->
<view class="load-more" v-if="hasMore && feedbackList.length > 0">
<text class="load-more-text">{{ $t('common.loading') }}</text>
</view>
<view class="no-more" v-if="!hasMore && feedbackList.length > 0">
<text class="no-more-text">{{ $t('common.noMore') }}</text>
</view>
</scroll-view>
</view>
</template>
<script setup>
import {
ref,
reactive,
onMounted
} from 'vue';
import {
onLoad,
onShow
} from '@dcloudio/uni-app';
import {
getFeedbackList
} from '@/config/api/feedback.js';
import {
useI18n
} from '@/utils/i18n.js'
const {
t
} = useI18n()
// 设置页面标题
onMounted(() => {
uni.setNavigationBarTitle({
title: t('feedback.recordList')
})
})
// 初始化状态
const currentTab = ref(0);
const feedbackList = ref([]);
const loading = ref(false);
const refreshing = ref(false);
const hasMore = ref(true);
const currentPage = ref(1);
const pageSize = ref(10);
// 状态标签
const statusTabs = reactive([{
get text() {
return t('common.all')
},
status: ''
},
{
get text() {
return t('feedback.pending')
},
status: 'pending'
},
{
get text() {
return t('feedback.processing')
},
status: 'in_progress'
},
{
get text() {
return t('feedback.completed')
},
status: 'resolved'
}
]);
// 页面加载
onLoad(async () => {
await loadFeedbackList();
});
// 页面显示时刷新
onShow(async () => {
// 可以在这里刷新列表
});
// 切换标签
const switchTab = async (index) => {
currentTab.value = index;
currentPage.value = 1;
feedbackList.value = [];
hasMore.value = true;
await loadFeedbackList();
};
// 加载投诉列表
const loadFeedbackList = async (isLoadMore = false) => {
if (loading.value) return;
try {
loading.value = true;
const status = statusTabs[currentTab.value].status;
const params = {
pageNum: currentPage.value,
pageSize: pageSize.value,
};
if (status) {
params.status = status;
}
const res = await getFeedbackList(params);
if (res.code === 200 && res.data) {
const records = res.data.records || res.data.list || [];
if (isLoadMore) {
feedbackList.value = [...feedbackList.value, ...records];
} else {
feedbackList.value = records;
}
// 判断是否还有更多数据
const total = res.data.total || 0;
hasMore.value = feedbackList.value.length < total;
if (hasMore.value) {
currentPage.value += 1;
}
} else {
uni.showToast({
title: res.msg || t('feedback.getListFailed'),
icon: 'none'
});
}
} catch (error) {
console.error('获取投诉列表失败:', error);
uni.showToast({
title: t('feedback.getListFailed'),
icon: 'none'
});
} finally {
loading.value = false;
refreshing.value = false;
}
};
// 加载更多
const loadMore = () => {
if (hasMore.value && !loading.value) {
loadFeedbackList(true);
}
};
// 下拉刷新
const onRefresh = () => {
refreshing.value = true;
currentPage.value = 1;
feedbackList.value = [];
hasMore.value = true;
loadFeedbackList();
};
// 获取状态文本
const getStatusText = (status) => {
const statusMap = {
'pending': t('feedback.pending'),
'in_progress': t('feedback.processing'),
'resolved': t('feedback.completed')
};
return statusMap[status] || t('feedback.pending');
};
// 获取状态样式类
const getStatusClass = (status) => {
const classMap = {
'pending': 'chip-pending',
'in_progress': 'chip-processing',
'resolved': 'chip-completed'
};
return classMap[status] || 'chip-pending';
};
// 获取类型文本
const getTypeText = (type) => {
const typeMap = {
'complain': t('feedback.complain'),
'suggestion': t('feedback.suggestion')
};
return typeMap[type] || type || '-';
};
// 格式化时间
const formatTime = (timeStr) => {
if (!timeStr) return '-';
try {
const date = new Date(timeStr);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}`;
} catch (e) {
return timeStr;
}
};
// 获取图片列表(支持字符串或数组)
const getImageList = (item) => {
if (!item.picturePath) return [];
if (Array.isArray(item.picturePath)) return item.picturePath;
if (typeof item.picturePath === 'string') {
// 如果是逗号分隔的字符串,拆分为数组
if (item.picturePath.includes(',')) {
return item.picturePath.split(',').filter(img => img.trim());
}
return [item.picturePath];
}
return [];
};
// 跳转到详情页
const navigateToDetail = (item) => {
uni.navigateTo({
url: `/pages/feedback/detail?id=${item.id || item.feedbackId}`
});
};
</script>
<style lang="scss" scoped>
.feedback-list-container {
min-height: 100vh;
background: #f7f8fa;
padding-bottom: 30rpx;
// 状态标签栏
.status-tabs {
display: flex;
background: #fff;
padding: 0 20rpx;
position: sticky;
top: 0;
z-index: 10;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
.tab-item {
flex: 1;
height: 90rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
color: #666;
position: relative;
&.active {
color: #07c160;
font-weight: 500;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 4rpx;
background: #07c160;
border-radius: 2rpx;
}
}
}
}
// 投诉列表
.feedback-list {
height: calc(100vh - 90rpx);
padding: 20rpx;
box-sizing: border-box;
// 投诉项
.feedback-item {
width: 100%;
box-sizing: border-box;
background: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
overflow: hidden;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
// 头部
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.header-left {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
margin-right: 16rpx;
.status-chip {
padding: 6rpx 16rpx;
border-radius: 8rpx;
font-size: 24rpx;
margin-right: 16rpx;
flex-shrink: 0;
&.chip-processing {
background: rgba(255, 152, 0, 0.12);
color: #FF9800;
}
&.chip-completed {
background: rgba(76, 175, 80, 0.12);
color: #4CAF50;
}
&.chip-pending {
background: rgba(158, 158, 158, 0.12);
color: #9E9E9E;
}
}
.type-text {
font-size: 28rpx;
color: #333;
font-weight: 500;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.header-right {
flex-shrink: 0;
.time-text {
font-size: 24rpx;
color: #999;
white-space: nowrap;
}
}
}
// 内容
.item-content {
padding: 24rpx;
.content-text {
font-size: 28rpx;
color: #333;
line-height: 1.6;
margin-bottom: 16rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
}
.content-images {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
.content-image {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
background: #f5f5f5;
}
}
}
// 底部
.item-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 24rpx;
background: #fafafa;
border-top: 1rpx solid #f0f0f0;
.footer-left {
flex: 1;
min-width: 0;
margin-right: 16rpx;
.phone-text {
font-size: 24rpx;
color: #999;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.footer-right {
display: flex;
align-items: center;
flex-shrink: 0;
}
}
}
// 空状态
.empty-state {
padding: 100rpx 0;
text-align: center;
.empty-icon {
width: 180rpx;
height: 180rpx;
margin: 0 auto 30rpx;
opacity: 0.5;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
}
// 加载更多
.load-more,
.no-more {
padding: 30rpx 0;
text-align: center;
.load-more-text,
.no-more-text {
font-size: 24rpx;
color: #999;
}
}
}
}
</style>
+143
View File
@@ -0,0 +1,143 @@
<template>
<view class="help-container">
<!-- 常见问题 -->
<view class="faq-section">
<uv-collapse :border="false">
<uv-collapse-item
v-for="(item, index) in faqList"
:key="index"
:title="$t(item.question)"
:name="index"
>
<view class="answer-content">
<text class="answer-text">{{ $t(item.answer) }}</text>
</view>
</uv-collapse-item>
</uv-collapse>
</view>
<!-- 联系客服 -->
<view class="contact-card">
<view class="contact-title">{{ $t('help.contactUs') }}</view>
<view class="contact-content">
<view class="contact-item">
<text class="label">{{ $t('help.phone') }}</text>
<text class="value" @click="makePhoneCall">{{ customerPhone }}</text>
</view>
<view class="contact-item">
<text class="label">{{ $t('help.workingHours') }}</text>
<text class="value">{{ $t('help.workingHoursValue') }}</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { HELP_CONTENT } from '@/constants/help'
import { getCustomerPhone } from '@/util/index.js'
import { useI18n } from '@/utils/i18n.js'
const { t } = useI18n()
const faqList = ref(HELP_CONTENT.FAQ_LIST)
const customerPhone = ref(HELP_CONTENT.CONTACT.PHONE.VALUE)
onLoad(() => {
uni.setNavigationBarTitle({
title: t('help.title')
})
customerPhone.value = getCustomerPhone()
})
const makePhoneCall = () => {
uni.makePhoneCall({
phoneNumber: customerPhone.value
})
}
</script>
<style lang="scss" scoped>
.help-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.faq-section {
background: #fff;
border-radius: 20rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
overflow: hidden;
.answer-content {
padding: 20rpx 30rpx 30rpx;
background: #f9f9f9;
.answer-text {
font-size: 28rpx;
color: #666;
line-height: 1.8;
display: block;
}
}
}
.contact-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.contact-title {
position: relative;
z-index: 4;
display: inline-block;
font-size: 32rpx;
color: #333;
font-weight: 500;
margin-bottom: 20rpx;
padding-bottom: 8rpx;
width: fit-content;
&::after {
z-index: -1;
content: '';
position: absolute;
left: 0;
bottom: 8rpx;
width: 88%;
height: 16rpx;
border-radius: 20rpx;
background: #07C160;
}
}
.contact-content {
.contact-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
.label {
font-size: 28rpx;
color: #666;
}
.value {
font-size: 28rpx;
color: #333;
font-weight: 500;
&:active {
opacity: 0.7;
}
}
}
}
}
}
</style>
File diff suppressed because it is too large Load Diff