fix(ticket): 修复配送地址超出范围提示问题

- 仅在用户允许修改门票配送地址时显示提示
- 避免在冷却窗口期间显示冗余提示
- 添加对地址修改限制状态的检查
- 更新 useEffect 依赖数组以包含地址修改限制状态
This commit is contained in:
2026-02-28 00:40:38 +08:00
parent 6f1e0a6a2b
commit 338dc421db

View File

@@ -878,6 +878,10 @@ const OrderConfirm = () => {
// When user changes the delivery address to an out-of-fence one, prompt immediately (once per address). // When user changes the delivery address to an out-of-fence one, prompt immediately (once per address).
const outOfRangePromptedAddressIdRef = useRef<number | undefined>(undefined) const outOfRangePromptedAddressIdRef = useRef<number | undefined>(undefined)
useEffect(() => { useEffect(() => {
// Only prompt when user is allowed to change the ticket delivery address.
// Otherwise this toast is noisy (they can't fix it within the cooldown window).
if (!ticketAddressModifyLimit.loaded) return
if (!ticketAddressModifyLimit.canModify) return
const id = address?.id const id = address?.id
if (!id) return if (!id) return
if (deliveryRangeCheckedAddressId !== id) return if (deliveryRangeCheckedAddressId !== id) return
@@ -885,7 +889,14 @@ const OrderConfirm = () => {
if (outOfRangePromptedAddressIdRef.current === id) return if (outOfRangePromptedAddressIdRef.current === id) return
outOfRangePromptedAddressIdRef.current = id outOfRangePromptedAddressIdRef.current = id
Taro.showToast({ title: addressHasCoords ? '该地址不在配送范围,请更换围栏内地址' : '该地址缺少定位,请在地址里选择地图定位后重试', icon: 'none' }) Taro.showToast({ title: addressHasCoords ? '该地址不在配送范围,请更换围栏内地址' : '该地址缺少定位,请在地址里选择地图定位后重试', icon: 'none' })
}, [address?.id, addressHasCoords, deliveryRangeCheckedAddressId, inDeliveryRange]) }, [
address?.id,
addressHasCoords,
deliveryRangeCheckedAddressId,
inDeliveryRange,
ticketAddressModifyLimit.loaded,
ticketAddressModifyLimit.canModify
])
// When tickets/stock change, clamp quantity into [0..maxQuantity]. // When tickets/stock change, clamp quantity into [0..maxQuantity].
useEffect(() => { useEffect(() => {