feat(mall): live group-buying page with open or join intent
The group-buying page lists active activities, the group price against the catalog price, and each open group with its paid-member count and expiry. A shopper opens a group or picks one to join; either way the activity SKU goes into the cart and the intent is carried to checkout, which submits it and hides the coupon picker for that order. Payment and order detail show the snapshotted group price. The group-buying fixtures leave the page; the fixed-data adapter still serves the domain as the rollback path.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { t as pick } from "@vmall/shared";
|
||||
import type { Address, AddressBookEntry, CartItem, Coupon, LocalizedText } from "@vmall/shared";
|
||||
import type { Address, AddressBookEntry, CartItem, Coupon, GroupBuyIntent, LocalizedText } from "@vmall/shared";
|
||||
|
||||
type CheckoutGroup = {
|
||||
shopId: string;
|
||||
@@ -16,6 +16,8 @@ const { currency } = usePrefs();
|
||||
const cartStore = useCartStore();
|
||||
const router = useRouter();
|
||||
const pendingOrderIds = useState<string[]>("checkout-orders", () => []);
|
||||
/** Group-buying intent chosen on the group-buying page, if any. */
|
||||
const groupIntent = useState<GroupBuyIntent | null>("checkout-group-intent", () => null);
|
||||
|
||||
const items = ref<CartItem[]>([]);
|
||||
const addresses = ref<AddressBookEntry[]>([]);
|
||||
@@ -140,7 +142,13 @@ async function submitOrder(): Promise<void> {
|
||||
for (const [shopId, couponId] of Object.entries(selectedCoupon)) {
|
||||
if (couponId) couponByShop[shopId] = couponId;
|
||||
}
|
||||
const orders = await $api.checkout(address, currency.value, couponByShop);
|
||||
const orders = await $api.checkout(
|
||||
address,
|
||||
currency.value,
|
||||
couponByShop,
|
||||
groupIntent.value ?? undefined,
|
||||
);
|
||||
groupIntent.value = null;
|
||||
pendingOrderIds.value = orders.map((order) => order.id);
|
||||
const snapshot = await $api.getCart();
|
||||
items.value = snapshot.items;
|
||||
@@ -216,7 +224,7 @@ onMounted(() => void loadCart());
|
||||
<PriceText :amount-minor="item.unit_price_minor * item.qty" :currency="item.currency" />
|
||||
</strong>
|
||||
</div>
|
||||
<div v-if="couponsForShop(group.shopId).length > 0" class="coupon-picker">
|
||||
<div v-if="!groupIntent && couponsForShop(group.shopId).length > 0" class="coupon-picker">
|
||||
<span class="coupon-label">{{ t("checkout.coupon") }}</span>
|
||||
<select v-model="selectedCoupon[group.shopId]" class="minput coupon-select">
|
||||
<option value="">{{ t("checkout.noCoupon") }}</option>
|
||||
|
||||
Reference in New Issue
Block a user