| | |
| | | const requoteTriggeredRef = useRef(false); // 重新报价触发标记,防止重复触发 |
| | | const [callSubmitting, setCallSubmitting] = useState(false); // 呼叫车辆提交中状态 |
| | | const [orderId, setOrderId] = useState<string>(''); // 订单ID |
| | | const [doorUnlockedInCurrentPage, setDoorUnlockedInCurrentPage] = useState(false); // 当前页面内是否已解锁过车门 |
| | | const [doorUnlockedInCurrentPage, setDoorUnlockedInCurrentPage] = useState(() => { |
| | | return getDoorUnlockCache(getOrderId(String(Taro.getStorageSync('orderId') || ''))); |
| | | }); // 当前页面内是否已解锁过车门 |
| | | const [finishCountdownEnabled, setFinishCountdownEnabled] = useState(false); // 完成倒计时是否启用 |
| | | const customCalloutIconUrl = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/maker-tooltip-right.png'; // 自定义气泡图标URL |
| | | const waitingCalloutBgUrl = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/maker-tooltip-bg.png'; // 等待气泡背景图URL |
| | |
| | | lastVehiclePointRef, |
| | | lastVehicleUpdateAtRef |
| | | } = vehicleState; // 车辆状态解构 |
| | | const resolveDoorUnlockTargetOrderId = useCallback((explicitOrderId?: string) => { |
| | | return getOrderId(explicitOrderId || orderId || Taro.getStorageSync('orderId') || ''); |
| | | }, [orderId]); |
| | | const restoreDoorUnlockUiState = useCallback((explicitOrderId?: string) => { |
| | | const targetOrderId = resolveDoorUnlockTargetOrderId(explicitOrderId); |
| | | setDoorUnlockedInCurrentPage(getDoorUnlockCache(targetOrderId)); |
| | | }, [resolveDoorUnlockTargetOrderId]); |
| | | const markDoorUnlockedForCurrentOrder = useCallback((explicitOrderId?: string) => { |
| | | const targetOrderId = resolveDoorUnlockTargetOrderId(explicitOrderId); |
| | | if (!targetOrderId) { |
| | | return; |
| | | } |
| | | setDoorUnlockedInCurrentPage(true); |
| | | setDoorUnlockCache(targetOrderId); |
| | | }, [resolveDoorUnlockTargetOrderId]); |
| | | const routeState = useRouteManager({ |
| | | isAndroid, |
| | | tripStatus, |
| | |
| | | if (!isOpenDoor) { |
| | | return; |
| | | } |
| | | const targetOrderId = getOrderId(orderId || Taro.getStorageSync('orderId') || ''); |
| | | if (!targetOrderId) { |
| | | return; |
| | | } |
| | | setDoorUnlockedInCurrentPage(true); |
| | | setDoorUnlockCache(targetOrderId); |
| | | markDoorUnlockedForCurrentOrder(); |
| | | }, |
| | | setCurrentUserLocation, |
| | | handleOpenNoRoutePopup |
| | |
| | | * 手动解锁成功后,同步页面级开门态并写入订单级缓存,供重新进页恢复 UI。 |
| | | */ |
| | | const handleDoorUnlockSuccess = useCallback(() => { |
| | | const targetOrderId = getOrderId(orderId || Taro.getStorageSync('orderId') || ''); |
| | | if (!targetOrderId) { |
| | | return; |
| | | } |
| | | setDoorUnlockedInCurrentPage(true); |
| | | setDoorUnlockCache(targetOrderId); |
| | | }, [orderId]); |
| | | markDoorUnlockedForCurrentOrder(); |
| | | }, [markDoorUnlockedForCurrentOrder]); |
| | | |
| | | /** |
| | | * 订单切换后重置当前页面内的车门打开态,避免串单。 |
| | | */ |
| | | useEffect(() => { |
| | | setDoorUnlockedInCurrentPage(getDoorUnlockCache(getOrderId(orderId))); |
| | | }, [orderId]); |
| | | restoreDoorUnlockUiState(orderId); |
| | | }, [orderId, restoreDoorUnlockUiState]); |
| | | |
| | | /** |
| | | * 页面重新展示后按当前订单缓存恢复开门 UI,避免退出再进入时丢态。 |
| | | */ |
| | | useEffect(() => { |
| | | restoreDoorUnlockUiState(orderId); |
| | | }, [pageDidShowVersion, orderId, restoreDoorUnlockUiState]); |
| | | |
| | | const { queryPaymentResult: queryOrderPaymentResult } = useOrderPaymentResultQuery({ |
| | | orderId, |
| | |
| | | |
| | | useDidShow(() => { |
| | | setPageDidShowVersion((v) => v + 1); |
| | | const targetOrderId = getOrderId(orderId || Taro.getStorageSync('orderId') || ''); |
| | | setDoorUnlockedInCurrentPage(getDoorUnlockCache(targetOrderId)); |
| | | handleDidShow(router.params?.skipPageFlag, router.params?.fromModifyDestination); |
| | | updateMapViewportPadding(); |
| | | // 完成态下隐藏小程序再恢复时,受控中心点可能与原生地图实际中心脱钩,主动触发一次 |