功能完善
This commit is contained in:
@@ -118,9 +118,8 @@ import { OrderBean } from '@/api/order/types';
|
||||
import { parseParameter, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { useUserStore } from '@/store';
|
||||
import { handlePayResult, isPending } from '@/utils/order';
|
||||
import { getOrderDeadline, handlePayResult, isPending } from '@/utils/order';
|
||||
import dayjs from 'dayjs';
|
||||
import { pay } from '@/api/groupbuy';
|
||||
|
||||
const userState = useUserStore();
|
||||
const { terminalInfo } = storeToRefs(userState);
|
||||
@@ -134,12 +133,16 @@ const orderBean = ref<{
|
||||
let currentInterval = 0;
|
||||
|
||||
onLoad(async (e: any) => {
|
||||
await uni.showLoading();
|
||||
orderBean.value = await getOrderDetail(e.orderId);
|
||||
await fetchData(e.orderId);
|
||||
handleCountdown();
|
||||
uni.hideLoading();
|
||||
});
|
||||
|
||||
const fetchData = async (orderId: string) => {
|
||||
await uni.showLoading();
|
||||
orderBean.value = await getOrderDetail(orderId);
|
||||
uni.hideLoading();
|
||||
};
|
||||
|
||||
onUnload(() => {
|
||||
clearInterval(currentInterval);
|
||||
});
|
||||
@@ -161,29 +164,28 @@ const buildSqbParams = computed(() => {
|
||||
});
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
console.log('--------------_>>>>>>navigateTo ', e);
|
||||
handlePayResult(orderBean.value?.order.id, e, {
|
||||
onSuccess: () => {
|
||||
// pay({
|
||||
// 'orderId': orderBean.value?.order.id,
|
||||
// 'result': 'xxx'
|
||||
// });
|
||||
fetchData(orderBean.value?.order.id || '');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleCountdown = () => {
|
||||
clearInterval(currentInterval);
|
||||
let second = 30 * 60;
|
||||
currentInterval = setInterval(() => {
|
||||
if(isPending(orderBean.value?.order)) {
|
||||
orderBean.value!.order!.countdown = second;
|
||||
if(orderBean.value!.order!.countdown <= 0) {
|
||||
orderBean.value!.order!.countdown = 0;
|
||||
if(orderBean.value != undefined) {
|
||||
if(isPending(orderBean.value?.order)) {
|
||||
let second = (getOrderDeadline(orderBean.value?.order) - Date.now()) / 1000;
|
||||
orderBean.value.order.countdown = second;
|
||||
if(second <= 0) {
|
||||
fetchData(orderBean.value?.order.id || '');
|
||||
}
|
||||
second--;
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
clearInterval(currentInterval);
|
||||
fetchData(orderBean.value?.order.id || '');
|
||||
}
|
||||
second--;
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
Reference in New Issue
Block a user