ai-coding
2026-07-28 fd415619c95ab08064f6336e061f2fd18d1147ea
refactor(robotaxi): 统一替换 Taro.showToast 为自定义 toast 组件1

Co-Authored-By: 甄雪君 <zhenxj@xiaopeng.com>
9个文件已修改
82 ■■■■■ 已修改文件
src/robotaxi/pages/payment-setting-detail/index.tsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/payment-setting/index.tsx 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/select-map-site/hooks/use-select-map-site.ts 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/select-map-site/index.tsx 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/share-trip/hooks/use-share-trip-runtime.ts 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/share-trip/index.tsx 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/components/favorite-popup/index.tsx 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/components/site-list-item.tsx 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/site-search/index.tsx 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/payment-setting-detail/index.tsx
@@ -3,6 +3,8 @@
import { useCallback, useState } from 'react';
import { getPayPwd, RobotaxiPaySettingStatus, setPayPwd } from '../../api/payment';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
import './index.less';
@@ -54,7 +56,7 @@
    try {
      setIsOperating(true);
      await setPayPwd(RobotaxiPaySettingStatus.Disable);
      Taro.showToast({
      showToast({
        title: '微信免密支付已关闭',
        icon: 'none'
      });
@@ -62,7 +64,7 @@
        navigateBackToList();
      }, 300);
    } catch (error) {
      Taro.showToast({
      showToast({
        title: '关闭失败',
        icon: 'none'
      });
@@ -79,7 +81,7 @@
        }
      })
      .catch(() => {
        Taro.showToast({
        showToast({
          title: '查询支付设置失败',
          icon: 'none'
        });
@@ -109,4 +111,4 @@
  );
}
export default withRobotaxiWhitelist(PaymentSettingDetail);
export default withRobotaxiWhitelist(withToast(PaymentSettingDetail));
src/robotaxi/pages/payment-setting/index.tsx
@@ -3,6 +3,8 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { getPayPwd, RobotaxiPaySettingStatus, setPayPwd } from '../../api/payment';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
import './index.less';
@@ -53,7 +55,7 @@
      return nextStatus;
    } catch (error) {
      if (showErrorToast) {
        Taro.showToast({ title: '查询支付设置失败', icon: 'none' });
        showToast({ title: '查询支付设置失败', icon: 'none' });
      }
      throw error;
    }
@@ -72,12 +74,12 @@
    try {
      const nextStatus = await refreshPayStatus(false);
      Taro.showToast({
      showToast({
        title: nextStatus ? '开通成功' : '开通未完成',
        icon: nextStatus ? 'success' : 'none'
      });
    } catch (error) {
      Taro.showToast({ title: '查询签约结果失败', icon: 'none' });
      showToast({ title: '查询签约结果失败', icon: 'none' });
    } finally {
      setIsOperating(false);
    }
@@ -101,7 +103,7 @@
  const openCreditPaySign = useCallback((signStr: string) => {
    const weappGlobal = (globalThis as any).wx;
    if (typeof weappGlobal?.openBusinessView !== 'function') {
      Taro.showToast({ title: '请升级微信版本后重试', icon: 'none' });
      showToast({ title: '请升级微信版本后重试', icon: 'none' });
      return false;
    }
@@ -116,7 +118,7 @@
        waitingCreditPayReturnRef.current = false;
        clearCreditPayReturnListener();
        setIsOperating(false);
        Taro.showToast({ title: '拉起支付分签约失败', icon: 'none' });
        showToast({ title: '拉起支付分签约失败', icon: 'none' });
      }
    });
    return true;
@@ -147,7 +149,7 @@
      if (nextOperateStatus === RobotaxiPaySettingStatus.Disable) {
        const nextStatus = await refreshPayStatus(false);
        Taro.showToast({
        showToast({
          title: nextStatus ? '关闭未完成' : '已关闭',
          icon: nextStatus ? 'none' : 'success'
        });
@@ -156,7 +158,7 @@
      const signStr = String(response?.signStr || '');
      if (!signStr) {
        Taro.showToast({ title: '获取签约信息失败', icon: 'none' });
        showToast({ title: '获取签约信息失败', icon: 'none' });
        return;
      }
@@ -165,7 +167,7 @@
        return;
      }
    } catch (error) {
      Taro.showToast({
      showToast({
        title: isPayEnabled ? '关闭失败' : '开通失败',
        icon: 'none'
      });
@@ -212,4 +214,4 @@
  );
}
export default withRobotaxiWhitelist(PaymentSetting);
export default withRobotaxiWhitelist(withToast(PaymentSetting));
src/robotaxi/pages/select-map-site/hooks/use-select-map-site.ts
@@ -1,4 +1,5 @@
import Taro, { useDidShow } from "@tarojs/taro";
import { showToast } from '../../../components/toast';
import { useEffect, useMemo } from 'react';
import {
  buildStationMetaMap,
@@ -494,7 +495,7 @@
  const handleViewOperatingArea = () => {
    const points = extractPointsFromPolygons(selectablePolygons);
    if (points.length === 0) {
      Taro.showToast({ title: '暂无可选运营区域', icon: 'none' });
      showToast({ title: '暂无可选运营区域', icon: 'none' });
      return;
    }
    const mapCtx = Taro.createMapContext('select-site-map');
@@ -675,18 +676,18 @@
   */
  const confirmSite = async () => {
    if (!state.selectedSite.name) {
      Taro.showToast({ title: '请选择站点', icon: 'none' });
      showToast({ title: '请选择站点', icon: 'none' });
      return;
    }
    if (state.rangeStatus === SELECT_SITE_RANGE_STATUS.crossOperatingArea) {
      Taro.showToast({ title: '请在同一运营区内选择', icon: 'none' });
      showToast({ title: '请在同一运营区内选择', icon: 'none' });
      return;
    }
    if (state.pageType === 'start') {
      const distanceConfig = await ensureDistanceConfigReady();
      const endSiteCache = Taro.getStorageSync('endSite');
      if (endSiteCache?.electronicAreaId && state.selectedSite?.electronicAreaId && endSiteCache.electronicAreaId !== state.selectedSite.electronicAreaId) {
        Taro.showToast({ title: '请在同一运营区内选择', icon: 'none' });
        showToast({ title: '请在同一运营区内选择', icon: 'none' });
        return;
      }
      if (!isWithinPickupMaxDistance({
@@ -728,7 +729,7 @@
    const distanceConfig = await ensureDistanceConfigReady();
    const startSiteCache = Taro.getStorageSync('startSite');
    if (startSiteCache?.electronicAreaId && state.selectedSite?.electronicAreaId && startSiteCache.electronicAreaId !== state.selectedSite.electronicAreaId) {
      Taro.showToast({ title: '请在同一运营区内选择', icon: 'none' });
      showToast({ title: '请在同一运营区内选择', icon: 'none' });
      return;
    }
    if (!isWithinStartEndMinDistance({
@@ -844,7 +845,7 @@
          Taro.setStorageSync('endSite', nextSite);
        }
      }
      Taro.showToast({
      showToast({
        title: type === 2 ? '已取消收藏' : '收藏成功',
        icon: 'none'
      });
src/robotaxi/pages/select-map-site/index.tsx
@@ -10,6 +10,7 @@
  PIN_PICKUP_LOCATION_PAGE_VIEW_EVENT_ID
} from '../../constants/report-events';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { withToast } from '../../components/toast/with-toast';
/**
 * 地图选点页入口:负责 hook 编排与视图组装。
@@ -116,4 +117,4 @@
  );
}
export default withRobotaxiWhitelist(SelectMapSite);
export default withRobotaxiWhitelist(withToast(SelectMapSite));
src/robotaxi/pages/share-trip/hooks/use-share-trip-runtime.ts
@@ -1,4 +1,5 @@
import Taro from '@tarojs/taro';
import { showToast } from '../../../components/toast';
import { useEffect, useRef } from 'react';
import type { MutableRefObject } from 'react';
import { getDistance, mapOrderStatusToTripStatus } from '../../../../utils/Robotaxi-public-method';
@@ -455,7 +456,7 @@
      return;
    }
    if (!deps.orderId) {
      Taro.showToast({ title: '分享订单不存在', icon: 'none' });
      showToast({ title: '分享订单不存在', icon: 'none' });
      return;
    }
@@ -474,7 +475,7 @@
      console.error('获取分享行程失败', error);
      if (!errorToastShownRef.current) {
        errorToastShownRef.current = true;
        Taro.showToast({ title: '获取分享行程失败', icon: 'none' });
        showToast({ title: '获取分享行程失败', icon: 'none' });
      }
    };
@@ -562,7 +563,7 @@
        pollCount += 1;
        if (pollCount >= MAX_SHARE_TRIP_POLL_COUNT) {
          stopPolling();
          Taro.showToast({ title: '分享行程数据可能不是最新,请手动刷新', icon: 'none' });
          showToast({ title: '分享行程数据可能不是最新,请手动刷新', icon: 'none' });
          return;
        }
        void fetchShareTripData();
src/robotaxi/pages/share-trip/index.tsx
@@ -16,6 +16,7 @@
import { checkOtp } from '../../../utils/tools';
import { safeMakePhoneCall } from '../../../utils/Robotaxi-public-method';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { withToast } from '../../components/toast/with-toast';
const ROUTE_SUMMARY_MARKER_ID = 999001;
@@ -395,4 +396,4 @@
  );
}
export default withRobotaxiWhitelist(ShareTrip);
export default withRobotaxiWhitelist(withToast(ShareTrip));
src/robotaxi/pages/site-search/components/favorite-popup/index.tsx
@@ -1,4 +1,5 @@
import Taro from '@tarojs/taro';
import { showToast } from '../../../../components/toast';
import { View, Text, Image, ScrollView } from '@tarojs/components';
import { useEffect, useState } from 'react';
import './index.less';
@@ -80,10 +81,10 @@
      await collectPoint(payload);
      setList(prev => prev.filter(f => (f.id || f.pointId || f.stationId) !== (item.id || item.pointId || item.stationId)));
      Taro.showToast({ title: '已取消收藏', icon: 'none' });
      showToast({ title: '已取消收藏', icon: 'none' });
    } catch (e) {
      console.log('取消收藏失败', e);
      Taro.showToast({ title: '取消收藏失败', icon: 'none' });
      showToast({ title: '取消收藏失败', icon: 'none' });
    }
  };
@@ -96,7 +97,7 @@
    if (itemType === 2) {
      const children = Array.isArray(item?.children) ? item.children : [];
      if (children.length === 0) {
        Taro.showToast({
        showToast({
          title: '此场站无有效站点',
          icon: 'none',
        });
src/robotaxi/pages/site-search/components/site-list-item.tsx
@@ -1,4 +1,5 @@
import Taro from '@tarojs/taro';
import { showToast } from '../../../components/toast';
import { View, Image } from '@tarojs/components';
import { useState, useEffect } from 'react';
import { collectPoint, getCollectPoints } from '../../../api/site-search';
@@ -83,7 +84,7 @@
    }
    const firstSite = stationChildren[0];
    if (!firstSite) {
      Taro.showToast({
      showToast({
        title: '此场站无有效站点',
        icon: 'none'
      });
@@ -107,7 +108,7 @@
    });
    if (Number(res?.total) >= MAX_COLLECT_COUNT) {
      Taro.showToast({
      showToast({
        title: `最多收藏${MAX_COLLECT_COUNT}个站点`,
        icon: 'none'
      });
@@ -153,7 +154,7 @@
      await collectPoint(payload);
      setIsCollected(!isCollected);
      Taro.showToast({
      showToast({
        title: isCollected ? '已取消收藏' : '收藏成功',
        icon: 'none'
      });
src/robotaxi/pages/site-search/index.tsx
@@ -64,6 +64,8 @@
} from '../../constants/confirm-ride-report';
import { hasActiveTripOrderInStorage } from '../../utils/order';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
import { TripStatus } from '../../constants/trip-status';
function SiteSearchPage() {
@@ -144,7 +146,7 @@
    const resolvedDistanceConfig = await ensureDistanceConfigReady();
    const startSiteCache = Taro.getStorageSync('startSite');
    if (startSiteCache?.electronicAreaId && item?.electronicAreaId && startSiteCache.electronicAreaId !== item.electronicAreaId) {
      Taro.showToast({
      showToast({
        title: '起终点需在同一运营区域',
        icon: 'none',
      })
@@ -377,14 +379,14 @@
    sourceType = UNKNOWN_CONFIRM_RIDE_SOURCE_TYPE
  ) => {
    if (item?.operationStatus === 2) {
      Taro.showToast({
      showToast({
        title: '当前站点暂未开放',
        icon: 'none',
      })
      return
    }
    if (!isNonOperational) {
      Taro.showToast({
      showToast({
        title: '当前站点暂未开放',
        icon: 'none',
      })
@@ -394,7 +396,7 @@
      const resolvedDistanceConfig = await ensureDistanceConfigReady();
      const endSiteCache = Taro.getStorageSync('endSite');
      if (endSiteCache?.electronicAreaId && item?.electronicAreaId && endSiteCache.electronicAreaId !== item.electronicAreaId) {
        Taro.showToast({
        showToast({
          title: '起终点需在同一运营区域',
          icon: 'none',
        })
@@ -704,4 +706,4 @@
  )
}
export default withRobotaxiWhitelist(SiteSearchPage);
export default withRobotaxiWhitelist(withToast(SiteSearchPage));