186 lines
4.2 KiB
Vue
186 lines
4.2 KiB
Vue
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { ElMessage } from 'element-plus'
|
|
import {
|
|
fetchMyMohongOrders,
|
|
mohongOrderStatusLabel,
|
|
type MohongOrder,
|
|
} from '@/features/mohong/api/mohong'
|
|
import { formatCent } from '@/shared/utils/money'
|
|
import { formatDateTime } from '@/shared/utils/time'
|
|
import { readError } from '@/shared/utils/error'
|
|
|
|
const router = useRouter()
|
|
const loading = ref(false)
|
|
const orders = ref<MohongOrder[]>([])
|
|
|
|
onMounted(loadOrders)
|
|
|
|
async function loadOrders() {
|
|
loading.value = true
|
|
try {
|
|
const result = await fetchMyMohongOrders({ page: 1, page_size: 50 })
|
|
orders.value = result.items || []
|
|
} catch (error) {
|
|
ElMessage.error(readError(error, '加载订单失败'))
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<section class="mohong-orders-page">
|
|
<header class="page-header">
|
|
<div>
|
|
<h1>撞车订单</h1>
|
|
<p class="sub">查看支付状态、复制订单信息、扫码联系客服</p>
|
|
</div>
|
|
<button type="button" class="toolbar-btn outline" @click="router.push('/crash')">
|
|
返回商品列表
|
|
</button>
|
|
</header>
|
|
|
|
<div class="table-wrap">
|
|
<el-table
|
|
v-loading="loading"
|
|
:data="orders"
|
|
border
|
|
stripe
|
|
empty-text="暂无订单"
|
|
style="width: 100%"
|
|
>
|
|
<el-table-column prop="order_no" label="订单号" min-width="200" />
|
|
<el-table-column prop="product_title" label="商品" min-width="180" />
|
|
<el-table-column label="数量" width="90" prop="quantity" align="center" />
|
|
<el-table-column label="金额" width="120" align="right">
|
|
<template #default="{ row }">¥{{ row.amount || formatCent(row.amount_cent) }}</template>
|
|
</el-table-column>
|
|
<el-table-column label="状态" width="110" align="center">
|
|
<template #default="{ row }">
|
|
<span class="status-tag" :class="row.status">
|
|
{{ mohongOrderStatusLabel(row.status) }}
|
|
</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="下单时间" min-width="180">
|
|
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" width="100" fixed="right" align="center">
|
|
<template #default="{ row }">
|
|
<button type="button" class="link-btn" @click="router.push(`/crash/orders/${row.id}`)">
|
|
详情
|
|
</button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.mohong-orders-page {
|
|
display: grid;
|
|
gap: 16px;
|
|
width: 100%;
|
|
}
|
|
|
|
.page-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
gap: 12px;
|
|
width: 100%;
|
|
}
|
|
|
|
.page-header h1 {
|
|
margin: 0 0 4px;
|
|
font-size: 22px;
|
|
font-weight: 800;
|
|
color: #17233d;
|
|
}
|
|
|
|
.sub {
|
|
margin: 0;
|
|
color: #8a94a6;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.toolbar-btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 36px;
|
|
padding: 0 14px;
|
|
border-radius: 10px;
|
|
border: 1px solid rgba(255, 106, 0, 0.32);
|
|
background: #fff8f2;
|
|
color: #ff6a00;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.toolbar-btn:hover {
|
|
border-color: #ff6a00;
|
|
background: #fff3e8;
|
|
box-shadow: 0 4px 12px rgba(255, 106, 0, 0.1);
|
|
}
|
|
|
|
.table-wrap {
|
|
width: 100%;
|
|
background: #fff;
|
|
border: 1px solid #eef1f5;
|
|
border-radius: 14px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.status-tag {
|
|
display: inline-flex;
|
|
padding: 2px 8px;
|
|
border-radius: 999px;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
background: #f1f5f9;
|
|
color: #64748b;
|
|
}
|
|
|
|
.status-tag.pending_payment {
|
|
background: #fff7ed;
|
|
color: #ff6a00;
|
|
}
|
|
|
|
.status-tag.paid {
|
|
background: #ecfdf5;
|
|
color: #059669;
|
|
}
|
|
|
|
.status-tag.completed {
|
|
background: #eff6ff;
|
|
color: #2563eb;
|
|
}
|
|
|
|
.status-tag.cancelled,
|
|
.status-tag.refunded {
|
|
background: #f8fafc;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
.link-btn {
|
|
border: 0;
|
|
background: transparent;
|
|
color: #ff6a00;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
padding: 0;
|
|
}
|
|
|
|
.link-btn:hover {
|
|
color: #e55d00;
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|