Files
JayuCloud/JY-Artist-Frontend/src/views/AfterSalesView.vue
T
2026-06-29 23:26:43 +08:00

123 lines
5.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { LeftOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { afterSaleApi, type AfterSaleVO } from '../api/order'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const records = ref<AfterSaleVO[]>([])
const focusOrderId = computed(() => String(route.query.orderId || ''))
const focusedRecords = computed(() => {
if (!focusOrderId.value) return records.value
return records.value.filter(item => String(item.orderId) === focusOrderId.value)
})
const statusText = (status?: string) => {
if (status === 'PENDING') return '审核中'
if (status === 'APPROVED') return '已通过'
if (status === 'REJECTED') return '已拒绝'
return status || '处理中'
}
const typeText = (type?: string) => type === 'REFUND' ? '退款' : (type || '售后')
const formatMoney = (value?: number) => value === undefined || value === null ? '--' : `¥${Number(value).toFixed(2)}`
const formatTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
const loadRecords = async () => {
loading.value = true
try {
const page = await afterSaleApi.listMy({ page: 1, size: 50 })
records.value = page?.list || []
} catch (error: any) {
records.value = []
message.error(error?.message || '售后记录加载失败')
} finally {
loading.value = false
}
}
onMounted(loadRecords)
</script>
<template>
<div class="after-sales-page">
<header class="header">
<a-button type="text" @click="router.back()">
<LeftOutlined />
</a-button>
<h1>售后记录</h1>
<a-button type="link" @click="loadRecords">刷新</a-button>
</header>
<main class="content">
<section class="hero-card">
<span>售后服务</span>
<h2>{{ focusedRecords.length }} 条记录</h2>
<p>{{ focusOrderId ? `订单 ${focusOrderId} 的售后进度` : '查看退款、售后审核与处理说明' }}</p>
</section>
<a-spin :spinning="loading">
<a-empty v-if="!focusedRecords.length" description="暂无售后记录">
<a-button type="primary" @click="router.push('/orders')">查看订单</a-button>
</a-empty>
<article v-for="item in focusedRecords" :key="item.id" class="record-card">
<div class="record-head">
<div>
<span class="record-label">{{ typeText(item.type) }}</span>
<h3>{{ item.afterSaleNo || `售后 ${item.id}` }}</h3>
</div>
<strong>{{ statusText(item.status) }}</strong>
</div>
<dl>
<div>
<dt>订单</dt>
<dd>{{ item.orderId }}</dd>
</div>
<div>
<dt>金额</dt>
<dd>{{ formatMoney(item.refundAmount) }}</dd>
</div>
<div>
<dt>提交时间</dt>
<dd>{{ formatTime(item.createTime) }}</dd>
</div>
</dl>
<p v-if="item.reason">原因:{{ item.reason }}</p>
<p v-if="item.auditReason">处理说明:{{ item.auditReason }}</p>
<div class="actions">
<a-button size="small" @click="router.push(`/orders/${item.orderId}`)">订单详情</a-button>
<a-button size="small" @click="router.push({ path: '/service-progress', query: { orderId: String(item.orderId) } })">服务进度</a-button>
</div>
</article>
</a-spin>
</main>
</div>
</template>
<style scoped>
.after-sales-page { min-height: 100vh; padding-top: 60px; background: var(--theme-page-bg); color: var(--text-primary); }
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 9px 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); border-bottom: 1px solid var(--theme-border); backdrop-filter: blur(14px); }
.header h1 { margin: 0; font-size: 18px; }
.content { padding: 16px 14px 32px; }
.hero-card, .record-card { border: 1px solid var(--theme-border); border-radius: 20px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); box-shadow: 0 18px 44px rgba(74, 68, 63, 0.08); }
.hero-card { padding: 22px; margin-bottom: 14px; background: var(--theme-gradient-soft); }
.hero-card span, .record-label { color: var(--theme-primary); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.hero-card h2 { margin: 10px 0 6px; font-size: 21px; }
.hero-card p, .record-card p { margin: 0; color: var(--text-secondary); line-height: 1.6; }
.record-card { padding: 16px; margin-top: 14px; }
.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-head h3 { margin: 6px 0 0; font-size: 17px; }
.record-head strong { flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--theme-primary-soft); color: var(--theme-primary); font-size: 12px; }
dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
dt { color: var(--text-secondary); font-size: 12px; }
dd { margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
:deep(.ant-btn-primary) { background: var(--theme-primary); border-color: var(--theme-primary); }
:deep(.ant-btn-link) { color: var(--theme-primary); }
</style>