| | |
| | | import Taro from '@tarojs/taro'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { useRef } from 'react'; |
| | | import { showToast } from '../../../components/toast'; |
| | | import wsManager from '../../../../utils/websocket'; |
| | | import { mapOrderStatusToTripStatus, clearOrderTripStorage } from '../../../../utils/Robotaxi-public-method'; |
| | |
| | | * 页面恢复与初始化编排:负责缓存恢复、订单同步、定位初始化与 socket 准备。 |
| | | */ |
| | | export default function usePageRestore(deps: Deps) { |
| | | const hasShownActiveTripToastRef = useRef(false); // 同一页面实例内只提示一次,避免回前台重复闪 toast |
| | | |
| | | /** |
| | | * 清理已选优惠券缓存。 |
| | | */ |
| | |
| | | const isModifyDestinationSessionActive = !!Taro.getStorageSync(MODIFY_DESTINATION_SESSION_KEY)?.active; // 修改目的地返回链路不提示“已有进行中订单” |
| | | const isModifyDestinationReturn = String(fromModifyDestination || '') === '1'; |
| | | const shouldShowPendingSameSiteToast = isModifyDestinationReturn && !!Taro.getStorageSync(MODIFY_DESTINATION_PENDING_SAME_SITE_TOAST_KEY); |
| | | if (skipPageFlag && hasActiveTripOrderInStorage() && !isModifyDestinationReturn && !isModifyDestinationSessionActive) { |
| | | const shouldShowActiveTripToast = Boolean(skipPageFlag) |
| | | && !hasShownActiveTripToastRef.current |
| | | && hasActiveTripOrderInStorage() |
| | | && !isModifyDestinationReturn |
| | | && !isModifyDestinationSessionActive; |
| | | if (shouldShowActiveTripToast) { |
| | | hasShownActiveTripToastRef.current = true; |
| | | showToast({ |
| | | title: getActiveTripOrderToastTitle(Taro.getStorageSync('tripStatus')), |
| | | icon: 'none', |