|
|
@@ -1,9 +1,12 @@
|
|
|
import { useState, useEffect } from 'react';
|
|
|
-import { View, Text, ScrollView, Button } from '@tarojs/components';
|
|
|
+import { View, Text, ScrollView } from '@tarojs/components';
|
|
|
+import { Button } from '@/components/ui/button';
|
|
|
+import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
|
|
import Taro from '@tarojs/taro';
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
import { orderClient } from '@/api';
|
|
|
import { OrderStatus } from '@/types/order.types';
|
|
|
+import { Navbar } from '@/components/ui/navbar';
|
|
|
|
|
|
const OrderDetailPage = () => {
|
|
|
const [orderId, setOrderId] = useState<number | null>(null);
|
|
|
@@ -111,7 +114,7 @@ const OrderDetailPage = () => {
|
|
|
case OrderStatus.CANCELLED:
|
|
|
return 'text-error';
|
|
|
default:
|
|
|
- return 'text-muted-foreground';
|
|
|
+ return 'text-gray-500';
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -128,7 +131,7 @@ const OrderDetailPage = () => {
|
|
|
<View className="flex flex-col items-center justify-center py-16">
|
|
|
<Text className="text-lg text-error mb-4">加载失败</Text>
|
|
|
<Button
|
|
|
- className="bg-primary text-primary-foreground px-4 py-2 rounded-md"
|
|
|
+ variant="default"
|
|
|
onClick={() => Taro.navigateBack()}
|
|
|
>
|
|
|
返回
|
|
|
@@ -138,133 +141,154 @@ const OrderDetailPage = () => {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <View className="min-h-screen bg-background">
|
|
|
- <ScrollView className="px-4 py-4" scrollY>
|
|
|
+ <View className="min-h-screen bg-gray-50">
|
|
|
+ <Navbar
|
|
|
+ title="订单详情"
|
|
|
+ backgroundColor="bg-primary"
|
|
|
+ textColor="text-white"
|
|
|
+ border={false}
|
|
|
+ leftIcon="i-heroicons-arrow-left-20-solid"
|
|
|
+ onClickLeft={() => Taro.navigateBack()}
|
|
|
+ rightIcon=""
|
|
|
+ />
|
|
|
+ <ScrollView className="px-4 pt-4" scrollY>
|
|
|
{/* 订单基本信息 */}
|
|
|
- <View className="bg-card rounded-card shadow-medium p-card border border-border mb-4">
|
|
|
- <Text className="text-lg font-semibold mb-4">订单信息</Text>
|
|
|
-
|
|
|
- <View className="space-y-3">
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">订单号:</Text>
|
|
|
- <Text>{order.id}</Text>
|
|
|
- </View>
|
|
|
+ <Card className="rounded-card shadow-medium mb-4">
|
|
|
+ <CardHeader className="border-b border-gray-200">
|
|
|
+ <Text className="text-lg font-semibold">订单信息</Text>
|
|
|
+ </CardHeader>
|
|
|
+ <CardContent className="p-card">
|
|
|
+ <View className="space-y-3">
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">订单号:</Text>
|
|
|
+ <Text>{order.id}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">行程路线:</Text>
|
|
|
- <Text className="text-right">
|
|
|
- {order.routeSnapshot?.pickupPoint} → {order.routeSnapshot?.dropoffPoint}
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">行程路线:</Text>
|
|
|
+ <Text className="text-right">
|
|
|
+ {order.routeSnapshot?.pickupPoint} → {order.routeSnapshot?.dropoffPoint}
|
|
|
+ </Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">出发时间:</Text>
|
|
|
- <Text>
|
|
|
- {order.routeSnapshot?.departureTime
|
|
|
- ? new Date(order.routeSnapshot.departureTime).toLocaleString('zh-CN')
|
|
|
- : '未知时间'
|
|
|
- }
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">出发时间:</Text>
|
|
|
+ <Text>
|
|
|
+ {order.routeSnapshot?.departureTime
|
|
|
+ ? new Date(order.routeSnapshot.departureTime).toLocaleString('zh-CN')
|
|
|
+ : '未知时间'
|
|
|
+ }
|
|
|
+ </Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">车辆型号:</Text>
|
|
|
- <Text>{order.routeSnapshot?.vehicleType || '未知车型'}</Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">车辆型号:</Text>
|
|
|
+ <Text>{order.routeSnapshot?.vehicleType || '未知车型'}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">乘车人数:</Text>
|
|
|
- <Text>{order.passengerCount}人</Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">乘车人数:</Text>
|
|
|
+ <Text>{order.passengerCount}人</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">订单状态:</Text>
|
|
|
- <Text className={`font-medium ${getStatusColor(order.status)}`}>
|
|
|
- {order.status}
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">订单状态:</Text>
|
|
|
+ <Text className={`font-medium ${getStatusColor(order.status)}`}>
|
|
|
+ {order.status}
|
|
|
+ </Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">支付状态:</Text>
|
|
|
- <Text>{order.paymentStatus}</Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">支付状态:</Text>
|
|
|
+ <Text>{order.paymentStatus}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">订单金额:</Text>
|
|
|
- <Text className="text-lg font-semibold text-primary">¥{order.totalAmount}</Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">订单金额:</Text>
|
|
|
+ <Text className="text-lg font-semibold text-primary">¥{order.totalAmount}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">下单时间:</Text>
|
|
|
- <Text>{new Date(order.createdAt).toLocaleString('zh-CN')}</Text>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">下单时间:</Text>
|
|
|
+ <Text>{new Date(order.createdAt).toLocaleString('zh-CN')}</Text>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
+ </CardContent>
|
|
|
+ </Card>
|
|
|
|
|
|
{/* 乘客信息 */}
|
|
|
{order.passengerSnapshots && order.passengerSnapshots.length > 0 && (
|
|
|
- <View className="bg-card rounded-card shadow-medium p-card border border-border mb-4">
|
|
|
- <Text className="text-lg font-semibold mb-4">乘客信息</Text>
|
|
|
-
|
|
|
- <View className="space-y-3">
|
|
|
- {order.passengerSnapshots.map((passenger, index) => (
|
|
|
- <View key={index} className="border-b border-border pb-3 last:border-b-0 last:pb-0">
|
|
|
- <View className="flex justify-between mb-1">
|
|
|
- <Text className="font-medium">{passenger.name}</Text>
|
|
|
- <Text className="text-sm text-muted-foreground">
|
|
|
- {passenger.idType === 'ID_CARD' ? '身份证' : '护照'}
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
-
|
|
|
- <View className="space-y-1 text-sm">
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">证件号码:</Text>
|
|
|
- <Text>{passenger.idNumber}</Text>
|
|
|
+ <Card className="rounded-card shadow-medium mb-4">
|
|
|
+ <CardHeader className="border-b border-gray-200">
|
|
|
+ <Text className="text-lg font-semibold">乘客信息</Text>
|
|
|
+ </CardHeader>
|
|
|
+ <CardContent className="p-card">
|
|
|
+ <View className="space-y-3">
|
|
|
+ {order.passengerSnapshots.map((passenger, index) => (
|
|
|
+ <View key={index} className="border-b border-gray-200 pb-3 last:border-b-0 last:pb-0">
|
|
|
+ <View className="flex justify-between mb-1">
|
|
|
+ <Text className="font-medium">{passenger.name}</Text>
|
|
|
+ <Text className="text-sm text-gray-500">
|
|
|
+ {passenger.idType === 'ID_CARD' ? '身份证' : '护照'}
|
|
|
+ </Text>
|
|
|
</View>
|
|
|
|
|
|
- {passenger.phone && (
|
|
|
+ <View className="space-y-1 text-sm">
|
|
|
<View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">联系电话:</Text>
|
|
|
- <Text>{passenger.phone}</Text>
|
|
|
+ <Text className="text-gray-500">证件号码:</Text>
|
|
|
+ <Text>{passenger.idNumber}</Text>
|
|
|
</View>
|
|
|
- )}
|
|
|
+
|
|
|
+ {passenger.phone && (
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">联系电话:</Text>
|
|
|
+ <Text>{passenger.phone}</Text>
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
- ))}
|
|
|
- </View>
|
|
|
- </View>
|
|
|
+ ))}
|
|
|
+ </View>
|
|
|
+ </CardContent>
|
|
|
+ </Card>
|
|
|
)}
|
|
|
|
|
|
{/* 路线快照信息 */}
|
|
|
{order.routeSnapshot && (
|
|
|
- <View className="bg-card rounded-card shadow-medium p-card border border-border mb-4">
|
|
|
- <Text className="text-lg font-semibold mb-4">行程详情</Text>
|
|
|
-
|
|
|
- <View className="space-y-3">
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">活动名称:</Text>
|
|
|
- <Text>{order.routeSnapshot.name}</Text>
|
|
|
- </View>
|
|
|
+ <Card className="rounded-card shadow-medium mb-4">
|
|
|
+ <CardHeader className="border-b border-gray-200">
|
|
|
+ <Text className="text-lg font-semibold">行程详情</Text>
|
|
|
+ </CardHeader>
|
|
|
+ <CardContent className="p-card">
|
|
|
+ <View className="space-y-3">
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">活动名称:</Text>
|
|
|
+ <Text>{order.routeSnapshot.name}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">出行方式:</Text>
|
|
|
- <Text>{order.routeSnapshot.travelMode === 'DRIVING' ? '驾车' : '其他'}</Text>
|
|
|
- </View>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">出行方式:</Text>
|
|
|
+ <Text>{order.routeSnapshot.travelMode === 'DRIVING' ? '驾车' : '其他'}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View className="flex justify-between">
|
|
|
- <Text className="text-muted-foreground">单价:</Text>
|
|
|
- <Text>¥{order.routeSnapshot.price}</Text>
|
|
|
+ <View className="flex justify-between">
|
|
|
+ <Text className="text-gray-500">单价:</Text>
|
|
|
+ <Text>¥{order.routeSnapshot.price}</Text>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
+ </CardContent>
|
|
|
+ </Card>
|
|
|
)}
|
|
|
+ {/* 底部占位,避免被操作按钮遮挡 */}
|
|
|
+ <View className="h-20"></View>
|
|
|
</ScrollView>
|
|
|
|
|
|
{/* 底部操作按钮 */}
|
|
|
{order.status === OrderStatus.WAITING_DEPARTURE && (
|
|
|
- <View className="fixed bottom-0 left-0 right-0 bg-white border-t border-border p-4">
|
|
|
+ <View className="fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 p-4">
|
|
|
<Button
|
|
|
- className="bg-error text-error-foreground w-full py-3 rounded-md"
|
|
|
+ variant="destructive"
|
|
|
+ className="w-full"
|
|
|
onClick={handleCancelOrder}
|
|
|
loading={cancelOrderMutation.isPending}
|
|
|
>
|