hejianhao
2026-03-27 2c7f82b6b7aecfb25df9cdd76f5fd7ab4722e58a
fix: 移除车辆位置监听并修复多个页面显示问题

- 移除 WebSocket 中的 VEHICLE_LOCATION 事件处理,不再监听车辆位置更新
- 修复站点搜索页面无数据时显示逻辑,仅在无搜索值时隐藏附近站点
- 调整订单页面“再来一单”按钮布局,使用绝对定位避免布局错乱
- 乘车需知弹窗中允许显示滚动条以提升用户体验
- 优化行程结束倒计时逻辑,确保有缓存或接口数据时始终展示
- 修复行程详情获取条件,仅当行程状态为8或9时请求轨迹数据
- 调整目的地标注显示条件,在行程状态6时也显示原生标注
- 清理 begin-route 页面中与车辆位置相关的引用和绑定逻辑
7个文件已修改
103 ■■■■■ 已修改文件
src/robotaxi/pages/begin-route/components/calling-car.tsx 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/components/passenger-notice.tsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/index.tsx 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/order/index.less 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/order/index.tsx 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/index.tsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/websocket.ts 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/components/calling-car.tsx
@@ -257,15 +257,8 @@
        } else if (tripStatus === 7) {
            const cachedEndTime = Taro.getStorageSync(FINISH_END_TIME_KEY);
            const hasValidCached = typeof cachedEndTime === 'number' && cachedEndTime > Date.now();
            if (!finishCountdownEnabled && !hasValidCached) {
                if (finishCountdownTimerRef.current) {
                    clearTimeout(finishCountdownTimerRef.current);
                }
                finishEndTimeRef.current = null;
                setFinishCountdownSeconds(null);
                Taro.removeStorageSync(FINISH_END_TIME_KEY);
                return;
            }
            // 无论 finishCountdownEnabled 是否为 true,只要有缓存或者接口返回数据就应该展示倒计时
            const initFinishCountdown = (endTimeMs: number | null) => {
                finishEndTimeRef.current = endTimeMs;
                if (typeof endTimeMs === 'number' && endTimeMs > Date.now()) {
src/robotaxi/pages/begin-route/components/passenger-notice.tsx
@@ -62,7 +62,7 @@
            <View className='passenger-mask' catchMove></View>
            <View className='passenger-content' animation={animationData}>
                <View className='passenger-content-title'>乘车需知</View>
                <ScrollView className='passenger-content-desc' scrollY enhanced lowerThreshold={30} upperThreshold={30} showScrollbar={false}>
                <ScrollView className='passenger-content-desc' scrollY enhanced lowerThreshold={30} upperThreshold={30} showScrollbar={true}>
                    <RichText nodes={noticeContent} />
                </ScrollView>
                <View onClick={() => setChecked(!checked)} className='passenger-content-checkbox'>
src/robotaxi/pages/begin-route/index.tsx
@@ -136,14 +136,12 @@
  const messageBound = useRef(false); // 消息是否绑定
  const orderStatusBound = useRef(false); // 订单状态是否绑定
  const orderRouteBound = useRef(false); // 订单路线是否绑定
  const vehicleLocationBound = useRef(false); // 车辆位置是否绑定
  const openTrunkBound = useRef(false); // 打开后备箱事件是否绑定
  const orderUpdatePriceBound = useRef(false); // 订单价格更新事件是否绑定
  const authSuccessHandlerRef = useRef<(data: any) => void>(); // 认证成功处理函数
  const messageHandlerRef = useRef<(data: any) => void>(); // 消息处理函数
  const orderStatusHandlerRef = useRef<(data: any) => void>(); // 订单状态处理函数
  const orderRouteHandlerRef = useRef<(data: any) => void>(); // 订单路线处理函数
  const vehicleLocationHandlerRef = useRef<(data: any) => void>(); // 车辆位置处理函数
  const openTrunkHandlerRef = useRef<(data: any) => void>(); // 打开后备箱事件处理函数
  const orderUpdatePriceHandlerRef = useRef<(data: any) => void>(); // 订单价格更新事件处理函数
  const socketOpenHandlerRef = useRef<(() => void) | null>(null); // WebSocket连接打开处理函数
@@ -954,18 +952,8 @@
          }
        }
      });
    };
    };
    // 仅在呼叫及后续阶段允许更新车辆位置
    vehicleLocationHandlerRef.current = (payload) => {
      const latitude = payload?.latitude;
      const longitude = payload?.longitude;
      if (typeof latitude === 'number' && typeof longitude === 'number') {
        if ([4, 5, 6, 7].includes(tripStatusRef.current)) {
          updateVehicleLocationThrottled(latitude, longitude);
        }
      }
    };
    return () => {
      if (authSuccessBound.current && authSuccessHandlerRef.current) {
        wsManager.off('auth_success', authSuccessHandlerRef.current);
@@ -982,10 +970,6 @@
      if (orderRouteBound.current && orderRouteHandlerRef.current) {
        wsManager.off('order_route', orderRouteHandlerRef.current);
        orderRouteBound.current = false;
      }
      if (vehicleLocationBound.current && vehicleLocationHandlerRef.current) {
        wsManager.off('vehicle_location', vehicleLocationHandlerRef.current);
        vehicleLocationBound.current = false;
      }
      if (openTrunkBound.current && openTrunkHandlerRef.current) {
        wsManager.off('open_trunk', openTrunkHandlerRef.current);
@@ -1079,7 +1063,7 @@
        const requestTripStatus = tripStatus;
        getOrderDetail(Taro.getStorageSync('orderId')).then((res: any) => {
          if (currentRequestId !== orderDetailRouteRequestIdRef.current) return;
          if (tripStatusRef.current !== requestTripStatus) return;
          if (![8, 9].includes(tripStatusRef.current)) return;
          const mapCtx = Taro.createMapContext('map');
          if (res.trajectories) {
            const points = res.trajectories
@@ -1178,7 +1162,7 @@
      anchor: { x: 0.5, y: 1 },
      zIndex: 1,
      name: [7].includes(tripStatus) ? '已到达' : (dropoffSite.name || '目的地'),
      ...(useAndroidNativeTrip1Callout
      ...(useAndroidNativeTrip1Callout || tripStatus == 6
        ? {
          callout: {
            content: tripStatus === 1 ? `${[7].includes(tripStatus) ? '已到达' : (dropoffSite.name || '目的地')} >` : ([7].includes(tripStatus) ? '已到达' : (dropoffSite.name || '目的地')),
@@ -1409,10 +1393,6 @@
    if (!orderRouteBound.current && orderRouteHandlerRef.current) {
      wsManager.on('order_route', orderRouteHandlerRef.current);
      orderRouteBound.current = true;
    }
    if (!vehicleLocationBound.current && vehicleLocationHandlerRef.current) {
      wsManager.on('vehicle_location', vehicleLocationHandlerRef.current);
      vehicleLocationBound.current = true;
    }
    if (!openTrunkBound.current && openTrunkHandlerRef.current) {
      wsManager.on('open_trunk', openTrunkHandlerRef.current);
@@ -1759,10 +1739,6 @@
    if (!orderRouteBound.current && orderRouteHandlerRef.current) {
      wsManager.on('order_route', orderRouteHandlerRef.current);
      orderRouteBound.current = true;
    }
    if (!vehicleLocationBound.current && vehicleLocationHandlerRef.current) {
      wsManager.on('vehicle_location', vehicleLocationHandlerRef.current);
      vehicleLocationBound.current = true;
    }
    if (!orderUpdatePriceBound.current && orderUpdatePriceHandlerRef.current) {
      wsManager.on('order_update_price', orderUpdatePriceHandlerRef.current);
src/robotaxi/pages/order/index.less
@@ -10,6 +10,7 @@
    background: #FFFFFF;
    margin-bottom: 24px;
    padding: 28px 40px 24px 32px;
    position: relative;
    .order-item-top {
      margin-bottom: 32px;
@@ -54,30 +55,42 @@
      color: rgba(0, 0, 0, 0.6);
    }
    .order-again-box-position {
      position: absolute;
      padding: 10px;
      bottom: 14px;
      right: 30px;
    }
    .order-again-box {
      margin-top: 4px;
      display: flex;
      justify-content: flex-end;
      .order-again-text {
      .order-again-text-container {
        width: 144px;
        z-index: 0;
        border-radius: 3112px;
        box-sizing: border-box;
        /* 按钮色/面性线性按钮 */
        border: 2px solid #181916;
        /* 辅助文字/辅助文字 常规 12 */
        font-family: PingFang SC;
        font-size: 24px;
        font-weight: normal;
        line-height: 48px;
        text-align: center;
        letter-spacing: normal;
        /* 按钮色/面性线性按钮 */
        color: #181916;
        height: 48px;
      }
    }
    .order-again-text {
      width: 144px;
      z-index: 0;
      border-radius: 3112px;
      box-sizing: border-box;
      /* 按钮色/面性线性按钮 */
      border: 2px solid #181916;
      /* 辅助文字/辅助文字 常规 12 */
      font-family: PingFang SC;
      font-size: 24px;
      font-weight: normal;
      line-height: 48px;
      text-align: center;
      letter-spacing: normal;
      /* 按钮色/面性线性按钮 */
      color: #181916;
    }
  }
}
src/robotaxi/pages/order/index.tsx
@@ -119,7 +119,13 @@
              {
                formatOrderStatus(item.status) != '进行中' &&
                <View className='order-again-box'>
                  <View onClick={(e) => { e.stopPropagation(); againOrder(item) }} className='order-again-text'>再来一单</View>
                  <View className='order-again-text-container'></View>
                </View>
              }
              {
                formatOrderStatus(item.status) != '进行中' &&
                <View className='order-again-box-position' onClick={(e) => { e.stopPropagation(); againOrder(item) }}>
                  <View className='order-again-text'>再来一单</View>
                </View>
              }
            </View>
src/robotaxi/pages/site-search/index.tsx
@@ -459,7 +459,7 @@
        </View>
      }
      {
        (!siteList.length && !nearbySiteList.length && !nonOperationalSite.length && (!searchValue ? !historySite.length : true)) &&
        (!siteList.length && (!searchValue ? !nearbySiteList.length : true) && !nonOperationalSite.length && (!searchValue ? !historySite.length : true)) &&
        <View className='no-data-box'>
          <Image className='no-data-image' src={require('../../assets/no-data-site.png')} />
          <View>暂无站点</View>
src/utils/websocket.ts
@@ -325,13 +325,6 @@
        this.notifyListeners('order_status', { status, ...mapped, data, content });
      }
    }
    if (data?.type === 'VEHICLE_LOCATION') {
      const longitude = content?.lon;
      const latitude = content?.lat;
      if (typeof longitude === 'number' && typeof latitude === 'number') {
        this.notifyListeners('vehicle_location', { longitude, latitude, data, content });
      }
    }
    if (data?.type === 'ORDER_ROUTE') {
      const routeType = content?.routeType;
      const direction = Number(content?.direction);