| | |
| | | const startSiteRef = useRef<any>(deps.startSite); // 上车点引用 |
| | | const endSiteRef = useRef<any>(deps.endSite); // 下车点引用 |
| | | const infoStatusRef = useRef<TripStatus | null>(null); // 最新详情状态引用 |
| | | const lastRouteIdRef = useRef<string>(''); // 最近一次路线 ID,辅助识别修改目的地后的新路线 |
| | | const errorToastShownRef = useRef(false); // 错误提示节流标记 |
| | | const applySmoothRouteSnapshotRef = useRef(deps.applySmoothRouteSnapshot); // 平滑快照消费函数引用 |
| | | |
| | |
| | | |
| | | const applyShareInfo = (info: any) => { |
| | | const mappedStatus = resolveShareTripStatus(info?.status); |
| | | |
| | | const nextStartSite = buildSite(info, 'start'); |
| | | const nextEndSite = buildSite(info, 'end'); |
| | | const etaMinutes = Math.max( |
| | |
| | | const routeStatus = resolveRouteOrderStatus(routeResponse); |
| | | const routeEndPoint = extractRouteEndPoint(routeResponse); |
| | | const currentEndSitePoint = normalizePoint(endSiteRef.current); |
| | | // 行程中修改目的地时,订单状态通常不变,因此需要额外通过路线终点变化补拉详情。 |
| | | const hasRouteDestinationChanged = ( |
| | | !!routeEndPoint |
| | | && !!currentEndSitePoint |
| | | && !isSameCoordinate(routeEndPoint, currentEndSitePoint) |
| | | const routeKey = String( |
| | | getFieldValue(routeResponse?.content?.route, ['routeID', 'routeId']) |
| | | ?? getFieldValue(routeResponse?.content, ['routeID', 'routeId']) |
| | | ?? getFieldValue(routeResponse?.data, ['routeID', 'routeId']) |
| | | ?? getFieldValue(routeResponse, ['routeID', 'routeId']) |
| | | ?? '' |
| | | ); |
| | | const hasRouteIdChanged = ( |
| | | !!routeKey |
| | | && !!lastRouteIdRef?.current |
| | | && routeKey !== lastRouteIdRef.current |
| | | ); |
| | | |
| | | // 行程中修改目的地时,订单状态通常不变,因此需要额外通过路线终点变化补拉详情。 |
| | | // 只要最新路线终点和当前展示的终点 (endSite) 不一致,或者 routeID 变了,就应该持续去拉详情 |
| | | const hasRouteDestinationChanged = ( |
| | | (!!routeEndPoint && !!currentEndSitePoint && !isSameCoordinate(routeEndPoint, currentEndSitePoint)) |
| | | || hasRouteIdChanged |
| | | ); |
| | | |
| | | const shouldFetchInfo = ( |
| | | (routeStatus !== null && routeStatus !== infoStatusRef.current) |
| | | || hasRouteDestinationChanged |
| | |
| | | |
| | | if (mappedStatus === TripStatus.CancelOnlyPickup) { |
| | | applyCanceledTripState(nextStartSite, nextEndSite); |
| | | lastRouteIdRef.current = ''; |
| | | stopPolling(); |
| | | errorToastShownRef.current = false; |
| | | return false; |
| | | } |
| | | |
| | | syncShareRoute(routeResponse, mappedStatus, nextStartSite, nextEndSite); |
| | | if (routeKey) lastRouteIdRef.current = routeKey; |
| | | |
| | | if (mappedStatus >= TripStatus.ArrivedDestination) { |
| | | stopPolling(); |
| | | errorToastShownRef.current = false; |
| | |
| | | ); |
| | | if (cancelled) return; |
| | | syncShareRoute(routeResponse, infoState.mappedStatus, infoState.nextStartSite, infoState.nextEndSite); |
| | | |
| | | const routeKey = String( |
| | | getFieldValue(routeResponse?.content?.route, ['routeID', 'routeId']) |
| | | ?? getFieldValue(routeResponse?.content, ['routeID', 'routeId']) |
| | | ?? getFieldValue(routeResponse?.data, ['routeID', 'routeId']) |
| | | ?? getFieldValue(routeResponse, ['routeID', 'routeId']) |
| | | ?? '' |
| | | ); |
| | | if (routeKey) lastRouteIdRef.current = routeKey; |
| | | |
| | | stopPolling(); |
| | | errorToastShownRef.current = false; |
| | | return; |