refactor(tickets): 前端适配门票一次一单API
- createTicketOrder 去掉 quantity 参数 - toTicketOrder 去掉 quantity 映射 - 购票页循环创建 N 笔独立订单,提示逐笔支付
This commit is contained in:
@@ -33,8 +33,7 @@ const toTicketAccount = (backendAccount = {}) => ({
|
|||||||
|
|
||||||
const toTicketOrder = (backendData = {}) => ({
|
const toTicketOrder = (backendData = {}) => ({
|
||||||
order: toOrderBrief(backendData.order),
|
order: toOrderBrief(backendData.order),
|
||||||
product: toTicketProduct(backendData.product),
|
product: toTicketProduct(backendData.product)
|
||||||
quantity: toNumber(backendData.quantity)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const ticketApi = {
|
export const ticketApi = {
|
||||||
@@ -49,11 +48,10 @@ export const ticketApi = {
|
|||||||
data: toPageQuery(params)
|
data: toPageQuery(params)
|
||||||
}).then(toTicketAccount)
|
}).then(toTicketAccount)
|
||||||
},
|
},
|
||||||
createTicketOrder(quantity) {
|
createTicketOrder() {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/tickets/orders',
|
url: '/api/tickets/orders',
|
||||||
method: 'POST',
|
method: 'POST'
|
||||||
data: { quantity }
|
|
||||||
}).then(toTicketOrder)
|
}).then(toTicketOrder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,15 @@ const submit = async () => {
|
|||||||
if (isSubmitting.value || !product.value?.is_active) return
|
if (isSubmitting.value || !product.value?.is_active) return
|
||||||
isSubmitting.value = true
|
isSubmitting.value = true
|
||||||
try {
|
try {
|
||||||
const data = await ticketApi.createTicketOrder(quantity.value)
|
const orderIds = []
|
||||||
uni.navigateTo({ url: `/pages/comprehensive/pay/index?order_id=${data.order.id}` })
|
for (let i = 0; i < quantity.value; i++) {
|
||||||
|
const data = await ticketApi.createTicketOrder()
|
||||||
|
orderIds.push(data.order.id)
|
||||||
|
}
|
||||||
|
if (orderIds.length > 1) {
|
||||||
|
uni.showToast({ title: `已创建${orderIds.length}笔订单,请逐笔完成支付`, icon: 'none', duration: 2000 })
|
||||||
|
}
|
||||||
|
uni.navigateTo({ url: `/pages/comprehensive/pay/index?order_id=${orderIds[0]}` })
|
||||||
} finally {
|
} finally {
|
||||||
isSubmitting.value = false
|
isSubmitting.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user