hejianhao
2026-04-21 e48e2fde0b21ae67ac8455cedf153f59a6d3f032
Merge branch 'feature_search_fix' into feature_v1.0
5个文件已修改
48 ■■■■■ 已修改文件
src/robotaxi/pages/begin-route/hooks/use-order-actions.ts 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/hooks/use-web-socket-events.ts 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/index.tsx 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/hooks/use-site-search.ts 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/index.tsx 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/hooks/use-order-actions.ts
@@ -30,6 +30,8 @@
  setTripStatus: (value: TripStatus) => void;
  /** 订单设置 */
  setOrderId: (value: string) => void;
  /** 车辆信息设置 */
  setVehicleInfo: (value: any) => void;
  /** 下单提交设置 */
  setCallSubmitting: (value: boolean) => void;
  /** 取消类型设置 */
@@ -219,6 +221,7 @@
   */
  const clearActiveOrderRuntime = () => {
    deps.setOrderId('');
    deps.setVehicleInfo({});
    clearOrderTripStorage();
    Taro.removeStorageSync('pickupEndTime');
    Taro.removeStorageSync('waitingTimerStartAt');
src/robotaxi/pages/begin-route/hooks/use-web-socket-events.ts
@@ -54,7 +54,8 @@
};
const isSameOrder = (incomingOrderId: string, currentOrderId: string) => {
    if (!incomingOrderId || !currentOrderId) return true;
    if (!incomingOrderId && !currentOrderId) return true;
    if (!incomingOrderId || !currentOrderId) return false;
    return String(incomingOrderId) === String(currentOrderId);
};
@@ -99,20 +100,21 @@
    lastFetchedVehicleOrderIdRef: any
) => {
    if (!effectiveOrderId) return;
    const vehicleInfoEmpty =
        !deps.vehicleInfo ||
        (!deps.vehicleInfo.plateNumber && !deps.vehicleInfo.vehicleCode && !deps.vehicleInfo.vehicleColor && !deps.vehicleInfo.vehiclePictures);
    const shouldFetchVehicle =
        lastFetchedVehicleOrderIdRef.current !== effectiveOrderId &&
        (vehicleInfoEmpty || deps.orderId !== effectiveOrderId);
    const shouldFetchVehicle = lastFetchedVehicleOrderIdRef.current !== effectiveOrderId;
    if (deps.orderId !== effectiveOrderId) {
        deps.setOrderId(effectiveOrderId);
        Taro.setStorageSync('orderId', effectiveOrderId);
    }
    if (!shouldFetchVehicle) return;
    lastFetchedVehicleOrderIdRef.current = effectiveOrderId;
    const requestedOrderId = String(effectiveOrderId);
    queryVehicleByOrderId({ orderId: effectiveOrderId })
        .then((res: any) => {
            const latestOrderId = String(Taro.getStorageSync('orderId') || '');
            if (latestOrderId !== requestedOrderId) {
                return;
            }
            deps.setVehicleInfo(res);
        })
        .catch(() => { });
@@ -122,6 +124,7 @@
    if (!payload?.showCancelPopup) return;
    if (changeStatusOld === TripStatus.VehicleApproaching || changeStatusOld === TripStatus.VehicleArrivedPickup) {
        deps.setOrderId('');
        deps.setVehicleInfo({});
        clearOrderTripStorage();
        Taro.removeStorageSync('pickupEndTime');
        Taro.removeStorageSync('waitingTimerStartAt');
@@ -361,8 +364,13 @@
                return;
            }
            lastFetchedVehicleOrderIdRef.current = null;
            const requestedOrderId = String(currentOrderId || '');
            queryVehicleByOrderId({ orderId: currentOrderId })
                .then((res: any) => {
                    const latestOrderId = String((depsRef.current.orderId || Taro.getStorageSync('orderId') || ''));
                    if (!requestedOrderId || latestOrderId !== requestedOrderId) {
                        return;
                    }
                    currentDeps.setVehicleInfo(res);
                })
                .catch(() => { });
src/robotaxi/pages/begin-route/index.tsx
@@ -526,6 +526,7 @@
    cancelType,
    setTripStatus,
    setOrderId,
    setVehicleInfo,
    setCallSubmitting,
    setCancelType,
    setShowCancelPopup,
src/robotaxi/pages/site-search/hooks/use-site-search.ts
@@ -185,6 +185,20 @@
    searchSiteRef.current(pendingValue);
  };
  // 确认搜索:优先使用显式关键字,其次使用防抖待执行关键字,最后回退到当前输入值
  const confirmSearch = (val?: string) => {
    const explicitValue = typeof val === 'string' ? val : '';
    const pendingValue = pendingSearchValueRef.current;
    const fallbackValue = deps.searchValue;
    const targetValue = explicitValue || pendingValue || fallbackValue || '';
    if (debounceTimerRef.current) {
      clearTimeout(debounceTimerRef.current);
      debounceTimerRef.current = null;
    }
    pendingSearchValueRef.current = '';
    searchSiteRef.current(targetValue);
  };
  // 清空搜索结果列表
  const clearSearchResults = () => {
    cancelDebouncedSearch();
@@ -290,6 +304,7 @@
    refreshData,
    cancelDebouncedSearch,
    flushDebouncedSearch,
    confirmSearch,
    clearSearchResults
  };
}
src/robotaxi/pages/site-search/index.tsx
@@ -55,6 +55,7 @@
    refreshData,
    cancelDebouncedSearch,
    flushDebouncedSearch,
    confirmSearch,
  } = useSiteSearch({
    router,
    searchValue,
@@ -269,9 +270,9 @@
          <Input className='search-input' placeholder={pageType == 'start' ? '请输入上车点' : '请输入目的地'} value={searchValue}
            onInput={(e) => changeSearchValue(e)}
            onBlur={flushDebouncedSearch}
            onConfirm={() => {
              cancelDebouncedSearch();
              searchSite();
            onConfirm={(e) => {
              const keyword = e?.detail?.value || searchValue; // 确认搜索关键字,优先取输入框事件值
              confirmSearch(keyword);
            }}
            confirmType='search'
            autoFocus