Compare commits
No commits in common. "309760863ab7aeaf096a0affd154df39e5c4dccd" and "17a32a89de08e4389d23a7737e87dfdbf359e796" have entirely different histories.
309760863a
...
17a32a89de
@ -9,54 +9,11 @@
|
||||
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, {
|
||||
|
@ -54,7 +54,8 @@
|
||||
"sass-loader": "^16.0.4",
|
||||
"sharp": "^0.33.5",
|
||||
"typescript": "~5.7.2",
|
||||
"vant": "^4.9.15"
|
||||
"vant": "^4.9.15",
|
||||
"vite-plugin-imagemin": "^0.6.1"
|
||||
},
|
||||
"pnpm": {
|
||||
"peerDependencyRules": {
|
||||
|
@ -24,7 +24,7 @@ export default defineConfig({
|
||||
],
|
||||
shortcuts: [
|
||||
// shortcuts to multiple utilities
|
||||
['btn', 'px-6 py-3 rounded-3 inline-block bg-primary text-white cursor-pointer disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
|
||||
['btn', 'px-6 py-3 rounded-3 inline-block bg-primary text-white cursor-pointer hover:bg-primary-hover disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
|
||||
],
|
||||
|
||||
presets: [
|
||||
|
Loading…
Reference in New Issue
Block a user