2
0

feat: 微信支付

This commit is contained in:
caiyuchao
2025-01-20 17:04:18 +08:00
parent 83d820cbce
commit 107ff2dfbb
7 changed files with 129 additions and 16 deletions

View File

@@ -0,0 +1,48 @@
<script setup lang="ts">
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { useRoute } from 'vue-router';
import { useRouterPush } from '@/hooks/common/router';
import { doGetOrderInfo } from '@/service/api/order';
const route = useRoute();
const { routerPushByKey } = useRouterPush();
const qrCodeImg = ref<string>(route.query.url);
const orderId = ref<number>(route.query.orderId);
let orderStatusInterval = ref<number | null>(null);
// 设置订单状态轮询定时器
const setOrderStatusInterval = () => {
orderStatusInterval = setInterval(async () => {
let res = await doGetOrderInfo(orderId.value);
if (res.data.status == 1) {
routerPushByKey('home')
}
}, 2000)
};
onMounted(() => {
setOrderStatusInterval();
});
onUnmounted(() => {
clearInterval(orderStatusInterval)
});
</script>
<template>
<div class="weChat__card--div">
<a-card class="weChat__card" :bordered="false">
<template #title>
<span class="title__span">微信支付</span>
</template>
<div class="weChat__card__content">
<p>
<img :src="qrCodeImg" class="weChat__card_qrCodeImg" />
</p>
<div class="bottomContent">
<span class="weChat__card_span">使用微信扫码支付</span>
</div>
</div>
</a-card>
</div>
</template>