摸大红支持购物车多选一起结账

下单支持多商品行快照与一次支付;支付后整单复制文案,前台提供购物车加购与结账。
This commit is contained in:
yml2213
2026-07-16 20:58:39 +08:00
parent e241607535
commit 183351a297
17 changed files with 1159 additions and 117 deletions
+27 -5
View File
@@ -34,6 +34,18 @@ export interface MohongProduct {
updated_at: string
}
export interface MohongOrderItem {
product_id: number
title: string
cover_url: string
unit: string
quantity: number
unit_price_cent: number
unit_price: string
amount_cent: number
amount: string
}
export interface MohongOrder {
id: number
order_no: string
@@ -48,6 +60,7 @@ export interface MohongOrder {
product_title: string
product_cover_url: string
product_unit: string
items?: MohongOrderItem[]
qrcode_url_snapshot: string
copy_text: string
buyer_nickname?: string
@@ -61,6 +74,11 @@ export interface MohongOrder {
updated_at: string
}
export interface MohongCheckoutItem {
product_id: number
quantity: number
}
export interface MohongConfig {
default_qrcode_url: string
order_copy_template: string
@@ -95,11 +113,15 @@ export async function fetchMohongProduct(id: number | string) {
return data.data
}
export async function createMohongOrder(productId: number, quantity: number) {
const { data } = await apiClient.post<ApiResponse<MohongOrder>>('/mohong/orders', {
product_id: productId,
quantity,
})
/** 单商品或购物车多商品结账 */
export async function createMohongOrder(
productIdOrItems: number | MohongCheckoutItem[],
quantity = 1
) {
const payload = Array.isArray(productIdOrItems)
? { items: productIdOrItems }
: { product_id: productIdOrItems, quantity }
const { data } = await apiClient.post<ApiResponse<MohongOrder>>('/mohong/orders', payload)
return data.data
}