feat: 支持商品管理

This commit is contained in:
richarjiang
2026-09-16 22:49:47 +08:00
parent 58c6d2092a
commit 95b9f6511c
30 changed files with 2800 additions and 5 deletions

View File

@@ -0,0 +1,32 @@
import type { ShopOrderStatus, PaymentParams } from '@mp-pilates/shared'
import { post } from './request'
export const shopMoney = (fen: number) => (fen / 100).toFixed(2)
export const shopStatus: Record<ShopOrderStatus, string> = {
PENDING: '待付款',
PAID: '待到馆取货',
COMPLETED: '已取货',
CANCELLED: '已取消',
}
export const shopError = (error: unknown) =>
uni.showToast({
title: error instanceof Error ? error.message : '操作失败,请重试',
icon: 'none',
})
export async function payShopOrder(id: string) {
const params = await post<PaymentParams>(`/shop/orders/${id}/pay`)
await new Promise<void>((resolve, reject) =>
uni.requestPayment({
...params,
provider: 'wxpay',
success: () => resolve(),
fail: (error) =>
reject(
new Error(
error.errMsg.includes('cancel')
? '已取消支付,可在订单中继续付款'
: '支付未完成,请刷新订单确认状态',
),
),
}),
)
}