fix(share-trip): 添加登录校验,修复行程显示逻辑并清理代码
- 为分享行程页面添加登录认证检查,仅在认证通过后渲染页面和执行业务逻辑
- 调整上下车点名称的匹配优先级,新增startPointName和endPointName字段
- 修复到达目的地的状态显示判断条件,将大于判断改为大于等于
- 清理未使用的导入语句,修复图片标签的格式问题
| | |
| | | import { View, Image, Map, CoverView, CoverImage } from '@tarojs/components'; |
| | | import { View, Image, Map } from '@tarojs/components'; |
| | | import { formatDurationDisplay, safeParse } from '../../../../utils/Robotaxi-public-method'; |
| | | import { TripStatus } from '../../begin-route/constants/trip-status'; |
| | | import homeIcon from '../../../assets/back-home.png'; |
| | |
| | | return ( |
| | | <View className='share-trip-expired'> |
| | | <View className='expired-content'> |
| | | <Image className='expired-img' src={'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/share-contact.png'} /> |
| | | <Image className='expired-img' src='https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/share-contact.png' /> |
| | | <View className='expired-text'>行程结束已超过24小时</View> |
| | | <View className='expired-sub-text'>查看行程信息,请联系客服</View> |
| | | <View className='expired-btn' onClick={handleContactService}> |
| | |
| | | 乘客已上车,正在前往目的地 |
| | | </View> |
| | | )} |
| | | {tripData?.tripStatus > TripStatus.ArrivedDestination && ( |
| | | {tripData?.tripStatus >= TripStatus.ArrivedDestination && ( |
| | | <View className='calling-car-head-title'>已到达目的地</View> |
| | | )} |
| | | </View> |
| | |
| | | type RouteDistance = { value: number; unit: 'km' | 'm' } | null; |
| | | |
| | | type Deps = { |
| | | authReady: boolean; |
| | | orderId: string; |
| | | tripStatus: TripStatus; |
| | | startSite: any; |
| | |
| | | longitude: longitudeNum, |
| | | name: getFieldValue( |
| | | source, |
| | | isStart ? ['startName', 'startSiteName', 'upName', 'originName'] : ['endName', 'endSiteName', 'downName', 'destinationName'], |
| | | isStart |
| | | ? ['startPointName', 'startName', 'startSiteName', 'upName', 'originName'] |
| | | : ['endPointName', 'endName', 'endSiteName', 'downName', 'destinationName'], |
| | | ) || (isStart ? '上车点' : '终点'), |
| | | address: getFieldValue( |
| | | source, |
| | |
| | | }, [deps.applyRoutePoints, deps.updateVehicleLocationThrottled, deps.setVehicleDirection]); |
| | | |
| | | useEffect(() => { |
| | | if (!deps.authReady) { |
| | | return; |
| | | } |
| | | if (!deps.orderId) { |
| | | Taro.showToast({ title: '分享订单不存在', icon: 'none' }); |
| | | return; |
| | |
| | | cancelled = true; |
| | | stopPolling(); |
| | | }; |
| | | }, [deps.orderId]); |
| | | }, [deps.authReady, deps.orderId]); |
| | | } |
| | |
| | | import Taro, { useRouter } from '@tarojs/taro'; |
| | | import Taro, { useDidShow, useRouter } from '@tarojs/taro'; |
| | | import { useEffect, useMemo, useState } from 'react'; |
| | | import './index.less'; |
| | | import useMapMarkers from './hooks/use-map-markers'; |
| | |
| | | import useShareTripRuntime from './hooks/use-share-trip-runtime'; |
| | | import ShareTripView from './components/share-trip-view'; |
| | | import { TripStatus } from '../begin-route/constants/trip-status'; |
| | | import { ORDER_SUCCESS_SUBSCRIBE_CONFIG } from '../../constants/subscribe'; |
| | | import { runSubscribeScene, subscribeAfterOrderSuccess } from '../../../utils/subscribe'; |
| | | import { subscribeAfterOrderSuccess } from '../../../utils/subscribe'; |
| | | import { checkOtp } from '../../../utils/tools'; |
| | | |
| | | type StatusRule = { |
| | | showPickup: boolean; |
| | |
| | | const [isExpired, setIsExpired] = useState(false); // 是否超 24h 过期 |
| | | const [showReminder, setShowReminder] = useState(true); // 是否展示提醒 |
| | | const [tripStatus, setTripStatus] = useState<TripStatus>(TripStatus.PublishRoute); // 当前行程状态 |
| | | const [authReady, setAuthReady] = useState(false); // 登录校验通过后才允许加载分享页 |
| | | |
| | | useDidShow(() => { |
| | | // 分享页需要先登录,登录成功后小程序会返回当前页并再次触发校验 |
| | | void checkOtp(true).then((otp) => { |
| | | setAuthReady(Boolean(otp)); |
| | | }); |
| | | }); |
| | | |
| | | const STATUS_RULES: Record<TripStatus, StatusRule> = { |
| | | [TripStatus.PublishRoute]: { showPickup: true, showDropoff: true, showCar: false, showRoute: true, showWalking: true, viewport: 'route_walking', translateCar: false }, |
| | |
| | | }); // 视口状态容器 |
| | | |
| | | useShareTripRuntime({ |
| | | authReady, |
| | | orderId, |
| | | tripStatus, |
| | | startSite, |
| | |
| | | setShowReminder(false); |
| | | }; // 开启提醒订阅 |
| | | |
| | | if (!authReady) { |
| | | return null; |
| | | } |
| | | |
| | | return ( |
| | | <ShareTripView |
| | | isExpired={isExpired} |