| | |
| | | setTemperature, |
| | | unlockVehicle, |
| | | queryTemperatureByOrderId, |
| | | queryVehicleTrunkOpenStatus, |
| | | queryOrderFinishTime, |
| | | queryFareBreakdown, |
| | | submitOrderComment, |
| | |
| | | const [showDetail, setShowDetail] = useState(false); // 是否显示费用明细 |
| | | const countdownTimerRef = useRef<any>(null); // 倒计时定时器引用 |
| | | const finishCountdownTimerRef = useRef<any>(null); // 结束倒计时定时器引用 |
| | | const trunkPollTimerRef = useRef<any>(null); // 后备箱轮询定时器引用 |
| | | const tempTimerRef = useRef<any>(null); // 温度定时器引用 |
| | | const lastConfirmedTempRef = useRef<number>(); // 上一次确认的温度 |
| | | const countdownFinishedRef = useRef(false); // 倒计时是否结束 |
| | |
| | | if (finishCountdownTimerRef.current) { |
| | | clearTimeout(finishCountdownTimerRef.current); |
| | | } |
| | | if (trunkPollTimerRef.current) { |
| | | clearTimeout(trunkPollTimerRef.current); |
| | | } |
| | | }; |
| | | }, [tripStatus, estimatedWaitMinutes, orderId, finishCountdownEnabled]); |
| | | |
| | |
| | | return () => { |
| | | if (tempTimerRef.current) { |
| | | clearTimeout(tempTimerRef.current); |
| | | } |
| | | if (trunkPollTimerRef.current) { |
| | | clearTimeout(trunkPollTimerRef.current); |
| | | } |
| | | }; |
| | | }, []); |
| | |
| | | return; |
| | | } |
| | | if (doorType === 'trunk') { |
| | | Taro.showToast({ |
| | | title: trunkStatus ? '关闭成功' : '打开成功', |
| | | icon: 'none' |
| | | }); |
| | | onSuccess?.(); |
| | | const loadingText = trunkStatus ? '正在关闭后备箱' : '正在开启后备箱'; |
| | | Taro.showLoading({ title: loadingText, mask: true }); |
| | | |
| | | let pollCount = 0; |
| | | const maxPolls = 3; |
| | | const pollInterval = 2000; // 2秒 |
| | | |
| | | const doPoll = () => { |
| | | queryVehicleTrunkOpenStatus({ orderId: targetOrderId }).then((pollRes: any) => { |
| | | const data = pollRes?.data ?? pollRes?.result ?? pollRes; |
| | | const value = data?.stateMap?.trunkAjarCloseSt?.value; |
| | | |
| | | if (value === '0' || value === '1') { |
| | | // 0: 关闭, 1: 开启 |
| | | const isOpen = value === '1'; |
| | | setTrunkStatus(isOpen); |
| | | Taro.hideLoading(); |
| | | Taro.showToast({ |
| | | title: isOpen ? '打开成功' : '关闭成功', |
| | | icon: 'none' |
| | | }); |
| | | onSuccess?.(); |
| | | } else { |
| | | // 继续轮询 |
| | | pollCount++; |
| | | if (pollCount < maxPolls) { |
| | | trunkPollTimerRef.current = setTimeout(doPoll, pollInterval); |
| | | } else { |
| | | Taro.hideLoading(); |
| | | Taro.showToast({ |
| | | title: trunkStatus ? '关闭后备箱失败' : '开启后备箱失败', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | } |
| | | }).catch(() => { |
| | | pollCount++; |
| | | if (pollCount < maxPolls) { |
| | | trunkPollTimerRef.current = setTimeout(doPoll, pollInterval); |
| | | } else { |
| | | Taro.hideLoading(); |
| | | Taro.showToast({ |
| | | title: trunkStatus ? '关闭后备箱失败' : '开启后备箱失败', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // 延迟2秒后开始第一次轮询 |
| | | trunkPollTimerRef.current = setTimeout(doPoll, pollInterval); |
| | | } |
| | | if (doorType === 'door') { |
| | | Taro.showToast({ |
| | |
| | | } |
| | | }).catch(() => { |
| | | Taro.showToast({ |
| | | title: res?.msg || '解锁失败,请重试或联系客服', |
| | | title: '解锁失败,请重试或联系客服', |
| | | icon: 'none' |
| | | }); |
| | | }); |
| | |
| | | { |
| | | tripStatus == 5 && |
| | | <View className="car-card-arrive"> |
| | | <View className={`car-card-arrive-item ${trunkStatus && 'close-btn-item'}`} onClick={() => handleUnlock('trunk', () => setTrunkStatus((prev) => !prev))}> |
| | | <View className={`car-card-arrive-item ${trunkStatus && 'close-btn-item'}`} onClick={() => handleUnlock('trunk')}> |
| | | { |
| | | trunkStatus ? |
| | | <Image className="car-card-arrive-item-img" src={require('../../../assets/trunk-open.png')} /> |
| | |
| | | <View className="car-card-reach-text">点击按钮开车门</View> |
| | | <Image className='car-card-reach-img' src='https://huishou-1323682843.cos.ap-nanjing.myqcloud.com/images/f4a18c3f-a2db-45e6-8967-1510355b5e3b.webp' /> |
| | | <View className="car-card-reach-btn"> |
| | | <View className={`car-card-reach-btn-item ${trunkStatus && 'close-btn-item'}`} onClick={() => handleUnlock('trunk', () => setTrunkStatus((prev) => !prev))}> |
| | | <View className={`car-card-reach-btn-item ${trunkStatus && 'close-btn-item'}`} onClick={() => handleUnlock('trunk')}> |
| | | { |
| | | trunkStatus ? |
| | | <Image className="car-card-reach-btn-item-img" src={require('../../../assets/trunk-open.png')} /> |