| | |
| | | }; |
| | | // 优化订单状态回调中的车辆信息拉取逻辑 |
| | | orderStatusHandlerRef.current = (payload) => { |
| | | const changeStatusOld = tripStatus |
| | | const changeStatusOld = tripStatusRef.current; |
| | | const mappedTripStatus = payload?.tripStatus; |
| | | if (typeof mappedTripStatus === 'number') { |
| | | const currentLocalStatus = Number(Taro.getStorageSync('tripStatus')); |
| | |
| | | return; |
| | | } |
| | | setTripStatus(mappedTripStatus); |
| | | tripStatusRef.current = mappedTripStatus; // 同步更新ref,防止后续路由推送拿不到最新状态 |
| | | Taro.setStorageSync('tripStatus', mappedTripStatus); |
| | | } |
| | | // 车辆信息拉取:当收到有效的订单号时,在首次达到呼叫及后续阶段拉取车辆信息 |
| | |
| | | if (mappedTripStatus === 6) { |
| | | setShowAnnouncementsPopup(false); |
| | | } |
| | | if (mappedTripStatus === 5) { |
| | | if (mappedTripStatus === 5 && changeStatusOld !== 5) { |
| | | setRoutePoints([]); |
| | | setPolyline([]); |
| | | polylineKeyRef.current = ''; |
| | |
| | | lastVehicleUpdateAtRef.current = 0; |
| | | currentFullRouteRef.current = []; |
| | | lastErasedIndexRef.current = 0; |
| | | orderRouteInitializedRef.current = false; |
| | | } |
| | | if (mappedTripStatus === 4) { |
| | | if (mappedTripStatus === 4 && changeStatusOld !== 4) { |
| | | setRoutePoints([]); |
| | | setPolyline([]); |
| | | polylineKeyRef.current = ''; |
| | |
| | | lastVehicleUpdateAtRef.current = 0; |
| | | currentFullRouteRef.current = []; |
| | | lastErasedIndexRef.current = 0; |
| | | orderRouteInitializedRef.current = false; |
| | | } |
| | | |
| | | if (payload?.showCancelPopup) { |
| | | if (changeStatusOld == 4 || changeStatusOld == 5) { |
| | | setOrderId(''); |
| | |
| | | useEffect(() => { |
| | | const pickupSite = startSite?.latitude && startSite?.longitude ? startSite : Taro.getStorageSync('startSite'); |
| | | const dropoffSite = endSite?.latitude && endSite?.longitude ? endSite : Taro.getStorageSync('endSite'); |
| | | const useAndroidNativeTrip1Callout = isAndroid && [1, 8, 9].includes(tripStatus); |
| | | const useAndroidNativeTrip1Callout = isAndroid && [1, 8, 9, 10].includes(tripStatus); |
| | | const pickupMarker = pickupSite?.latitude && pickupSite?.longitude ? { |
| | | id: 1, |
| | | latitude: pickupSite.latitude, |