提交 d9af39bc authored 作者: matian's avatar matian

获取课程接口延迟请求

上级 2b12a212
......@@ -18,9 +18,10 @@ const { mobile } = useDevice()
const router = useRouter()
const route = useRoute()
const buyDialogVisible = ref(false)
let disabledTime = $ref(10)
const orderId = useStorage('order_detail_id', route.query.order_detail_id)
const order = ref<Order>()
let timer:number
async function getOrder() {
getOrderList({ order_detail_id: orderId.value })
.then(res => {
......@@ -28,7 +29,13 @@ async function getOrder() {
if (order.value?.order_status === '4') {
// 支付成功
// 刷新已购买的课程列表
useUserStore().getCourse()
timer = setInterval(() => {
disabledTime--
if (disabledTime <= 0) {
useUserStore().getCourse()
clearTimer()
}
}, 1000)
} else {
// 未支付,返回支付页面
router.replace(`/shop/pay/${props.id}`)
......@@ -38,14 +45,22 @@ async function getOrder() {
router.replace(`/shop/pay/${props.id}`)
})
}
const clearTimer = () => {
timer && clearInterval(timer)
}
onMounted(() => {
getOrder()
})
onUnmounted(() => {
clearTimer()
})
const start_time = getDateTime(0)
const end_time = getDateTime(90)
const handleStudy = () => {
console.log(shopItem?.is_new === true)
if (shopItem?.is_new === true) {
buyDialogVisible.value = true
} else {
......
......@@ -20,22 +20,18 @@ const handleDatail = (item: any) => {
})
}
const handleBuy = (courseItem: any) => {
if (user.isLogin) {
if (courseItem?.isBuy === true) {
if (courseItem?.is_new === true) {
buyDialogVisible.value = true
} else {
window.open('https://fi-learning.ezijing.com')
}
if (courseItem?.isBuy === true) {
if (courseItem?.is_new === true) {
buyDialogVisible.value = true
} else {
if (courseItem?.is_free === true) {
buyDialogVisible.value = true
} else {
router.push(`/shop/pay/${courseItem.id}`)
}
window.open('https://fi-learning.ezijing.com')
}
} else {
window.location.href = `${import.meta.env.VITE_LOGIN_URL}?rd=${encodeURIComponent(location.href)}`
if (courseItem?.is_free === true) {
buyDialogVisible.value = true
} else {
router.push(`/shop/pay/${courseItem.id}`)
}
}
}
</script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论