|
|
@@ -1,6 +1,5 @@
|
|
|
import { View, Text } from '@tarojs/components'
|
|
|
import { useLoad, useRouter, navigateTo } from '@tarojs/taro'
|
|
|
-import { useState, useEffect } from 'react'
|
|
|
import { Button } from '@/components/ui/button'
|
|
|
import { Card, CardContent } from '@/components/ui/card'
|
|
|
|
|
|
@@ -9,58 +8,13 @@ export default function PaySuccessPage() {
|
|
|
const {
|
|
|
totalPrice = '0',
|
|
|
passengerCount = '0',
|
|
|
- orderId = '',
|
|
|
- orderType = 'bus'
|
|
|
+ orderId = ''
|
|
|
} = router.params
|
|
|
|
|
|
- const [assigningDriver, setAssigningDriver] = useState(false)
|
|
|
- const [driverAssigned, setDriverAssigned] = useState(false)
|
|
|
- const [driverInfo, setDriverInfo] = useState<any>(null)
|
|
|
-
|
|
|
useLoad(() => {
|
|
|
- // 支付成功后自动分配司机
|
|
|
- if (orderId) {
|
|
|
- assignDriver()
|
|
|
- }
|
|
|
+ console.log('支付成功页面加载,订单ID:', orderId)
|
|
|
})
|
|
|
|
|
|
- // 分配司机
|
|
|
- const assignDriver = async () => {
|
|
|
- if (!orderId) {
|
|
|
- console.warn('订单ID为空,跳过司机分配')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- setAssigningDriver(true)
|
|
|
-
|
|
|
- try {
|
|
|
- // TODO: 待司机分配API开发完成后替换为真实API调用
|
|
|
- // const result = await api.drivers.assignToOrder(orderId, orderType)
|
|
|
- // setDriverInfo(result.data)
|
|
|
-
|
|
|
- // 模拟司机分配过程
|
|
|
- setTimeout(() => {
|
|
|
- const mockDriverInfo = {
|
|
|
- driverName: '李师傅',
|
|
|
- rating: 4.9,
|
|
|
- carNumber: '京A12345',
|
|
|
- carModel: '奔驰V级商务车',
|
|
|
- estimatedArrival: {
|
|
|
- display: '约15分钟'
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- setAssigningDriver(false)
|
|
|
- setDriverAssigned(true)
|
|
|
- setDriverInfo(mockDriverInfo)
|
|
|
- }, 2000)
|
|
|
-
|
|
|
- } catch (error) {
|
|
|
- setAssigningDriver(false)
|
|
|
- console.error('司机分配失败:', error)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 查看订单
|
|
|
const handleViewOrder = () => {
|
|
|
navigateTo({
|
|
|
@@ -102,81 +56,6 @@ export default function PaySuccessPage() {
|
|
|
</CardContent>
|
|
|
</Card>
|
|
|
|
|
|
- {/* 积分奖励 */}
|
|
|
- <Card className="mb-8 bg-white/95 backdrop-blur-sm border-white/40">
|
|
|
- <CardContent className="p-6">
|
|
|
- <Text className="text-lg font-bold text-gray-900 mb-6 text-center">本次获得奖励</Text>
|
|
|
- <View className="flex justify-around mb-6">
|
|
|
- <View className="flex flex-col items-center">
|
|
|
- <View className="w-16 h-16 bg-blue-50 rounded-full flex items-center justify-center mb-3">
|
|
|
- <Text className="text-2xl">💰</Text>
|
|
|
- </View>
|
|
|
- <Text className="text-2xl font-bold text-primary mb-1">+{Math.floor(parseFloat(totalPrice))}</Text>
|
|
|
- <Text className="text-xs text-gray-600">积分</Text>
|
|
|
- </View>
|
|
|
- <View className="flex flex-col items-center">
|
|
|
- <View className="w-16 h-16 bg-blue-50 rounded-full flex items-center justify-center mb-3">
|
|
|
- <Text className="text-2xl">💎</Text>
|
|
|
- </View>
|
|
|
- <Text className="text-2xl font-bold text-primary mb-1">+{Math.floor(parseFloat(totalPrice))}</Text>
|
|
|
- <Text className="text-xs text-gray-600">会员值</Text>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <Text className="text-xs text-gray-500 text-center leading-5">
|
|
|
- 消费1元得1积分+1会员值,积分可兑换优惠券
|
|
|
- </Text>
|
|
|
- </CardContent>
|
|
|
- </Card>
|
|
|
-
|
|
|
- {/* 司机分配状态 */}
|
|
|
- <View className="mb-8">
|
|
|
- {assigningDriver && (
|
|
|
- <Card className="bg-white/95 backdrop-blur-sm border-white/40">
|
|
|
- <CardContent className="p-8 text-center">
|
|
|
- <Text className="text-6xl mb-4 animate-bounce">🚗</Text>
|
|
|
- <Text className="text-lg font-semibold text-gray-900 mb-2">正在为您分配司机...</Text>
|
|
|
- <Text className="text-sm text-gray-600">预计需要1-2分钟</Text>
|
|
|
- </CardContent>
|
|
|
- </Card>
|
|
|
- )}
|
|
|
-
|
|
|
- {driverAssigned && driverInfo && (
|
|
|
- <Card className="bg-white/95 backdrop-blur-sm border-white/40">
|
|
|
- <CardContent className="p-6">
|
|
|
- <View className="flex items-center justify-center mb-6">
|
|
|
- <View className="w-6 h-6 bg-success rounded-full flex items-center justify-center mr-3">
|
|
|
- <Text className="text-white text-xs">✓</Text>
|
|
|
- </View>
|
|
|
- <Text className="text-lg font-semibold text-success">司机分配成功</Text>
|
|
|
- </View>
|
|
|
- <Card className="bg-blue-50 border-blue-100">
|
|
|
- <CardContent className="p-4">
|
|
|
- <View className="flex items-center justify-between mb-4 pb-4 border-b border-blue-100">
|
|
|
- <Text className="text-lg font-semibold text-gray-900">{driverInfo.driverName}</Text>
|
|
|
- <View className="flex items-center bg-warning/20 px-2 py-1 rounded-full">
|
|
|
- <Text className="text-warning text-sm">⭐ {driverInfo.rating}</Text>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <View className="space-y-3">
|
|
|
- <View className="flex items-center">
|
|
|
- <Text className="text-sm text-gray-600 w-20 flex-shrink-0">车牌号:</Text>
|
|
|
- <Text className="text-sm text-gray-900 font-medium flex-1">{driverInfo.carNumber}</Text>
|
|
|
- </View>
|
|
|
- <View className="flex items-center">
|
|
|
- <Text className="text-sm text-gray-600 w-20 flex-shrink-0">车型:</Text>
|
|
|
- <Text className="text-sm text-gray-900 font-medium flex-1">{driverInfo.carModel}</Text>
|
|
|
- </View>
|
|
|
- <View className="flex items-center">
|
|
|
- <Text className="text-sm text-gray-600 w-20 flex-shrink-0">预计到达:</Text>
|
|
|
- <Text className="text-sm text-gray-900 font-medium flex-1">{driverInfo.estimatedArrival.display}</Text>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </CardContent>
|
|
|
- </Card>
|
|
|
- </CardContent>
|
|
|
- </Card>
|
|
|
- )}
|
|
|
- </View>
|
|
|
|
|
|
{/* 操作按钮 */}
|
|
|
<View className="flex gap-4">
|