feat(auth): implement OTP login flow with toast notifications
feat(content): enhance detail view with dynamic content and comments feat(order): add polling for payment status in the payment view feat(user): update dashboard to display wallet and recent orders feat(user): improve orders view with dynamic order fetching and status mapping feat(api): create API modules for auth, content, order, user, and common functionalities refactor(request): implement a centralized request utility for API calls
This commit is contained in:
@@ -103,12 +103,13 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { orderApi } from '../../api/order';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const orderId = route.params.id || '82934712';
|
||||
const amount = '9.90';
|
||||
const amount = '9.90'; // Should fetch order details first
|
||||
const productName = '《霸王别姬》全本实录珍藏版';
|
||||
|
||||
const paymentMethod = ref('wechat');
|
||||
@@ -116,6 +117,7 @@ const timeLeft = ref(900); // 15 minutes
|
||||
const isScanning = ref(false);
|
||||
const isSuccess = ref(false);
|
||||
let timer = null;
|
||||
let pollTimer = null;
|
||||
|
||||
const paymentMethodName = computed(() => {
|
||||
return paymentMethod.value === 'wechat' ? '微信' : '支付宝';
|
||||
@@ -142,9 +144,25 @@ onMounted(() => {
|
||||
timer = setInterval(() => {
|
||||
if (timeLeft.value > 0) timeLeft.value--;
|
||||
}, 1000);
|
||||
|
||||
// Poll Status
|
||||
pollTimer = setInterval(async () => {
|
||||
try {
|
||||
const res = await orderApi.status(orderId);
|
||||
if (res.status === 'paid' || res.status === 'completed') {
|
||||
isScanning.value = false;
|
||||
isSuccess.value = true;
|
||||
clearInterval(pollTimer);
|
||||
setTimeout(() => router.replace(`/me/orders/${orderId}`), 1500);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Poll status failed', e);
|
||||
}
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer) clearInterval(timer);
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user