优化完善套餐购买页面
This commit is contained in:
@@ -15,7 +15,6 @@ import {
|
||||
} from '@/lib/models/trade'
|
||||
import {PaymentModal} from '@/components/composites/payment/payment-modal'
|
||||
import {PaymentProps} from '@/components/composites/payment/type'
|
||||
import {usePlatformType} from '@/lib/hooks'
|
||||
|
||||
export type PayProps = {
|
||||
amount: string
|
||||
@@ -32,36 +31,35 @@ export default function Pay(props: PayProps) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [trade, setTrade] = useState<PaymentProps | null>(null)
|
||||
const router = useRouter()
|
||||
// const platform = usePlatformType()
|
||||
|
||||
const onOpen = async () => {
|
||||
setOpen(true)
|
||||
|
||||
if (props.method === 'balance') return
|
||||
if (props.method === 'balance') {
|
||||
return
|
||||
}
|
||||
|
||||
const method = props.method === 'alipay'
|
||||
? TradeMethod.SftAlipay
|
||||
: TradeMethod.SftWechat
|
||||
const req = {
|
||||
const response = await prepareResource({
|
||||
...props.resource,
|
||||
payment_method: method,
|
||||
payment_platform: TradePlatform.Desktop,
|
||||
}
|
||||
})
|
||||
|
||||
const resp = await prepareResource(req)
|
||||
|
||||
if (!resp.success) {
|
||||
toast.error(`创建订单失败: ${resp.message}`)
|
||||
if (!response.success) {
|
||||
toast.error(`创建订单失败: ${response.message}`)
|
||||
setOpen(false)
|
||||
return
|
||||
}
|
||||
|
||||
setTrade({
|
||||
inner_no: resp.data.trade_no,
|
||||
pay_url: resp.data.pay_url,
|
||||
inner_no: response.data.trade_no,
|
||||
pay_url: response.data.pay_url,
|
||||
amount: Number(props.amount),
|
||||
platform: TradePlatform.Desktop,
|
||||
method: method,
|
||||
method,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -112,7 +110,6 @@ export default function Pay(props: PayProps) {
|
||||
立即支付
|
||||
</Button>
|
||||
|
||||
{/* 余额支付对话框 */}
|
||||
{props.method === 'balance' && (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogContent>
|
||||
@@ -178,7 +175,6 @@ export default function Pay(props: PayProps) {
|
||||
</Dialog>
|
||||
)}
|
||||
|
||||
{/* 支付宝/微信支付 */}
|
||||
{props.method !== 'balance' && trade && (
|
||||
<PaymentModal
|
||||
{...trade}
|
||||
|
||||
Reference in New Issue
Block a user