refactor(robotaxi): 统一替换 Taro.showToast 为自定义 toast 组件1
Co-Authored-By: 甄雪君 <zhenxj@xiaopeng.com>
| | |
| | | CouponDetail |
| | | } from "../../../robotaxi/api/coupon"; |
| | | import { withRobotaxiWhitelist } from "../../../utils/whitelist"; |
| | | import { showToast } from "../../components/toast"; |
| | | import { withToast } from "../../components/toast/with-toast"; |
| | | |
| | | function CouponPage() { |
| | | const [couponStatus] = useState([ |
| | |
| | | setVisible(true); |
| | | } catch (error) { |
| | | Taro.hideLoading(); |
| | | Taro.showToast({ title: "获取详情失败", icon: "none" }); |
| | | showToast({ title: "获取详情失败", icon: "none" }); |
| | | } |
| | | }; |
| | | |
| | |
| | | e.stopPropagation(); |
| | | try { |
| | | await receiveCoupon({ couponId: item.couponId }); |
| | | Taro.showToast({ title: "领取成功", icon: "success" }); |
| | | showToast({ title: "领取成功", icon: "success" }); |
| | | // 领取成功后刷新列表 |
| | | getList(1, activeStatus, true); |
| | | setPageNum(1); |
| | | } catch (error) { |
| | | Taro.showToast({ title: "领取失败", icon: "none" }); |
| | | showToast({ title: "领取失败", icon: "none" }); |
| | | } |
| | | }; |
| | | |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(CouponPage); |
| | | export default withRobotaxiWhitelist(withToast(CouponPage)); |
| | |
| | | } from '../../../utils/Robotaxi-public-method'; |
| | | import EvaluatePopup from '../begin-route/components/evaluate-popup'; |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { showToast } from '../../components/toast'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | import './index.less'; |
| | | |
| | | function OrderPage() { |
| | |
| | | setFareData(res); |
| | | } catch (error) { |
| | | console.error('获取费用明细失败', error); |
| | | Taro.showToast({ title: '获取费用明细失败', icon: 'none' }); |
| | | showToast({ title: '获取费用明细失败', icon: 'none' }); |
| | | } |
| | | }; |
| | | |
| | |
| | | ) |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(OrderPage); |
| | | export default withRobotaxiWhitelist(withToast(OrderPage)); |
| | |
| | | formatTripDurationFromSeconds |
| | | } from '../../../utils/Robotaxi-public-method'; |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { showToast } from '../../components/toast'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | |
| | | /** 城市缓存 key */ |
| | | const SELECTED_CITY_STORAGE_KEY = 'selectedCity'; |
| | |
| | | const cityID = getSelectedCityId(); |
| | | |
| | | if (!cityID) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: RESELECT_CITY_TOAST_TEXT, |
| | | icon: 'none' |
| | | }); |
| | |
| | | ) |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(OrderPage); |
| | | export default withRobotaxiWhitelist(withToast(OrderPage)); |
| | |
| | | import Taro from '@tarojs/taro'; |
| | | import Toast, { showToast } from '../../components/toast'; |
| | | import { View, 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' }); |
| | | } |
| | | }; |
| | | |
| | |
| | | )} |
| | | </View> |
| | | </ScrollView> |
| | | <Toast /> |
| | | </View> |
| | | ); |
| | | } |
| | |
| | | import { formatTripDistance, formatTripDurationFromSeconds, safeParse } from '../../../../utils/Robotaxi-public-method'; |
| | | import { getOrderId } from '../../../utils/order'; |
| | | import { withRobotaxiWhitelist } from '../../../../utils/whitelist'; |
| | | import { showToast } from '../../../components/toast'; |
| | | import { withToast } from '../../../components/toast/with-toast'; |
| | | |
| | | function OrderDetailPage() { |
| | | const router = useRouter(); |
| | |
| | | setActiveIndex(res.orderRating); |
| | | } catch (error) { |
| | | console.error('获取订单详情失败', error); |
| | | Taro.showToast({ title: '获取详情失败', icon: 'none' }); |
| | | showToast({ title: '获取详情失败', icon: 'none' }); |
| | | } |
| | | }; |
| | | |
| | |
| | | const submitSimpleEvaluate = (index: number) => { |
| | | const targetOrderId = getOrderId(orderId); |
| | | if (!targetOrderId) { |
| | | Taro.showToast({ title: '订单信息缺失,无法提交评价', icon: 'none' }); |
| | | showToast({ title: '订单信息缺失,无法提交评价', icon: 'none' }); |
| | | return; |
| | | } |
| | | const successToastMap: Record<number, string> = { |
| | |
| | | submitOrderComment({ orderRating: index, orderId: targetOrderId }) |
| | | .then(() => { |
| | | setActiveIndex(index); |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: successToastMap[index] || '评价提交成功', |
| | | icon: 'none' |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | Taro.showToast({ title: '评价提交失败,请稍后重试', icon: 'none' }); |
| | | showToast({ title: '评价提交失败,请稍后重试', icon: 'none' }); |
| | | }); |
| | | } |
| | | |
| | |
| | | ) |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(OrderDetailPage); |
| | | export default withRobotaxiWhitelist(withToast(OrderDetailPage)); |
| | |
| | | const XP_INVOICE_APP_ID = "xp_invoice"; |
| | | |
| | | import { withRobotaxiWhitelist } from "../../../utils/whitelist"; |
| | | import { showToast } from "../../components/toast"; |
| | | import { withToast } from "../../components/toast/with-toast"; |
| | | |
| | | function OrderPage() { |
| | | const router = useRouter(); |
| | |
| | | // 根据当前订单编号跳转到发票开具页面。 |
| | | const toInvoicePage = (orderNo?: string) => { |
| | | if (!orderNo) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: "订单编号缺失", |
| | | icon: "none" |
| | | }); |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(OrderPage); |
| | | export default withRobotaxiWhitelist(withToast(OrderPage)); |
| | |
| | | import './index.less' |
| | | import { getLoginAgreementContentInfo, getPrivacyContent } from '../../api/home'; |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { showToast } from '../../components/toast'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | |
| | | type AgreementItem = { |
| | | id: number | string; |
| | |
| | | console.log('normalizeContent(target.content ||', normalizeContent(target.content || '')); |
| | | return; |
| | | } |
| | | Taro.showToast({ title: '协议内容获取失败', icon: 'none' }); |
| | | showToast({ title: '协议内容获取失败', icon: 'none' }); |
| | | }).catch(() => { |
| | | Taro.showToast({ title: '协议内容获取失败', icon: 'none' }); |
| | | showToast({ title: '协议内容获取失败', icon: 'none' }); |
| | | }); |
| | | }, []); |
| | | |
| | |
| | | ) |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(PassengerNotice); |
| | | export default withRobotaxiWhitelist(withToast(PassengerNotice)); |
| | |
| | | ]; |
| | | |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { showToast } from '../../components/toast'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | |
| | | function PersonalCenter() { |
| | | const nickname = useSelector((state: any) => state.user?.userInfo?.nickName) || "小鹏艺术家"; |
| | |
| | | return; |
| | | } |
| | | |
| | | Taro.showToast({ title: "功能建设中", icon: "none" }); |
| | | showToast({ title: "功能建设中", icon: "none" }); |
| | | }; |
| | | |
| | | return ( |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(PersonalCenter); |
| | | export default withRobotaxiWhitelist(withToast(PersonalCenter)); |
| | |
| | | import { View, Text } from '@tarojs/components'; |
| | | import { getPricingRules } from '../../api/pricing'; |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { showToast } from '../../components/toast'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | import './index.less'; |
| | | |
| | | type AnyRecord = Record<string, any>; |
| | |
| | | setMockJson(res || {}); |
| | | } catch (error) { |
| | | setMockJson({}); |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '获取定价规则失败', |
| | | icon: 'none' |
| | | }); |
| | | }); |
| | | } finally { |
| | | setLoading(false); |
| | | } |
| | |
| | | ); |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(PricingRulesPage); |
| | | export default withRobotaxiWhitelist(withToast(PricingRulesPage)); |
| | | |
| | |
| | | import './index.less'; |
| | | import { getOpenCity, getCityList } from '../../api/select-city'; |
| | | import { withRobotaxiWhitelist } from '../../../utils/whitelist'; |
| | | import { showToast } from '../../components/toast'; |
| | | import { withToast } from '../../components/toast/with-toast'; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | const handleSelectCity = (city, isOpen) => { |
| | | if (!isOpen) { |
| | | Taro.showToast({ |
| | | showToast({ |
| | | title: '该城市暂未开通服务', |
| | | icon: 'none' |
| | | }); |
| | |
| | | ) |
| | | } |
| | | |
| | | export default withRobotaxiWhitelist(SelectCityPage); |
| | | export default withRobotaxiWhitelist(withToast(SelectCityPage)); |