fix: 订单详情页状态为0时清除路线并优化解锁位置获取
- 订单状态为0(待接单)时,地图不显示路线
- 解锁车辆时优先使用实时定位,失败时回退到起点位置
- 修复订单详情页里程和时间显示为undefined的问题
| | |
| | | }; |
| | | |
| | | // 处理解锁 |
| | | const handleUnlock = (doorType: 'door' | 'trunk', onSuccess?: () => void) => { |
| | | const getUnlockLocationPayload = async () => { |
| | | try { |
| | | const location = await Taro.getLocation({ type: 'gcj02' }); |
| | | const longitude = Number(location?.longitude); |
| | | const latitude = Number(location?.latitude); |
| | | if (!Number.isNaN(longitude) && !Number.isNaN(latitude)) { |
| | | return { longitude, latitude }; |
| | | } |
| | | } catch (_) { } |
| | | const startSite = Taro.getStorageSync('startSite') || {}; |
| | | const longitude = Number(startSite?.longitude); |
| | | const latitude = Number(startSite?.latitude); |
| | | if (!Number.isNaN(longitude) && !Number.isNaN(latitude)) { |
| | | return { longitude, latitude }; |
| | | } |
| | | return {}; |
| | | }; |
| | | |
| | | const handleUnlock = async (doorType: 'door' | 'trunk', onSuccess?: () => void) => { |
| | | const targetOrderId = orderId || Taro.getStorageSync('orderId'); |
| | | if (!targetOrderId) { |
| | | return; |
| | | } |
| | | const locationPayload = await getUnlockLocationPayload(); |
| | | unlockVehicle({ |
| | | orderId: targetOrderId, |
| | | doorType |
| | | doorType, |
| | | ...locationPayload |
| | | }).then((res: any) => { |
| | | const isFailure = res?.success === false || (typeof res?.code === 'number' && res.code !== 0); |
| | | if (isFailure) { |
| | |
| | | }; |
| | | |
| | | const initMap = (data: OrderDetail) => { |
| | | const { startLat, startLon, endLat, endLon, trajectories } = data; |
| | | const { startLat, startLon, endLat, endLon, trajectories, status } = data; |
| | | |
| | | // 设置起点和终点标记 |
| | | const markerList = [ |
| | |
| | | setLatitude(center.latitude); |
| | | } |
| | | |
| | | if (status === 0) { |
| | | setPolyline([]); |
| | | return; |
| | | } |
| | | const polylineData = [{ |
| | | points: routePath, |
| | | color: '#6D7FD9', |
| | |
| | | <View className='trip-line'> |
| | | { |
| | | orderData.status != 0 && |
| | | <View className='line-name'>全程{orderData.totalMileage || '-'}公里|{orderData.orderTime || '-'}分钟</View> |
| | | <View className='line-name'>全程{orderData.totalMileage}公里|{orderData.orderTime}分钟</View> |
| | | } |
| | | <View className='line-address'> |
| | | <View className='line-icon first-icon'></View> |