hejianhao
2026-05-14 c20d6c6abca4ea353df5526bc304a9b9d5fbe919
feat(robotaxi): 添加站点搜索页预填搜索功能并修复显示问题

在跳转至站点搜索页时传递初始搜索关键字,页面会自动填充并执行搜索。修改目的地流程中会传递当前终点名称作为搜索关键字。修复修改目的地确认页的优惠金额仅在大于0时显示的问题,同时优化部分代码的空格格式。
4个文件已修改
33 ■■■■■ 已修改文件
src/robotaxi/pages/begin-route/components/modify-destination-review.tsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/hooks/use-modify-destination-flow.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/hooks/use-page-actions.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/index.tsx 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/components/modify-destination-review.tsx
@@ -40,7 +40,7 @@
  const [boxHeightPx, setBoxHeightPx] = useState<number | null>(null); // 容器高度(px)
  const selectedRoute = routeOptions?.[selectedRouteIndex]; // 当前选中的改终点路线
  const isOperateFree = Number(selectedRoute?.operateFree) === 1; // 当前路线是否为载客测试免费
  const isDragging = useRef(false);
  const startY = useRef(0);
  const startHeight = useRef(0);
@@ -162,9 +162,9 @@
  return (
    <View className="modify-destination-review-container">
      <View
        className='modify-destination-review'
        style={{
      <View
        className='modify-destination-review'
        style={{
          height: typeof boxHeightPx === 'number' ? `${boxHeightPx}px` : 'auto',
          transition: isDragging.current ? 'none' : 'height 0.3s ease'
        }}
@@ -226,7 +226,7 @@
                    元
                  </View>
                )}
                {isOperateFree ? null :
                {isOperateFree ? null : fareEstimate.discountAmount > 0 &&
                  <View className='modify-destination-review-fare-discount'>
                    已优惠{fareEstimate.discountAmount}元
                  </View>
src/robotaxi/pages/begin-route/hooks/use-modify-destination-flow.ts
@@ -15,7 +15,7 @@
  orderId: string;
  endSite: any;
  setEndSite: (site: any) => void;
  toSelectSite: (pageType: 'start' | 'end') => void;
  toSelectSite: (pageType: 'start' | 'end', keyword?: string) => void;
  onModifySuccess?: () => void;
};
@@ -145,6 +145,7 @@
  ]);
  const handleStartModifyDestination = (fareEstimate?: any, routePoints?: any[]) => {
    const currentEndSiteName = String(deps.endSite?.name || '');
    Taro.setStorageSync(MODIFY_DESTINATION_SESSION_KEY, {
      active: true,
      previousEndSite: deps.endSite || null,
@@ -155,7 +156,7 @@
    });
    Taro.setStorageSync(MODIFY_DESTINATION_ROUTE_POINTS_KEY, Array.isArray(routePoints) ? routePoints : []);
    Taro.removeStorageSync(MODIFY_DESTINATION_CANDIDATE_KEY);
    deps.toSelectSite('end');
    deps.toSelectSite('end', currentEndSiteName);
  };
  const clearLocalDestinationOverride = () => {
src/robotaxi/pages/begin-route/hooks/use-page-actions.ts
@@ -82,9 +82,10 @@
  /**
   * 跳转选点页。
   */
  const toSelectSite = (pageType: 'start' | 'end') => {
  const toSelectSite = (pageType: 'start' | 'end', keyword?: string) => {
    const searchKeyword = encodeURIComponent(String(keyword || ''));
    Taro.navigateTo({
      url: `/robotaxi/pages/site-search/index?pageType=${pageType}&longitude=${deps.startSite.longitude}&latitude=${deps.startSite.latitude}&electronicAreaId=${deps.startSite.electronicAreaId}`
      url: `/robotaxi/pages/site-search/index?pageType=${pageType}&longitude=${deps.startSite.longitude}&latitude=${deps.startSite.latitude}&electronicAreaId=${deps.startSite.electronicAreaId}&keyword=${searchKeyword}`
    });
  };
src/robotaxi/pages/site-search/index.tsx
@@ -1,5 +1,5 @@
import Taro from '@tarojs/taro';
import { useState, useEffect } from 'react';
import { useState, useEffect, useRef } from 'react';
import { View, Text, Image, Input } from '@tarojs/components';
import './index.less';
import map from '../../assets/map.png'
@@ -38,11 +38,13 @@
  const [showTipPopup, setShowTipPopup] = useState(false)
  const [tipType, setTipType] = useState('')
  const [showFavoritePopup, setShowFavoritePopup] = useState(false)
  const hasAppliedInitialKeyword = useRef(false) // 是否已应用初始搜索关键字
  const MAX_SHOW_COUNT = 5 // 默认最多显示5条
  const MAX_EXPANDED_COUNT = 10
  const router = Taro.useRouter();
  const initialKeyword = String(router.params?.keyword || '').trim();
  const {
    pageType,
    siteList,
@@ -78,6 +80,15 @@
    }).catch(() => { });
  }, []);
  useEffect(() => {
    if (!initialKeyword || hasAppliedInitialKeyword.current) {
      return;
    }
    hasAppliedInitialKeyword.current = true;
    setSearchValue(initialKeyword);
    confirmSearch(initialKeyword);
  }, [initialKeyword, confirmSearch]);
  // 处理终点选择后的业务校验与跳转
  const handleEndSiteSelection = async (item: any) => {
    const startSiteCache = Taro.getStorageSync('startSite');