This commit is contained in:
Phoenix 2025-04-18 17:23:06 +08:00
parent f5a51ffa7c
commit 309760863a

View File

@ -9,11 +9,54 @@
import QRCode from 'qrcode';
import { ref } from 'vue';
import {authStore} from "~/stores/auth/index.js";
import {orderQuery} from "~/api/goods/index.js";
const {payment}= authStore()
definePageMeta({
i18n: 'payment.title'
})
const router=useRouter()
const resData=ref({})
let timer = null
const queryOrder = async () => {
try {
const res = await orderQuery({
orderNo: payment.value.payUid
})
if (res.status === 0) {
resData.value = res.data
//
if (resData.value.status === 1) {
clearInterval(timer)
router.push({
path: '/payment/result',
query:{
orderNo:payment.value.payUid
}
})
}
}
} catch (error) {
clearInterval(timer)
}
}
//
await queryOrder()
const qrCodeUrl=ref('')
//
timer = setInterval(async () => {
await queryOrder()
}, 1000)
//
onUnmounted(() => {
if (timer) {
clearInterval(timer)
closeToast()
}
})
async function generateQRCodeURL(text) {
try {
const url = await QRCode.toDataURL(text, {