feat(mobile): 接入商品详情下单确认与协议

This commit is contained in:
yml2213
2026-10-30 13:50:08 +08:00
parent 52b6d439bf
commit 1f358a37c9
7 changed files with 354 additions and 8 deletions
+36
View File
@@ -5,6 +5,8 @@ import type { ApiResponse } from '@/shared/api/types'
import type {
CounterCheckoutPayload,
CreateDisputePayload,
OrderAgreements,
PostRentalNotice,
SubmitCheckoutPayload,
UserHandoffRecord,
UserOrderDetail,
@@ -54,6 +56,40 @@ export async function cancelMyOrder(id: number | string) {
await apiClient.post(`/orders/${id}/cancel`)
}
export async function createOrder(listingId: number | string) {
return unwrapData<{ id: number }>(
apiClient.post<ApiResponse<{ id: number }>>('/orders', { listing_id: Number(listingId) })
)
}
export function fetchOrderAgreements() {
return unwrapData<OrderAgreements>(
apiClient.get<ApiResponse<OrderAgreements>>('/order-agreements')
)
}
export function fetchPostRentalNotice() {
return unwrapData<PostRentalNotice>(
apiClient.get<ApiResponse<PostRentalNotice>>('/post-rental-notice')
)
}
export function useOrderAgreements() {
return useQuery({
queryKey: ['order-agreements'],
queryFn: fetchOrderAgreements,
staleTime: 5 * 60 * 1000,
})
}
export function usePostRentalNotice() {
return useQuery({
queryKey: ['post-rental-notice'],
queryFn: fetchPostRentalNotice,
staleTime: 5 * 60 * 1000,
})
}
export async function startOrderPayment(id: number | string, payWay: 'WXZF' | 'ZFBZF') {
return unwrapData<UserPayment>(
apiClient.post<ApiResponse<UserPayment>>(`/orders/${id}/start-payment`, {