Merge branch 'feature_v1.0' of http://gitlab.xiaopeng.local:18080/robotaxi1/xp-robotaxi-miniprogram into feature_v1.0
| | |
| | | import request from '../../utils/request'; |
| | | import { _ROBOTAXI_HOST } from '../../constants/api'; |
| | | |
| | | // 获取可下单最大距离 最小距离 |
| | | // 获取系统配置项 |
| | | export const getOrderDistance = async () => { |
| | | return request({ |
| | | url: _ROBOTAXI_HOST + '/operation/base/v1/mini-program/xp-point/getOrderDistance', |
| | |
| | | import { useEffect, useState } from 'react'; |
| | | import './css-folder/over-route.less' |
| | | import { |
| | | endOrder, |
| | | queryOrderFinishTime |
| | | } from '../../../api/begin-route'; |
| | | |
| | | type Props = { |
| | | show?: boolean; |
| | | onClose?: () => void; |
| | | onConfirm?: () => void; |
| | | onConfirm?: () => Promise<void> | void; |
| | | } |
| | | |
| | | export default function OverRoute({ show = false, onClose, onConfirm }: Props) { |
| | |
| | | const [finishMinutes, setFinishMinutes] = useState<number | null>(null); // 自动驶离倒计时(分钟) |
| | | const [isSubmitting, setIsSubmitting] = useState(false); // 结束行程提交状态 |
| | | |
| | | // 确认结束行程并调用结束接口 |
| | | const handleConfirm = () => { |
| | | // 确认结束行程:仅透传确认事件,业务逻辑由 hooks 编排 |
| | | const handleConfirm = async () => { |
| | | if (isSubmitting) { |
| | | return; |
| | | } |
| | | const orderId = Taro.getStorageSync('orderId'); |
| | | if (!orderId) { |
| | | Taro.showToast({ |
| | | title: '订单信息缺失,无法结束行程', |
| | | icon: 'none' |
| | | }); |
| | | return; |
| | | } |
| | | setIsSubmitting(true); |
| | | endOrder(orderId).then((res: any) => { |
| | | if (res) { |
| | | Taro.showToast({ |
| | | title: '当前选择优惠券不满足,已自动切换为满足条件优惠券', |
| | | icon: 'none', |
| | | duration: 3000 |
| | | }); |
| | | } |
| | | onConfirm?.(); |
| | | }).catch(() => { |
| | | Taro.showToast({ |
| | | title: '结束行程失败,请重试', |
| | | icon: 'none' |
| | | }); |
| | | Promise.resolve(onConfirm?.()).catch(() => { |
| | | }).finally(() => { |
| | | setIsSubmitting(false); |
| | | }); |
| | |
| | | import { formatDateTime, clearOrderTripStorage, debounce, reportEvent } from '../../../../utils/Robotaxi-public-method'; |
| | | import { saveOrder, getOrderPayment, cancelOrder, endOrder, routeStaleCheck } from '../../../api/begin-route'; |
| | | import { getAgreement } from '../../../api/home'; |
| | | import { getOrderDistance } from '../../../api/select-map-site'; |
| | | import { checkOtp } from '../../../../utils/tools'; |
| | | import { jumpTo } from '../../../../utils/jump'; |
| | | import { subscribeAfterOrderSuccess } from '../../../../utils/subscribe'; |
| | |
| | | /** |
| | | * 确认结束行程。 |
| | | */ |
| | | const handleConfirmOverRoute = () => { |
| | | const handleConfirmOverRoute = async () => { |
| | | deps.setShowOverRoutePopup(false); |
| | | deps.setTripStatus(TripStatus.TripFinished); |
| | | const targetOrderId = deps.orderId || Taro.getStorageSync('orderId'); // 当前待结束订单 ID |
| | | if (!targetOrderId) { |
| | | Taro.showToast({ title: '订单信息缺失,无法结束行程', icon: 'none' }); |
| | | return; |
| | | } |
| | | let operateFree = 0; // 免费阶段标记:1=免费直达支付成功态 |
| | | try { |
| | | const orderDistanceConfig: any = await getOrderDistance(); |
| | | operateFree = Number(orderDistanceConfig?.operateFree); |
| | | } catch (error) { |
| | | operateFree = 0; |
| | | } |
| | | if (operateFree === 1) { |
| | | deps.setTripStatus(TripStatus.PaymentSuccess); |
| | | Taro.setStorageSync('tripStatus', TripStatus.PaymentSuccess); |
| | | return; |
| | | } |
| | | try { |
| | | const endOrderResult: any = await endOrder(targetOrderId); |
| | | if (endOrderResult) { |
| | | Taro.showToast({ |
| | | title: '当前选择优惠券不满足,已自动切换为满足条件优惠券', |
| | | icon: 'none', |
| | | duration: 3000 |
| | | }); |
| | | } |
| | | deps.setTripStatus(TripStatus.TripFinished); |
| | | } catch (error) { |
| | | Taro.showToast({ title: '结束行程失败,请重试', icon: 'none' }); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | |
| | | * 渲染单个 marker 气泡。 |
| | | */ |
| | | const renderMarkerCallout = (item: any, index: number) => { |
| | | if (shouldHideAndroidMarkerCallout && !item.isBeforeUserSite) return null; |
| | | const calloutKey = `callout-${item.id}-${item.name || ''}`; |
| | | // 路线摘要气泡需跨平台强制显示,避免被 Android 普通气泡隐藏规则误伤 |
| | | if (item.isRouteSummaryBubble) return renderDefaultCallout(item, calloutKey); |
| | | if (shouldHideAndroidMarkerCallout && !item.isBeforeUserSite) return null; |
| | | const isWaiting = [TripStatus.Publishing, TripStatus.CallingCar].includes(deps.tripStatus) && index === 0; |
| | | if (isWaiting) return renderWaitingCallout(item, calloutKey); |
| | | if (item.name === '车辆位置' && deps.isAndroid && [TripStatus.VehicleApproaching, TripStatus.InService].includes(deps.tripStatus)) return null; |
| | |
| | | .route-summary-callout-arrow { |
| | | position: absolute; |
| | | left: 50%; |
| | | bottom: 2rpx; |
| | | width: 0; |
| | | height: 0; |
| | | margin-left: -8rpx; |
| | | background: transparent; |
| | | border-style: solid; |
| | | border-width: 10rpx 8rpx 0 8rpx; |
| | | border-color: rgba(0, 0, 0, 0.6) transparent transparent transparent; |
| | | bottom: 6rpx; |
| | | width: 12rpx; |
| | | height: 12rpx; |
| | | margin-left: -6rpx; |
| | | background: rgba(0, 0, 0, 0.6); |
| | | transform: rotate(45deg); |
| | | transform-origin: center; |
| | | z-index: 1; |
| | | } |
| | | |
| | |
| | | /** @param {string|number=} what */ function abort(what) { |
| | | Module["onAbort"]?.(what); |
| | | what = "Aborted(" + what + ")"; |
| | | // TODO(sbc): Should we remove printing and leave it up to whoever |
| | | // catches the exception? |
| | | err(what); |
| | | ABORT = true; |
| | | what += ". Build with -sASSERTIONS for more info."; |
| | | // Use Error instead of WebAssembly.RuntimeError for MiniApp compatibility |
| | | var e = new Error(what); |
| | | throw e; |
| | | // 小程序环境:只打印警告,不抛错 |
| | | console.warn("[WASM]", what, ". Build with -sASSERTIONS for more info."); |
| | | // err(what); |
| | | // ABORT = true; |
| | | // var e = new Error(what); |
| | | // throw e; |
| | | } |
| | | |
| | | var wasmBinaryFile; |
| | |
| | | // 微信小程序环境直接使用文件路径 |
| | | if (ENVIRONMENT_IS_MINIAPP) { |
| | | // 小程序需要使用相对于项目根目录的路径 |
| | | var wasmPath = 'otherPage/pages/carControl/rtBleMethod.wasm.br'; |
| | | var wasmPath = 'robotaxi/utils/car-control/rtBleMethod.wasm.br'; |
| | | var instance = await WXWebAssembly.instantiate(wasmPath, imports); |
| | | return instance; |
| | | } else { |