| | |
| | | 4: { showPickup: true, showDropoff: false, showCar: true, showRoute: true, showWalking: false, viewport: 'route', translateCar: true }, |
| | | 5: { showPickup: true, showDropoff: false, showCar: true, showRoute: false, showWalking: false, viewport: 'car_user', translateCar: true }, |
| | | 6: { showPickup: false, showDropoff: true, showCar: true, showRoute: true, showWalking: false, viewport: 'route', translateCar: true }, |
| | | 7: { showPickup: false, showDropoff: true, showCar: false, showRoute: false, showWalking: false, viewport: 'dropoff', translateCar: false }, |
| | | 7: { showPickup: false, showDropoff: true, showCar: true, showRoute: false, showWalking: false, viewport: 'dropoff', translateCar: false }, |
| | | 8: { showPickup: true, showDropoff: true, showCar: false, showRoute: true, showWalking: false, viewport: 'order_detail', translateCar: false }, |
| | | 9: { showPickup: true, showDropoff: true, showCar: false, showRoute: true, showWalking: false, viewport: 'order_detail', translateCar: false }, |
| | | 10: { showPickup: true, showDropoff: false, showCar: false, showRoute: false, showWalking: false, viewport: 'pickup', translateCar: false }, |
| | |
| | | useEffect(() => { |
| | | const wasHold = [4, 6].includes(lastTripStatusRef.current); |
| | | const isHold = [4, 6].includes(tripStatus); |
| | | if (tripStatus == 6) { |
| | | if ([6, 7].includes(tripStatus)) { |
| | | setShowLocationFlag(false); |
| | | } else { |
| | | setShowLocationFlag(true); |
| | |
| | | if (dist > bestDistance * 3 && bestDistance < 100) break; |
| | | } |
| | | |
| | | if (bestMatchIndex > startIndex && bestDistance < 500) { |
| | | if (bestMatchIndex >= startIndex && bestDistance < 500) { |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | |
| | | const eraseIndex = Math.max(0, bestMatchIndex - 1); |
| | |
| | | }); |
| | | |
| | | lastErasedIndexRef.current = bestMatchIndex; |
| | | } else if (bestMatchIndex === startIndex && bestDistance < 500) { |
| | | // 新路线起点与旧路线起点一致,无需擦除 |
| | | } else { |
| | | // 路线发生较大变化,回退为全量重绘 |
| | | currentFullRouteRef.current = [...newPoints]; |
| | |
| | | // 认证成功处理函数 |
| | | useEffect(() => { |
| | | authSuccessHandlerRef.current = () => { |
| | | setTripStatus(2); |
| | | if (!messageBound.current && messageHandlerRef.current) { |
| | | wsManager.on('message', messageHandlerRef.current); |
| | | messageBound.current = true; |
| | |
| | | // 优化订单状态回调中的车辆信息拉取逻辑 |
| | | orderStatusHandlerRef.current = (payload) => { |
| | | const changeStatusOld = tripStatusRef.current; |
| | | const incomingOrderId = payload?.content?.orderId || payload?.orderId; |
| | | const currentOrderId = orderId || Taro.getStorageSync('orderId'); |
| | | if (incomingOrderId && currentOrderId && String(incomingOrderId) !== String(currentOrderId)) { |
| | | return; |
| | | } |
| | | const mappedTripStatus = payload?.tripStatus; |
| | | if (typeof mappedTripStatus === 'number') { |
| | | const currentLocalStatus = Number(Taro.getStorageSync('tripStatus')); |
| | |
| | | Taro.setStorageSync('tripStatus', mappedTripStatus); |
| | | } |
| | | // 车辆信息拉取:当收到有效的订单号时,在首次达到呼叫及后续阶段拉取车辆信息 |
| | | const incomingOrderId = payload?.content?.orderId || Taro.getStorageSync('orderId'); |
| | | const effectiveOrderId = incomingOrderId || currentOrderId || Taro.getStorageSync('orderId'); |
| | | const vehicleInfoEmpty = |
| | | !vehicleInfo || |
| | | (!vehicleInfo.plateNumber && !vehicleInfo.vehicleCode && !vehicleInfo.vehicleColor && !vehicleInfo.vehiclePictures); |
| | | const shouldFetchVehicle = |
| | | !!incomingOrderId && |
| | | (lastFetchedVehicleOrderIdRef.current !== incomingOrderId) && |
| | | (vehicleInfoEmpty || orderId !== incomingOrderId); |
| | | if (incomingOrderId && orderId !== incomingOrderId) { |
| | | setOrderId(incomingOrderId); |
| | | !!effectiveOrderId && |
| | | (lastFetchedVehicleOrderIdRef.current !== effectiveOrderId) && |
| | | (vehicleInfoEmpty || orderId !== effectiveOrderId); |
| | | if (effectiveOrderId && orderId !== effectiveOrderId) { |
| | | setOrderId(effectiveOrderId); |
| | | } |
| | | if (shouldFetchVehicle) { |
| | | lastFetchedVehicleOrderIdRef.current = incomingOrderId; |
| | | queryVehicleByOrderId({ orderId: incomingOrderId }) |
| | | lastFetchedVehicleOrderIdRef.current = effectiveOrderId; |
| | | queryVehicleByOrderId({ orderId: effectiveOrderId }) |
| | | .then((res: any) => { |
| | | setVehicleInfo(res); |
| | | }) |
| | |
| | | setPolyline(lines); |
| | | lastPolylineUpdateAtRef.current = now; |
| | | } else { |
| | | setPolyline([]); |
| | | if (![8, 9].includes(tripStatus)) { |
| | | setPolyline([]); |
| | | } |
| | | lastPolylineUpdateAtRef.current = 0; |
| | | } |
| | | }, [tripStatus, shouldShowRoute, routePoints, walkingPoints, statusRule.showWalking, isAndroid]); |