feat(jd-order): 重构订单历史抽屉组件

- 修改时间线关键帧的 key 为 jdOrderId 或 index
- 更新时间线点颜色逻辑,使用 status 字段替代 changeType
- 替换时间线图标,使用状态对应的图标
- 更新标签颜色和文本显示逻辑,基于 status 字段
- 时间显示优先使用 updatedAt,其次 createdAt
- 新增订单金额和商品品类显示
- 调整分页请求参数顺序
- 删除冗余的 orderType 属性
- 更新组件导入和类型定义
- 移除无用的枚举类型导入
This commit is contained in:
danial
2025-10-13 21:51:01 +08:00
parent a02aee28b0
commit f9c80df41f
3 changed files with 58 additions and 49 deletions

View File

@@ -14,37 +14,37 @@
<a-timeline v-else class="history-timeline">
<a-timeline-item
v-for="(item, index) in historyList"
:key="item.historyUuid"
:dot-color="getTimelineDotColor(item.changeType)"
:key="item.jdOrderId || index"
:dot-color="getTimelineDotColor(item.status)"
:line-type="index === historyList.length - 1 ? 'dashed' : 'solid'"
>
<template #dot>
<icon-history
v-if="item.changeType === 'create'"
:style="{ color: '#00b42a', fontSize: '16px' }"
<icon-clock-circle
v-if="item.status === 1"
:style="{ color: '#ff7d00', fontSize: '16px' }"
/>
<icon-pay
v-else-if="item.changeType === 'pay'"
v-else-if="item.status === 2"
:style="{ color: '#00b42a', fontSize: '16px' }"
/>
<icon-truck
v-else-if="item.status === 3"
:style="{ color: '#165dff', fontSize: '16px' }"
/>
<icon-clock-circle
v-else-if="item.changeType === 'expire'"
<icon-close-circle
v-else-if="item.status === 4 || item.status === 5"
:style="{ color: '#f53f3f', fontSize: '16px' }"
/>
<icon-refresh
v-else-if="item.changeType === 'rebind'"
:style="{ color: '#ff7d00', fontSize: '16px' }"
/>
<icon-more v-else :style="{ color: '#86909c', fontSize: '16px' }" />
</template>
<div class="timeline-content">
<div class="timeline-header">
<a-tag :color="getChangeTypeColor(item.changeType)" size="small">
{{ getChangeTypeText(item.changeType) }}
<a-tag :color="getStatusColor(item.status)" size="small">
{{ getStatusText(item.status) }}
</a-tag>
<span class="timeline-time">
{{ formatTime(item.createdAt) }}
{{ formatTime(item.updatedAt || item.createdAt) }}
</span>
</div>
@@ -63,6 +63,18 @@
</a-typography-text>
</div>
<div v-if="item.amount" class="detail-item">
<span class="detail-label">订单金额:</span>
<span class="arco-text-primary">
¥{{ item.amount?.toFixed(2) }}
</span>
</div>
<div v-if="item.category" class="detail-item">
<span class="detail-label">商品品类:</span>
<span>{{ item.category }}</span>
</div>
<div v-if="item.wxPayUrl" class="detail-item">
<span class="detail-label">支付链接:</span>
<a-link :href="item.wxPayUrl" target="_blank" type="primary">
@@ -110,15 +122,14 @@ interface Emits {
}
const props = withDefaults(defineProps<Props>(), {
visible: false,
orderType: ApiJdCookieHistoryOrderGetOrderTypeEnum.User
visible: false
});
const emit = defineEmits<Emits>();
// 数据状态
const loading = ref(false);
const historyList = ref<KamiApiJdCookieV1OrderHistoryInfo[]>([]);
const historyList = ref<KamiApiJdCookieV1JdOrderInfo[]>([]);
const total = ref(0);
const currentPage = ref(1);
const pageSize = ref(20);
@@ -139,11 +150,10 @@ const fetchHistory = async () => {
loading.value = true;
try {
const response = await jdHistoryClient.apiJdCookieHistoryOrderGet({
orderId: props.orderId,
orderType: props.orderType!,
const response = await jdOrderClient.apiJdCookieOrderJdListGet({
page: currentPage.value,
size: pageSize.value
size: pageSize.value,
orderId: props.orderId
});
historyList.value = response.data.list || [];
@@ -169,37 +179,40 @@ const onPageSizeChange = (size: number) => {
fetchHistory();
};
// 获取变更类型颜色
const getChangeTypeColor = (type?: string): string => {
const colorMap: Record<string, string> = {
create: 'green',
pay: 'blue',
expire: 'red',
rebind: 'orange'
// 获取状态颜色
const getStatusColor = (status?: number): string => {
const colorMap: Record<number, string> = {
1: 'orange', // 待支付
2: 'green', // 已支付
3: 'blue', // 已发货
4: 'red', // 已过期
5: 'gray' // 已取消
};
return colorMap[type || ''] || 'gray';
return colorMap[status || 0] || 'gray';
};
// 获取变更类型文本
const getChangeTypeText = (type?: string): string => {
const textMap: Record<string, string> = {
create: '创建订单',
pay: '支付完成',
expire: '订单过期',
rebind: '重新绑定'
// 获取状态文本
const getStatusText = (status?: number): string => {
const textMap: Record<number, string> = {
1: '待支付',
2: '支付',
3: '已发货',
4: '已过期',
5: '已取消'
};
return textMap[type || ''] || '未知操作';
return textMap[status || 0] || '未知状态';
};
// 获取时间线点颜色
const getTimelineDotColor = (type?: string): string => {
const colorMap: Record<string, string> = {
create: '#00b42a',
pay: '#165dff',
expire: '#f53f3f',
rebind: '#ff7d00'
const getTimelineDotColor = (status?: number): string => {
const colorMap: Record<number, string> = {
1: '#ff7d00', // 待支付
2: '#00b42a', // 已支付
3: '#165dff', // 已发货
4: '#f53f3f', // 已过期
5: '#86909c' // 已取消
};
return colorMap[type || ''] || '#86909c';
return colorMap[status || 0] || '#86909c';
};
// 格式化时间

View File

@@ -226,7 +226,6 @@
<order-history-drawer
v-model:visible="historyVisible"
:order-id="currentOrderId"
:order-type="ApiJdCookieHistoryOrderGetOrderTypeEnum.Jd"
/>
</div>
</template>
@@ -239,7 +238,6 @@ import useLoading from '@/hooks/loading';
import { Pagination } from '@/types/global';
import { jdOrderClient } from '@/api';
import type { KamiApiJdCookieV1JdOrderInfo } from '@/api/generated';
import { ApiJdCookieHistoryOrderGetOrderTypeEnum } from '@/api/generated';
import OrderHistoryDrawer from '../components/order-history-drawer.vue';
const { loading, setLoading } = useLoading(true);

View File

@@ -119,7 +119,6 @@
<order-history-drawer
v-model:visible="historyVisible"
:order-id="currentOrderId"
:order-type="ApiJdCookieHistoryOrderGetOrderTypeEnum.User"
/>
</div>
</template>
@@ -135,7 +134,6 @@ import type {
KamiApiJdCookieV1ListOrderRes,
KamiApiJdCookieV1OrderInfo
} from '@/api/generated';
import { ApiJdCookieHistoryOrderGetOrderTypeEnum } from '@/api/generated';
import OrderDetail from './components/order-detail.vue';
import OrderHistoryDrawer from '../components/order-history-drawer.vue';