修复:图书详情和课程详情无数据问题

This commit is contained in:
2025-12-26 11:39:06 +08:00
parent 89e77864a3
commit e76e6da008
11 changed files with 459 additions and 409 deletions

View File

@@ -13,14 +13,11 @@
</view>
<!-- 课程信息 -->
<Skeleton theme="image-text" :request="getCourseDetail" @success="getCourseDetailSuccess">
<template #content>
<CourseInfo v-if="courseDetail" :course="courseDetail" :class="{'pt-10': !!vipTip}" />
</template>
</Skeleton>
<CourseInfo v-if="courseDetail" :course="courseDetail" :class="{'pt-10': !!vipTip}" />
<!-- 课程内容包装器 -->
<CatalogueList
v-if="catalogueList.length > 0"
:catalogues="catalogueList"
:userVip="userVip"
@toVip="goToVip"
@@ -180,29 +177,38 @@ const vipTip = computed(() => {
*/
onLoad(async (options: any) => {
courseId.value = parseInt(options.id)
loadPageData()
})
/**
* 页面显示
*/
onShow(async () => {
await loadPageData()
})
/**
* 加载页面数据
*/
const getCourseDetail = () => courseApi.getCourseDetail(courseId.value)
const getCourseDetailSuccess = async (res: any) => {
const loadPageData = async () => {
// 获取课程详情
const res = await courseApi.getCourseDetail(courseId.value)
if (res.code === 0 && res.data) {
courseDetail.value = res.data.course
catalogueList.value = res.data.catalogues || []
relatedBooks.value = res.data.shopProductList || []
// 计算学习进度
if (catalogueList.value.length > 0) {
const totalProgress = catalogueList.value.reduce((sum, cat) => sum + cat.completion, 0)
learningProgress.value = Number((totalProgress / catalogueList.value.length).toFixed(2))
}
}
}
const loadPageData = async () => {
// 检查VIP权益
await checkVipStatus()
// 加载评论
await loadComments()
}
/**
@@ -442,11 +448,11 @@ onPullDownRefresh(async () => {
/**
* 触底加载
*/
// onReachBottom(() => {
// if (hasMoreComments.value && !commentsLoading.value) {
// loadComments()
// }
// })
onReachBottom(() => {
if (hasMoreComments.value && !commentsLoading.value) {
loadComments()
}
})
</script>
<style lang="scss" scoped>