| | |
| | | // 步行路径点 |
| | | const [walkingPoints, setWalkingPoints] = useState<any[]>([]); |
| | | const [walkingTime, setWalkingTime] = useState<number>(0); |
| | | const carMarkerInitialized = useRef(false); |
| | | const [fareEstimate, setFareEstimate] = useState<any>({}); // 预估费用信息 |
| | | const [vehicleLocation, setVehicleLocation] = useState<{ latitude: number, longitude: number } | null>(null); |
| | | const [vehicleDirection, setVehicleDirection] = useState<number | null>(null); |
| | |
| | | const [evaluateCloseVersion, setEvaluateCloseVersion] = useState(0); |
| | | const [originOpacity, setOriginOpacity] = useState(1); |
| | | |
| | | const markersRef = useRef<any[]>([]); |
| | | const tripStatusRef = useRef(tripStatus); // 行程状态引用 |
| | | const lastTripStatusRef = useRef(tripStatus); |
| | | const routeRequestKeyRef = useRef<string>(''); // 路线请求键 |
| | | const allowIncludePointsRef = useRef(true); // 是否允许包含地图点 |
| | | const orderRouteInitializedRef = useRef(false); |
| | | // 在发布行程状态也允许展示路线 |
| | | const shouldShowRoute = [1, 4, 6, 8, 9].includes(tripStatus); |
| | | const STATUS_RULES: Record<number, any> = { |
| | | 1: { showPickup: true, showDropoff: true, showCar: false, showRoute: true, showWalking: true, viewport: 'route_walking', translateCar: false }, |
| | | 2: { showPickup: true, showDropoff: false, showCar: false, showRoute: false, showWalking: false, viewport: 'pickup', translateCar: false }, |
| | | 3: { showPickup: true, showDropoff: false, showCar: false, showRoute: false, showWalking: false, viewport: 'pickup', translateCar: false }, |
| | | 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 }, |
| | | 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 }, |
| | | }; |
| | | const statusRule = useMemo(() => STATUS_RULES[tripStatus] || STATUS_RULES[1], [tripStatus]); |
| | | const shouldShowRoute = statusRule.showRoute; |
| | | const authSuccessBound = useRef(false); // 认证成功是否绑定 |
| | | const messageBound = useRef(false); // 消息是否绑定 |
| | | const orderStatusBound = useRef(false); // 订单状态是否绑定 |
| | |
| | | // 记录已为某订单拉取过车辆信息,避免重复 |
| | | const lastFetchedVehicleOrderIdRef = useRef<string | null>(null); |
| | | const mapRectRef = useRef<any>(null); |
| | | const viewportKeyRef = useRef<string>(''); |
| | | const tripStatus6ViewportLockedRef = useRef(false); |
| | | const polylineKeyRef = useRef<string>(''); |
| | | const lastRoutePointRef = useRef<{ latitude: number; longitude: number } | null>(null); |
| | | const lastRouteUpdateAtRef = useRef<number>(0); |
| | | const lastPolylineUpdateAtRef = useRef<number>(0); |
| | | const isAndroid = useMemo(() => { |
| | | try { |
| | | const info = Taro.getSystemInfoSync(); |
| | |
| | | const wasHold = [6].includes(lastTripStatusRef.current); |
| | | const isHold = [6].includes(tripStatus); |
| | | if (!wasHold && isHold) { |
| | | allowIncludePointsRef.current = true; |
| | | orderRouteInitializedRef.current = false; |
| | | tripStatus6ViewportLockedRef.current = false; |
| | | } |
| | | if (!isHold) { |
| | | tripStatus6ViewportLockedRef.current = false; |
| | | } |
| | | lastTripStatusRef.current = tripStatus; |
| | | }, [tripStatus]); |
| | | |
| | | useEffect(() => { |
| | | markersRef.current = markers; |
| | | }, [markers]); |
| | | |
| | | const checkAndShowPassengerNotice = () => { |
| | | const checkedTimeRaw = Taro.getStorageSync('passengerNoticeCheckedTime'); |
| | |
| | | // 应用路线点 |
| | | const applyRoutePoints = (points: any[]) => { |
| | | if (Array.isArray(points) && points.length > 0) { |
| | | const lastPoint = points[points.length - 1]; |
| | | const lastLatitude = Number(lastPoint?.latitude); |
| | | const lastLongitude = Number(lastPoint?.longitude); |
| | | const now = Date.now(); |
| | | const prev = lastRoutePointRef.current; |
| | | if (Number.isFinite(lastLatitude) && Number.isFinite(lastLongitude) && prev) { |
| | | const delta = Math.abs(prev.latitude - lastLatitude) + Math.abs(prev.longitude - lastLongitude); |
| | | const minDelta = isAndroid ? 0.00003 : 0.00002; |
| | | const minInterval = isAndroid ? 1200 : 800; |
| | | if (delta < minDelta && now - lastRouteUpdateAtRef.current < minInterval) { |
| | | return; |
| | | } |
| | | } |
| | | if (Number.isFinite(lastLatitude) && Number.isFinite(lastLongitude)) { |
| | | lastRoutePointRef.current = { latitude: lastLatitude, longitude: lastLongitude }; |
| | | lastRouteUpdateAtRef.current = now; |
| | | } else { |
| | | lastRoutePointRef.current = null; |
| | | lastRouteUpdateAtRef.current = 0; |
| | | } |
| | | setRoutePoints(points); |
| | | } else { |
| | | lastRoutePointRef.current = null; |
| | | lastRouteUpdateAtRef.current = 0; |
| | | setRoutePoints([]); |
| | | } |
| | | }; |
| | | |
| | | const reducePoints = (points: any[], maxCount: number) => { |
| | | if (!Array.isArray(points) || points.length <= maxCount) { |
| | | return points; |
| | | } |
| | | const step = Math.ceil(points.length / maxCount); |
| | | const reduced = []; |
| | | for (let i = 0; i < points.length; i += step) { |
| | | reduced.push(points[i]); |
| | | } |
| | | const last = points[points.length - 1]; |
| | | if (reduced[reduced.length - 1] !== last) { |
| | | reduced.push(last); |
| | | } |
| | | return reduced; |
| | | }; |
| | | |
| | | // 归一化距离(公里或米) |
| | |
| | | } |
| | | if (Array.isArray(points) && points.length > 0) { |
| | | applyRoutePoints(points); |
| | | if (tripStatusRef.current === 1) { |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | const allPoints = [...points, ...walkingPoints]; |
| | | if (allPoints.length > 0) { |
| | | mapCtx.includePoints({ |
| | | points: allPoints, |
| | | padding: [100, 100, 280, 100] |
| | | }); |
| | | } |
| | | } |
| | | } else { |
| | | applyRoutePoints([]); |
| | | } |
| | |
| | | if (mappedTripStatus === 5) { |
| | | setRoutePoints([]); |
| | | setPolyline([]); |
| | | polylineKeyRef.current = ''; |
| | | lastPolylineUpdateAtRef.current = 0; |
| | | lastRoutePointRef.current = null; |
| | | lastRouteUpdateAtRef.current = 0; |
| | | } |
| | | if (mappedTripStatus === 4) { |
| | | setRoutePoints([]); |
| | | setPolyline([]); |
| | | polylineKeyRef.current = ''; |
| | | lastPolylineUpdateAtRef.current = 0; |
| | | lastRoutePointRef.current = null; |
| | | lastRouteUpdateAtRef.current = 0; |
| | | } |
| | | if (payload?.showCancelPopup) { |
| | | handleOpenCancelPopupWithType(5); |
| | |
| | | }; |
| | | |
| | | orderRouteHandlerRef.current = (payload) => { |
| | | if (tripStatusRef.current === 5) { |
| | | return; |
| | | } |
| | | const points = payload?.points || []; |
| | | const direction = payload?.direction; |
| | | if (typeof direction === 'number' && Number.isFinite(direction)) { |
| | |
| | | // tripStatus=2/3:等待计时 |
| | | if (tripStatus == 2 || tripStatus == 3) { |
| | | const s = Taro.getStorageSync('startSite'); |
| | | if (s && s.latitude && s.longitude) { |
| | | const hasPlannedRoute = Array.isArray(routePoints) && routePoints.length > 0; |
| | | if (!hasPlannedRoute && s && s.latitude && s.longitude) { |
| | | setLatitude(s.latitude); |
| | | setLongitude(s.longitude); |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | mapCtx.moveToLocation({ |
| | | latitude: s.latitude, |
| | | longitude: s.longitude, |
| | | }); |
| | | } |
| | | |
| | | const cachedStartAt = Number(Taro.getStorageSync(WAITING_TIMER_START_KEY)); |
| | |
| | | timer = setInterval(() => { |
| | | updateElapsed(); |
| | | }, 1000); |
| | | } else if (tripStatus == 5) { |
| | | const s = Taro.getStorageSync('startSite'); |
| | | if (s && s.latitude && s.longitude) { |
| | | setLatitude(s.latitude); |
| | | setLongitude(s.longitude); |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | mapCtx.moveToLocation({ |
| | | latitude: s.latitude, |
| | | longitude: s.longitude, |
| | | }); |
| | | } |
| | | setElapsedSeconds(0); |
| | | Taro.removeStorageSync(WAITING_TIMER_START_KEY); |
| | | Taro.removeStorageSync(WAITING_TIMER_ELAPSED_KEY); |
| | | } else if (tripStatus == 7) { |
| | | const e = Taro.getStorageSync('endSite'); |
| | | if (e && e.latitude && e.longitude) { |
| | | setLatitude(e.latitude); |
| | | setLongitude(e.longitude); |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | mapCtx.includePoints({ |
| | | points: [{ |
| | | latitude: e.latitude, |
| | | longitude: e.longitude, |
| | | }], |
| | | padding: [100, 100, 280, 100] |
| | | }); |
| | | } |
| | | setElapsedSeconds(0); |
| | | Taro.removeStorageSync(WAITING_TIMER_START_KEY); |
| | |
| | | getOrderDetail(Taro.getStorageSync('orderId')).then((res: any) => { |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | if (res.trajectories) { |
| | | const points = res.trajectories.map((item: any) => ({ |
| | | latitude: item.location.split(',')[1], |
| | | longitude: item.location.split(',')[0], |
| | | })); |
| | | const s = Taro.getStorageSync('startSite'); |
| | | const e = Taro.getStorageSync('endSite'); |
| | | points.push({ |
| | | latitude: s.latitude, |
| | | longitude: s.longitude, |
| | | }) |
| | | points.push({ |
| | | latitude: e.latitude, |
| | | longitude: e.longitude, |
| | | }) |
| | | const points = res.trajectories |
| | | .map((item: any) => { |
| | | const [lonStr, latStr] = String(item.location || '').split(','); |
| | | const lon = Number(lonStr); |
| | | const lat = Number(latStr); |
| | | return { latitude: lat, longitude: lon }; |
| | | }) |
| | | .filter(p => Number.isFinite(p.latitude) && Number.isFinite(p.longitude)); |
| | | applyRoutePoints(points); |
| | | mapCtx.includePoints({ |
| | | points: points, |
| | | padding: [100, 100, 280, 100] |
| | | }) |
| | | } else { |
| | | mapCtx.moveToLocation({ |
| | | latitude: 39.916527, |
| | |
| | | } |
| | | }); |
| | | |
| | | // 在tripStatus=1时也绘制预估路线与步行路线 |
| | | // 构建并更新地图标记点(与路线解耦,避免路线更新导致标记刷新) |
| | | useEffect(() => { |
| | | const s = Taro.getStorageSync('startSite'); |
| | | const pickupMarker = s?.latitude && s?.longitude ? { |
| | | const pickupSite = startSite?.latitude && startSite?.longitude ? startSite : Taro.getStorageSync('startSite'); |
| | | const dropoffSite = endSite?.latitude && endSite?.longitude ? endSite : Taro.getStorageSync('endSite'); |
| | | const pickupMarker = pickupSite?.latitude && pickupSite?.longitude ? { |
| | | id: 1, |
| | | latitude: s.latitude, |
| | | longitude: s.longitude, |
| | | latitude: pickupSite.latitude, |
| | | longitude: pickupSite.longitude, |
| | | iconPath: 'https://huishou-1323682843.cos.ap-nanjing.myqcloud.com/images/51e7cb75-72af-4994-9d6e-d999efb2fbc7.png', |
| | | width: 22, |
| | | height: 40, |
| | | anchor: { x: 0.5, y: 1 }, |
| | | zIndex: 1, |
| | | name: s?.name || '上车点', |
| | | name: pickupSite?.name || '上车点', |
| | | customCallout: { |
| | | anchorY: [2, 3].includes(tripStatus) ? 150 : -5, |
| | | anchorX: 0, |
| | | display: 'ALWAYS' |
| | | } |
| | | } : null; |
| | | const dropoffMarker = endSite?.latitude && endSite?.longitude ? { |
| | | const dropoffMarker = dropoffSite?.latitude && dropoffSite?.longitude ? { |
| | | id: 2, |
| | | latitude: endSite.latitude, |
| | | longitude: endSite.longitude, |
| | | latitude: dropoffSite.latitude, |
| | | longitude: dropoffSite.longitude, |
| | | iconPath: 'https://huishou-1323682843.cos.ap-nanjing.myqcloud.com/images/6a56b1eb-ec37-4839-8733-262942af070d.png', |
| | | width: 22, |
| | | height: 40, |
| | | anchor: { x: 0.5, y: 1 }, |
| | | zIndex: 1, |
| | | name: endSite.name || '目的地', |
| | | name: dropoffSite.name || '目的地', |
| | | customCallout: { |
| | | anchorY: -5, |
| | | anchorX: 0, |
| | |
| | | customCallout: { anchorY: 50, anchorX: 0, display: 'ALWAYS' } |
| | | } : null; |
| | | |
| | | const includePickup = [1, 2, 3, 4, 5, 8, 9].includes(tripStatus); |
| | | const includeDropoff = [1, 6, 7, 8, 9].includes(tripStatus); |
| | | const includeCar = [4, 5, 6, 7].includes(tripStatus); |
| | | const nextMarkers: any[] = []; |
| | | if (includePickup && pickupMarker) nextMarkers.push(pickupMarker); |
| | | if (includeCar && carMarker) nextMarkers.push(carMarker); |
| | | if (includeDropoff && dropoffMarker) nextMarkers.push(dropoffMarker); |
| | | setMarkers(nextMarkers); |
| | | if (statusRule.showPickup && pickupMarker) nextMarkers.push(pickupMarker); |
| | | if (statusRule.showCar && carMarker) nextMarkers.push(carMarker); |
| | | if (statusRule.showDropoff && dropoffMarker) nextMarkers.push(dropoffMarker); |
| | | const hasDropoffMarker = markersRef.current.some((m: any) => m.id === 2); |
| | | const shouldSkipUpdate = tripStatus === 6 && carMarkerInitialized.current && statusRule.showCar && (!statusRule.showDropoff || hasDropoffMarker); |
| | | if (shouldSkipUpdate) { |
| | | } else { |
| | | setMarkers(nextMarkers); |
| | | } |
| | | carMarkerInitialized.current = statusRule.showCar && !!carMarker; |
| | | }, [tripStatus, startSite?.name, startSite?.latitude, startSite?.longitude, endSite.name, endSite?.latitude, endSite?.longitude, vehicleLocation, vehicleDirection]); |
| | | |
| | | if (shouldShowRoute && (routePoints.length > 0 || (tripStatus === 1 && walkingPoints.length > 0))) { |
| | | // 绘制路线与视野适配 |
| | | useEffect(() => { |
| | | const displayRoutePoints = reducePoints(routePoints, isAndroid ? 120 : 200); |
| | | const lastRoutePoint = displayRoutePoints[displayRoutePoints.length - 1]; |
| | | const lastWalkingPoint = walkingPoints[walkingPoints.length - 1]; |
| | | const isTripMoving = [4, 5, 6].includes(tripStatus); |
| | | const now = Date.now(); |
| | | const throttle = isAndroid ? 1200 : 800; |
| | | if (shouldShowRoute && isTripMoving && displayRoutePoints.length > 0 && now - lastPolylineUpdateAtRef.current < throttle) { |
| | | return; |
| | | } |
| | | const nextKey = [ |
| | | shouldShowRoute ? 1 : 0, |
| | | statusRule.showWalking ? 1 : 0, |
| | | displayRoutePoints.length, |
| | | walkingPoints.length, |
| | | lastRoutePoint?.latitude ?? '', |
| | | lastRoutePoint?.longitude ?? '', |
| | | lastWalkingPoint?.latitude ?? '', |
| | | lastWalkingPoint?.longitude ?? '', |
| | | ].join('|'); |
| | | if (nextKey === polylineKeyRef.current) { |
| | | return; |
| | | } |
| | | polylineKeyRef.current = nextKey; |
| | | if (shouldShowRoute && (displayRoutePoints.length > 0 || (statusRule.showWalking && walkingPoints.length > 0))) { |
| | | const lines: any[] = []; |
| | | if (routePoints.length > 0) { |
| | | if (displayRoutePoints.length > 0) { |
| | | lines.push({ |
| | | points: routePoints, |
| | | points: displayRoutePoints, |
| | | color: '#7B91FF', |
| | | width: 10, |
| | | dottedLine: false, |
| | | arrowLine: true, |
| | | }); |
| | | } |
| | | // 仅在发布行程阶段展示步行路线 |
| | | if (tripStatus === 1 && walkingPoints.length > 0) { |
| | | if (statusRule.showWalking && walkingPoints.length > 0) { |
| | | lines.push({ |
| | | points: walkingPoints, |
| | | color: '#7B91FF', |
| | |
| | | }); |
| | | } |
| | | setPolyline(lines); |
| | | if (![6].includes(tripStatus) || allowIncludePointsRef.current) { |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | if ([8, 9].includes(tripStatus) && routePoints.length > 0) { |
| | | mapCtx.includePoints({ |
| | | points: routePoints, |
| | | padding: [100, 100, 280, 100] |
| | | }); |
| | | } else { |
| | | const allPoints = tripStatus === 1 |
| | | ? [...routePoints, ...walkingPoints] |
| | | : [...routePoints]; |
| | | mapCtx.includePoints({ |
| | | points: allPoints, |
| | | padding: [100, 100, ![1, 6].includes(tripStatus) ? 280 : 100, 100] |
| | | }); |
| | | } |
| | | if ([6].includes(tripStatus)) { |
| | | allowIncludePointsRef.current = false; |
| | | } |
| | | } |
| | | lastPolylineUpdateAtRef.current = now; |
| | | } else { |
| | | setPolyline([]); |
| | | lastPolylineUpdateAtRef.current = 0; |
| | | } |
| | | }, [tripStatus, shouldShowRoute, routePoints, walkingPoints, startSite?.name, startSite?.latitude, startSite?.longitude, endSite.name, endSite?.latitude, endSite?.longitude, vehicleLocation, vehicleDirection, routeDistance?.value, routeDistance?.unit, routeDuration]); |
| | | }, [tripStatus, shouldShowRoute, routePoints, walkingPoints, statusRule.showWalking, isAndroid]); |
| | | |
| | | useEffect(() => { |
| | | const pickupSite = startSite?.latitude && startSite?.longitude ? startSite : Taro.getStorageSync('startSite'); |
| | | const dropoffSite = endSite?.latitude && endSite?.longitude ? endSite : Taro.getStorageSync('endSite'); |
| | | const viewportType = statusRule.viewport; |
| | | const points: any[] = []; |
| | | const keyParts: any[] = [tripStatus, viewportType]; |
| | | |
| | | if (viewportType === 'route_walking') { |
| | | if (routePoints.length > 0) { |
| | | points.push(...routePoints); |
| | | } |
| | | if (walkingPoints.length > 0) { |
| | | points.push(...walkingPoints); |
| | | } |
| | | keyParts.push(routePoints.length, walkingPoints.length); |
| | | } else if (viewportType === 'pickup') { |
| | | if (pickupSite?.latitude && pickupSite?.longitude) { |
| | | points.push({ latitude: pickupSite.latitude, longitude: pickupSite.longitude }); |
| | | } |
| | | keyParts.push(pickupSite?.latitude, pickupSite?.longitude); |
| | | } else if (viewportType === 'route') { |
| | | if (routePoints.length > 0) { |
| | | points.push(...routePoints); |
| | | } |
| | | keyParts.push(routePoints.length); |
| | | } else if (viewportType === 'car_user') { |
| | | if (Number.isFinite(latitude) && Number.isFinite(longitude)) { |
| | | points.push({ latitude, longitude }); |
| | | } |
| | | if (vehicleLocation?.latitude && vehicleLocation?.longitude) { |
| | | points.push({ latitude: vehicleLocation.latitude, longitude: vehicleLocation.longitude }); |
| | | } |
| | | keyParts.push(latitude, longitude, vehicleLocation?.latitude, vehicleLocation?.longitude); |
| | | } else if (viewportType === 'dropoff') { |
| | | if (dropoffSite?.latitude && dropoffSite?.longitude) { |
| | | points.push({ latitude: dropoffSite.latitude, longitude: dropoffSite.longitude }); |
| | | } |
| | | keyParts.push(dropoffSite?.latitude, dropoffSite?.longitude); |
| | | } else if (viewportType === 'order_detail') { |
| | | if (routePoints.length > 0) { |
| | | points.push(...routePoints); |
| | | } |
| | | if (pickupSite?.latitude && pickupSite?.longitude) { |
| | | points.push({ latitude: pickupSite.latitude, longitude: pickupSite.longitude }); |
| | | } |
| | | if (dropoffSite?.latitude && dropoffSite?.longitude) { |
| | | points.push({ latitude: dropoffSite.latitude, longitude: dropoffSite.longitude }); |
| | | } |
| | | keyParts.push(routePoints.length, pickupSite?.latitude, pickupSite?.longitude, dropoffSite?.latitude, dropoffSite?.longitude); |
| | | } |
| | | |
| | | if (points.length === 0) return; |
| | | if (tripStatus === 6 && viewportType === 'route' && tripStatus6ViewportLockedRef.current) { |
| | | return; |
| | | } |
| | | const nextKey = keyParts.join('|'); |
| | | if (nextKey === viewportKeyRef.current) return; |
| | | viewportKeyRef.current = nextKey; |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | const padding = viewportType === 'order_detail' ? [50, 50, 200, 50] : [100, 100, 280, 100]; |
| | | Taro.nextTick(() => { |
| | | mapCtx.includePoints({ |
| | | points, |
| | | padding |
| | | }); |
| | | }); |
| | | if (tripStatus === 6 && viewportType === 'route') { |
| | | tripStatus6ViewportLockedRef.current = true; |
| | | } |
| | | }, [tripStatus, statusRule, routePoints, walkingPoints, startSite?.latitude, startSite?.longitude, endSite?.latitude, endSite?.longitude, vehicleLocation, longitude, latitude]); |
| | | |
| | | useEffect(() => { |
| | | if (!statusRule.translateCar) return; |
| | | if (!carMarkerInitialized.current) return; |
| | | if (!vehicleLocation) return; |
| | | const mapCtx = Taro.createMapContext('map'); |
| | | Taro.nextTick(() => { |
| | | mapCtx.translateMarker({ |
| | | markerId: 3, |
| | | destination: { |
| | | latitude: vehicleLocation.latitude, |
| | | longitude: vehicleLocation.longitude, |
| | | }, |
| | | autoRotate: false, |
| | | rotate: typeof vehicleDirection === 'number' ? vehicleDirection : 0, |
| | | duration: 500, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | |
| | | }, |
| | | }); |
| | | }); |
| | | }, [tripStatus, vehicleLocation, vehicleDirection]); |
| | | |
| | | const bindSocketListeners = () => { |
| | | if (!orderStatusBound.current && orderStatusHandlerRef.current) { |
| | |
| | | updateWalkingRouteForStart(); |
| | | } |
| | | |
| | | if (cachedOrderId) { |
| | | ensureSocketListeners(); |
| | | } |
| | | ensureSocketListeners(); |
| | | }); |
| | | |
| | | useEffect(() => { |
| | |
| | | estimatedTime: estimatedTime, |
| | | }; |
| | | try { |
| | | const { orderId } = await saveOrder(payload); |
| | | Taro.setStorageSync('orderId', orderId); |
| | | const res = await saveOrder(payload); |
| | | if (typeof res == 'string') { |
| | | Taro.showToast({ |
| | | title: res, |
| | | icon: 'none', |
| | | mask: true, |
| | | }) |
| | | setTimeout(() => { |
| | | Taro.reLaunch({ |
| | | url: '/robotaxi/pages/begin-route/index', |
| | | }) |
| | | }, 1500); |
| | | return |
| | | } |
| | | Taro.setStorageSync('orderId', res?.orderId || ''); |
| | | } catch (error) { |
| | | return |
| | | } |
| | |
| | | <CoverView slot="callout" marker-id={item.id} key={`${tripStatus}-${item.id}`} className="custom-callout"> |
| | | { |
| | | (!['车辆位置', '已到达'].includes(item.name)) && |
| | | <CoverView className="custom-callout-content"> |
| | | {item.name} |
| | | <CoverView className={`custom-callout-content`}> |
| | | {item.name}<CoverView style={{ width: '2px' }}></CoverView> |
| | | { |
| | | tripStatus == 1 && <CoverImage className="custom-callout-icon" src={customCalloutIconSrc} /> |
| | | } |
| | |
| | | <CoverView className="car-time"> |
| | | <CoverView className="car-time-num">{routeDistance?.value ?? 0}</CoverView> |
| | | <CoverView>{routeDistance?.unit === 'm' ? '米' : '公里'}</CoverView> |
| | | <CoverView style={{ marginLeft: '4px' }} className="car-time-num">{durationDisplay.value}</CoverView> |
| | | <CoverView style={{ marginLeft: '2.5px' }} className="car-time-num">{durationDisplay.value}</CoverView> |
| | | <CoverView>{durationDisplay.unit}</CoverView> |
| | | </CoverView> |
| | | </CoverView> |