diff --git a/apps/mall/pages/checkout/index.vue b/apps/mall/pages/checkout/index.vue index 5698fb1..4729584 100644 --- a/apps/mall/pages/checkout/index.vue +++ b/apps/mall/pages/checkout/index.vue @@ -117,6 +117,11 @@ async function loadCart(): Promise { items.value = snapshot.items; addresses.value = list; coupons.value = couponList; + // A stashed group intent only applies while its SKU is still in the cart. + const intent = groupIntent.value; + if (intent && !items.value.some((item) => item.sku_id === intent.sku_id)) { + groupIntent.value = null; + } selectedAddressId.value = list.find((address) => address.is_default)?.id ?? list[0]?.id ?? ""; if (items.value.length === 0) { @@ -162,6 +167,12 @@ async function submitOrder(): Promise { } onMounted(() => void loadCart()); + +// Leaving without submitting must not reprice a later order: the intent is +// consumed by a successful submit, which clears it before navigating to pay. +onBeforeUnmount(() => { + groupIntent.value = null; +});