feat: 微信支付
This commit is contained in:
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { submitOrder } from '@/service/api/auth';
|
||||
import { aliPayPcPay } from '@/service/api/payment';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useRouterPush } from '@/hooks/common/router';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
defineOptions({
|
||||
@@ -11,6 +12,7 @@ defineOptions({
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const { routerPushByKey } = useRouterPush();
|
||||
|
||||
interface RechargeOption {
|
||||
amount: number;
|
||||
@@ -116,6 +118,21 @@ const handleAliPay = async () => {
|
||||
console.error('Failed to submit recharge order:', error);
|
||||
}
|
||||
};
|
||||
// 微信支付
|
||||
const handleWxPay = async () => {
|
||||
try {
|
||||
const orderRes = await submitOrder({
|
||||
type: 1,
|
||||
orderAmount: paymentAmount.value
|
||||
});
|
||||
const res = await wxPayScanCode({orderId: orderRes.data});
|
||||
routerPushByKey('billing_wxpay', { query: { url: res.data, orderId: orderRes.data } })
|
||||
|
||||
} catch (error) {
|
||||
message.error('充值失败,请重试!');
|
||||
console.error('Failed to submit recharge order:', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -169,15 +186,25 @@ const handleAliPay = async () => {
|
||||
¥{{ paymentAmount.toFixed(2) }} {{ t('page.carddata.pay') }}
|
||||
</AButton>
|
||||
<!-- 测试:支付宝支付 -->
|
||||
<!-- <AButton-->
|
||||
<!-- type="primary"-->
|
||||
<!-- size="large"-->
|
||||
<!-- block-->
|
||||
<!-- :disabled="!paymentAmount || paymentAmount <= 0"-->
|
||||
<!-- @click="handleAliPay"-->
|
||||
<!-- >-->
|
||||
<!-- AliPay-->
|
||||
<!-- </AButton>-->
|
||||
<AButton
|
||||
type="primary"
|
||||
size="large"
|
||||
block
|
||||
:disabled="!paymentAmount || paymentAmount <= 0"
|
||||
@click="handleAliPay"
|
||||
>
|
||||
AliPay
|
||||
</AButton>
|
||||
<!-- 测试:微信支付 -->
|
||||
<AButton
|
||||
type="primary"
|
||||
size="large"
|
||||
block
|
||||
:disabled="!paymentAmount || paymentAmount <= 0"
|
||||
@click="handleWxPay"
|
||||
>
|
||||
WxPay
|
||||
</AButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user