62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import {StaticImageData} from 'next/image'
|
|
import wechat from '@/components/composites/purchase/_assets/wechat.svg'
|
|
import alipay from '@/components/composites/purchase/_assets/alipay.svg'
|
|
import balance from '@/components/composites/purchase/_assets/balance.svg'
|
|
|
|
export function getTradeMethodDecoration(method: TradeMethod) {
|
|
switch (method) {
|
|
case TradeMethod.Alipay:
|
|
return {
|
|
text: '支付宝',
|
|
icon: alipay,
|
|
}
|
|
case TradeMethod.Wechat:
|
|
return {
|
|
text: '微信支付',
|
|
icon: wechat,
|
|
}
|
|
default:
|
|
return {
|
|
text: '扫码支付',
|
|
icon: balance,
|
|
}
|
|
}
|
|
}
|
|
|
|
// 支付方法枚举
|
|
export const TradeMethod = {
|
|
Alipay: 1,
|
|
Wechat: 2,
|
|
Sft: 3,
|
|
SftAlipay: 4,
|
|
SftWechat: 5,
|
|
} as const
|
|
|
|
// 平台枚举
|
|
export const TradePlatform = {
|
|
Desktop: 1,
|
|
Mobile: 2,
|
|
} as const
|
|
|
|
// 支付状态枚举
|
|
export const TradeStatus = {
|
|
Pending: 0,
|
|
Completed: 1,
|
|
Cancelled: 2, // 同步修改
|
|
Refunded: 3,
|
|
} as const
|
|
|
|
// 定义类型
|
|
export type TradeMethod = typeof TradeMethod[keyof typeof TradeMethod]
|
|
export type TradePlatform = typeof TradePlatform[keyof typeof TradePlatform]
|
|
export type TradeStatus = typeof TradeStatus[keyof typeof TradeStatus]
|
|
|
|
// 支付方法配置类型
|
|
export type PaymentMethodConfig = {
|
|
value: TradeMethod
|
|
decoration: {
|
|
icon: StaticImageData
|
|
text: string
|
|
}
|
|
}
|