feat: 支付宝测试对接
This commit is contained in:
@@ -3,6 +3,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue';
|
||||
import { useBillingStore } from '@/store/modules/billing/billing';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { submitOrder } from '@/service/api/auth';
|
||||
import { aliPayPcPay } from '@/service/api/payment';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { Ref } from 'vue';
|
||||
defineOptions({
|
||||
@@ -102,6 +103,25 @@ const handleRecharge = async () => {
|
||||
console.error('Failed to submit recharge order:', error);
|
||||
}
|
||||
};
|
||||
// 测试:支付宝支付
|
||||
const handleAliPay = async () => {
|
||||
try {
|
||||
const orderRes = await submitOrder({
|
||||
type: 1,
|
||||
orderAmount: paymentAmount.value
|
||||
});
|
||||
const res = await aliPayPcPay({orderId: orderRes.data});
|
||||
console.log(res);
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = res; // html code
|
||||
document.body.appendChild(div);
|
||||
document.forms['punchout_form'].submit();
|
||||
|
||||
} catch (error) {
|
||||
message.error('充值失败,请重试!');
|
||||
console.error('Failed to submit recharge order:', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -158,6 +178,16 @@ const handleRecharge = async () => {
|
||||
>
|
||||
¥{{ paymentAmount.toFixed(2) }} {{ t('page.carddata.pay') }}
|
||||
</AButton>
|
||||
<!-- 测试:支付宝支付 -->
|
||||
<AButton
|
||||
type="primary"
|
||||
size="large"
|
||||
block
|
||||
:disabled="!paymentAmount || paymentAmount <= 0"
|
||||
@click="handleAliPay"
|
||||
>
|
||||
AliPay
|
||||
</AButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user