更新了购买套餐里的充值和立即支付的传参,增加我的账单模块待支付链接跳转和弹窗

This commit is contained in:
Eamon-meng
2025-06-18 19:05:38 +08:00
parent 36b17f1bf2
commit ba7d22168d
9 changed files with 662 additions and 136 deletions

View File

@@ -14,6 +14,7 @@ import {Loader} from 'lucide-react'
import {useRouter} from 'next/navigation'
import * as qrcode from 'qrcode'
import {completeResource, createResource, prepareResource} from '@/actions/resource'
import {PaymentMethod, Platform, usePlatformType} from '@/lib/models/trade'
export type PayProps = {
method: 'alipay' | 'wechat' | 'balance'
@@ -24,7 +25,7 @@ export type PayProps = {
export default function Pay(props: PayProps) {
const profile = useProfileStore(store => store.profile)
const refreshProfile = useProfileStore(store => store.refreshProfile)
const platform = usePlatformType() // 获取当前平台类型
const [open, setOpen] = useState(false)
const [payInfo, setPayInfo] = useState<ExtraResp<typeof prepareResource> | undefined>()
const canvas = useRef<HTMLCanvasElement>(null)
@@ -44,15 +45,32 @@ export default function Pay(props: PayProps) {
return
}
// 根据平台类型设置支付方法
let paymentMethod: PaymentMethod
if (platform === Platform.Desktop) {
paymentMethod = PaymentMethod.Sft
}
else {
// 移动端根据选择的支付方式设置
paymentMethod = props.method === 'alipay'
? PaymentMethod.SftAlipay
: PaymentMethod.SftWeChat
}
const method = {
alipay: 1,
wechat: 2,
alipay: PaymentMethod.Alipay,
wechat: PaymentMethod.WeChat,
}[props.method]
const resp = await prepareResource({
const res = {
...props.resource,
method,
})
payment_method: paymentMethod,
payment_platform: platform, // 使用检测到的平台类型
}
console.log(res, 'reresp')
const resp = await prepareResource(res)
console.log(resp, 'resp')
if (!resp.success) {
toast.error(`创建订单失败: ${resp.message}`)
setOpen(false)