zjk
2026-05-19 52f3e492bfe3bd499a06c35b8fa30b1cf46395b2
fix(share-trip): 添加登录校验,修复行程显示逻辑并清理代码

- 为分享行程页面添加登录认证检查,仅在认证通过后渲染页面和执行业务逻辑
- 调整上下车点名称的匹配优先级,新增startPointName和endPointName字段
- 修复到达目的地的状态显示判断条件,将大于判断改为大于等于
- 清理未使用的导入语句,修复图片标签的格式问题
3个文件已修改
35 ■■■■■ 已修改文件
src/robotaxi/pages/share-trip/components/share-trip-view.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/share-trip/hooks/use-share-trip-runtime.ts 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/share-trip/index.tsx 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/share-trip/components/share-trip-view.tsx
@@ -1,4 +1,4 @@
import { View, Image, Map, CoverView, CoverImage } from '@tarojs/components';
import { View, Image, Map } from '@tarojs/components';
import { formatDurationDisplay, safeParse } from '../../../../utils/Robotaxi-public-method';
import { TripStatus } from '../../begin-route/constants/trip-status';
import homeIcon from '../../../assets/back-home.png';
@@ -45,7 +45,7 @@
    return (
      <View className='share-trip-expired'>
        <View className='expired-content'>
          <Image className='expired-img' src={'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/share-contact.png'}  />
          <Image className='expired-img' src='https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/share-contact.png'  />
          <View className='expired-text'>行程结束已超过24小时</View>
          <View className='expired-sub-text'>查看行程信息,请联系客服</View>
          <View className='expired-btn' onClick={handleContactService}>
@@ -114,7 +114,7 @@
                      乘客已上车,正在前往目的地
                    </View>
                  )}
                  {tripData?.tripStatus > TripStatus.ArrivedDestination && (
                  {tripData?.tripStatus >= TripStatus.ArrivedDestination && (
                    <View className='calling-car-head-title'>已到达目的地</View>
                  )}
                </View>
src/robotaxi/pages/share-trip/hooks/use-share-trip-runtime.ts
@@ -10,6 +10,7 @@
type RouteDistance = { value: number; unit: 'km' | 'm' } | null;
type Deps = {
  authReady: boolean;
  orderId: string;
  tripStatus: TripStatus;
  startSite: any;
@@ -135,7 +136,9 @@
      longitude: longitudeNum,
      name: getFieldValue(
        source,
        isStart ? ['startName', 'startSiteName', 'upName', 'originName'] : ['endName', 'endSiteName', 'downName', 'destinationName'],
        isStart
          ? ['startPointName', 'startName', 'startSiteName', 'upName', 'originName']
          : ['endPointName', 'endName', 'endSiteName', 'downName', 'destinationName'],
      ) || (isStart ? '上车点' : '终点'),
      address: getFieldValue(
        source,
@@ -309,6 +312,9 @@
  }, [deps.applyRoutePoints, deps.updateVehicleLocationThrottled, deps.setVehicleDirection]);
  useEffect(() => {
    if (!deps.authReady) {
      return;
    }
    if (!deps.orderId) {
      Taro.showToast({ title: '分享订单不存在', icon: 'none' });
      return;
@@ -451,5 +457,5 @@
      cancelled = true;
      stopPolling();
    };
  }, [deps.orderId]);
  }, [deps.authReady, deps.orderId]);
}
src/robotaxi/pages/share-trip/index.tsx
@@ -1,4 +1,4 @@
import Taro, { useRouter } from '@tarojs/taro';
import Taro, { useDidShow, useRouter } from '@tarojs/taro';
import { useEffect, useMemo, useState } from 'react';
import './index.less';
import useMapMarkers from './hooks/use-map-markers';
@@ -9,8 +9,8 @@
import useShareTripRuntime from './hooks/use-share-trip-runtime';
import ShareTripView from './components/share-trip-view';
import { TripStatus } from '../begin-route/constants/trip-status';
import { ORDER_SUCCESS_SUBSCRIBE_CONFIG } from '../../constants/subscribe';
import { runSubscribeScene, subscribeAfterOrderSuccess } from '../../../utils/subscribe';
import { subscribeAfterOrderSuccess } from '../../../utils/subscribe';
import { checkOtp } from '../../../utils/tools';
type StatusRule = {
  showPickup: boolean;
@@ -33,6 +33,14 @@
  const [isExpired, setIsExpired] = useState(false); // 是否超 24h 过期
  const [showReminder, setShowReminder] = useState(true); // 是否展示提醒
  const [tripStatus, setTripStatus] = useState<TripStatus>(TripStatus.PublishRoute); // 当前行程状态
  const [authReady, setAuthReady] = useState(false); // 登录校验通过后才允许加载分享页
  useDidShow(() => {
    // 分享页需要先登录,登录成功后小程序会返回当前页并再次触发校验
    void checkOtp(true).then((otp) => {
      setAuthReady(Boolean(otp));
    });
  });
  const STATUS_RULES: Record<TripStatus, StatusRule> = {
    [TripStatus.PublishRoute]: { showPickup: true, showDropoff: true, showCar: false, showRoute: true, showWalking: true, viewport: 'route_walking', translateCar: false },
@@ -111,6 +119,7 @@
  }); // 视口状态容器
  useShareTripRuntime({
    authReady,
    orderId,
    tripStatus,
    startSite,
@@ -179,6 +188,10 @@
    setShowReminder(false);
  }; // 开启提醒订阅
  if (!authReady) {
    return null;
  }
  return (
    <ShareTripView
      isExpired={isExpired}