From 4d8062f1769973a6b95effd7089068361404a0ef Mon Sep 17 00:00:00 2001 From: Zhang Chengdong Date: Fri, 18 Sep 2026 13:44:02 +0000 Subject: [PATCH] fix(mall): normalise group quantity and drop abandoned intents Opening or joining a group now sets the activity SKU to quantity 1 instead of accumulating, so a retry after a failed checkout - or a second click - can no longer push the line to quantity 2 and then fail the quantity-1 intent with an opaque error. The stashed group intent is cleared when the checkout page unmounts without submitting, and when its SKU is no longer in the cart, so an abandoned intent cannot silently reprice a later order or keep the coupon picker hidden. --- apps/mall/pages/checkout/index.vue | 11 +++++++++++ apps/mall/pages/collective.vue | 3 +++ 2 files changed, 14 insertions(+) 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; +});