refactor(robotaxi): 统一替换 Taro.showToast 为自定义 toast 组件1
Co-Authored-By: 甄雪君 <zhenxj@xiaopeng.com>
| | |
| | | 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'; |
| | | |
| | |
| | | try { |
| | | setIsOperating(true); |
| | | await setPayPwd(RobotaxiPaySettingStatus.Disable); |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '微信免密支付已关闭', |
| | | icon: 'none' |
| | | }); |
| | |
| | | navigateBackToList(); |
| | | }, 300); |
| | | } catch (error) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '关闭失败', |
| | | icon: 'none' |
| | | }); |
| | |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '查询支付设置失败', |
| | | icon: 'none' |
| | | }); |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(PaymentSettingDetail); |
| | | export default withRobotaxiWhitelist(withToast(PaymentSettingDetail)); |
| | |
| | | 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'; |
| | | |
| | |
| | | return nextStatus; |
| | | } catch (error) { |
| | | if (showErrorToast) { |
| | | Taro.showToast({ title: '查询支付设置失败', icon: 'none' }); |
| | | showToast({ title: '查询支付设置失败', icon: 'none' }); |
| | | } |
| | | throw error; |
| | | } |
| | |
| | | |
| | | 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); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | waitingCreditPayReturnRef.current = false; |
| | | clearCreditPayReturnListener(); |
| | | setIsOperating(false); |
| | | Taro.showToast({ title: '拉起支付分签约失败', icon: 'none' }); |
| | | showToast({ title: '拉起支付分签约失败', icon: 'none' }); |
| | | } |
| | | }); |
| | | return true; |
| | |
| | | |
| | | if (nextOperateStatus === RobotaxiPaySettingStatus.Disable) { |
| | | const nextStatus = await refreshPayStatus(false); |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: nextStatus ? '关闭未完成' : '已关闭', |
| | | icon: nextStatus ? 'none' : 'success' |
| | | }); |
| | |
| | | |
| | | const signStr = String(response?.signStr || ''); |
| | | if (!signStr) { |
| | | Taro.showToast({ title: '获取签约信息失败', icon: 'none' }); |
| | | showToast({ title: '获取签约信息失败', icon: 'none' }); |
| | | return; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | } catch (error) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: isPayEnabled ? '关闭失败' : '开通失败', |
| | | icon: 'none' |
| | | }); |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(PaymentSetting); |
| | | export default withRobotaxiWhitelist(withToast(PaymentSetting)); |
| | |
| | | import Taro, { useDidShow } from "@tarojs/taro"; |
| | | import { showToast } from '../../../components/toast'; |
| | | import { useEffect, useMemo } from 'react'; |
| | | import { |
| | | buildStationMetaMap, |
| | |
| | | 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'); |
| | |
| | | */ |
| | | 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({ |
| | |
| | | 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({ |
| | |
| | | Taro.setStorageSync('endSite', nextSite); |
| | | } |
| | | } |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: type === 2 ? '已取消收藏' : '收藏成功', |
| | | icon: 'none' |
| | | }); |
| | |
| | | PIN_PICKUP_LOCATION_PAGE_VIEW_EVENT_ID |
| | | } from '../../constants/report-events'; |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | |
| | | /** |
| | | * 地图选点页入口:负责 hook 编排与视图组装。 |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(SelectMapSite); |
| | | export default withRobotaxiWhitelist(withToast(SelectMapSite)); |
| | |
| | | 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'; |
| | |
| | | return; |
| | | } |
| | | if (!deps.orderId) { |
| | | Taro.showToast({ title: '分享订单不存在', icon: 'none' }); |
| | | showToast({ title: '分享订单不存在', icon: 'none' }); |
| | | return; |
| | | } |
| | | |
| | |
| | | console.error('获取分享行程失败', error); |
| | | if (!errorToastShownRef.current) { |
| | | errorToastShownRef.current = true; |
| | | Taro.showToast({ title: '获取分享行程失败', icon: 'none' }); |
| | | showToast({ title: '获取分享行程失败', icon: 'none' }); |
| | | } |
| | | }; |
| | | |
| | |
| | | pollCount += 1; |
| | | if (pollCount >= MAX_SHARE_TRIP_POLL_COUNT) { |
| | | stopPolling(); |
| | | Taro.showToast({ title: '分享行程数据可能不是最新,请手动刷新', icon: 'none' }); |
| | | showToast({ title: '分享行程数据可能不是最新,请手动刷新', icon: 'none' }); |
| | | return; |
| | | } |
| | | void fetchShareTripData(); |
| | |
| | | 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; |
| | | |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(ShareTrip); |
| | | export default withRobotaxiWhitelist(withToast(ShareTrip)); |
| | |
| | | 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'; |
| | |
| | | |
| | | 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' }); |
| | | } |
| | | }; |
| | | |
| | |
| | | if (itemType === 2) { |
| | | const children = Array.isArray(item?.children) ? item.children : []; |
| | | if (children.length === 0) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '此场站无有效站点', |
| | | icon: 'none', |
| | | }); |
| | |
| | | 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'; |
| | |
| | | } |
| | | const firstSite = stationChildren[0]; |
| | | if (!firstSite) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '此场站无有效站点', |
| | | icon: 'none' |
| | | }); |
| | |
| | | }); |
| | | |
| | | if (Number(res?.total) >= MAX_COLLECT_COUNT) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: `最多收藏${MAX_COLLECT_COUNT}个站点`, |
| | | icon: 'none' |
| | | }); |
| | |
| | | await collectPoint(payload); |
| | | |
| | | setIsCollected(!isCollected); |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: isCollected ? '已取消收藏' : '收藏成功', |
| | | icon: 'none' |
| | | }); |
| | |
| | | } 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() { |
| | |
| | | const resolvedDistanceConfig = await ensureDistanceConfigReady(); |
| | | const startSiteCache = Taro.getStorageSync('startSite'); |
| | | if (startSiteCache?.electronicAreaId && item?.electronicAreaId && startSiteCache.electronicAreaId !== item.electronicAreaId) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '起终点需在同一运营区域', |
| | | icon: 'none', |
| | | }) |
| | |
| | | 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', |
| | | }) |
| | |
| | | const resolvedDistanceConfig = await ensureDistanceConfigReady(); |
| | | const endSiteCache = Taro.getStorageSync('endSite'); |
| | | if (endSiteCache?.electronicAreaId && item?.electronicAreaId && endSiteCache.electronicAreaId !== item.electronicAreaId) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '起终点需在同一运营区域', |
| | | icon: 'none', |
| | | }) |
| | |
| | | ) |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(SiteSearchPage); |
| | | export default withRobotaxiWhitelist(withToast(SiteSearchPage)); |