feat(store): 在订单列表页新增下单时间展示
- 订单卡片头部左侧新增「下单时间:YYYY-MM-DD HH:mm」显示,位于订单号下方 - 状态标签右侧对齐方式由垂直居中调整为顶端对齐,适配两行文本 - 新增辅助函数 formatOrderTime 兼容 ISO 和空格分隔时间格式,仅保留到分钟 - 复用后台返回的 ShopOrder.createTime 字段,无需后端改动,保证时间数据准确同步
This commit is contained in:
@@ -84,6 +84,17 @@ function formatDateTime(date: Date): string {
|
||||
return `${y}-${m}-${d} ${h}:${mi}:${s}`
|
||||
}
|
||||
|
||||
/** 格式化下单时间为「YYYY-MM-DD HH:mm」,兼容 "2026-07-23T02:00:18" 与 "2026-07-23 02:00:18" */
|
||||
function formatOrderTime(raw?: string): string {
|
||||
if (!raw) return ''
|
||||
const s = raw.replace('T', ' ').trim()
|
||||
const parts = s.split(' ')
|
||||
if (parts.length < 2) return s
|
||||
const timeParts = parts[1].split(':')
|
||||
const hhmm = `${timeParts[0]}:${timeParts[1] || '00'}`
|
||||
return `${parts[0]} ${hhmm}`
|
||||
}
|
||||
|
||||
/** 解析 sendEndImg:兼容 JSON 数组(新格式)和逗号分隔(旧格式) */
|
||||
function parseSendEndImg(raw: string): string[] {
|
||||
if (!raw || !raw.trim()) return []
|
||||
@@ -585,8 +596,13 @@ export default function StoreOrdersPage() {
|
||||
return (
|
||||
<View key={order.orderId} className='bg-white rounded-xl mx-3 mt-3 p-4'>
|
||||
{/* 订单头部 */}
|
||||
<View className='flex justify-between items-center mb-3'>
|
||||
<Text className='text-xs text-gray-400'>订单号:{order.orderNo}</Text>
|
||||
<View className='flex justify-between items-start mb-3'>
|
||||
<View className='flex flex-col'>
|
||||
<Text className='text-xs text-gray-400'>订单号:{order.orderNo}</Text>
|
||||
{order.createTime ? (
|
||||
<Text className='text-xs text-gray-400 mt-1'>下单时间:{formatOrderTime(order.createTime)}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<Text className='text-xs' style={{color: getStatusColor(order)}}>
|
||||
{getStatusText(order)}
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user