更新:1.课程详情增加骨架屏;2.图书首页和图书详情增加骨架屏;

This commit is contained in:
2025-12-11 16:13:40 +08:00
parent b3d9b0c100
commit b8dd0584aa
27 changed files with 897 additions and 649 deletions

View File

@@ -13,11 +13,14 @@
</view>
<!-- 课程信息 -->
<CourseInfo v-if="courseDetail" :course="courseDetail" :class="{'pt-10': !!vipTip}" />
<Skeleton theme="image-text" :request="getCourseDetail" @success="getCourseDetailSuccess">
<template #content>
<CourseInfo v-if="courseDetail" :course="courseDetail" :class="{'pt-10': !!vipTip}" />
</template>
</Skeleton>
<!-- 课程内容包装器 -->
<CatalogueList
v-if="catalogueList.length > 0"
:catalogues="catalogueList"
:userVip="userVip"
@toVip="goToVip"
@@ -177,38 +180,29 @@ const vipTip = computed(() => {
*/
onLoad(async (options: any) => {
courseId.value = parseInt(options.id)
})
/**
* 页面显示
*/
onShow(async () => {
await loadPageData()
loadPageData()
})
/**
* 加载页面数据
*/
const loadPageData = async () => {
// 获取课程详情
const res = await courseApi.getCourseDetail(courseId.value)
const getCourseDetail = () => courseApi.getCourseDetail(courseId.value)
const getCourseDetailSuccess = async (res: any) => {
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()
}
/**
@@ -448,11 +442,11 @@ onPullDownRefresh(async () => {
/**
* 触底加载
*/
onReachBottom(() => {
if (hasMoreComments.value && !commentsLoading.value) {
loadComments()
}
})
// onReachBottom(() => {
// if (hasMoreComments.value && !commentsLoading.value) {
// loadComments()
// }
// })
</script>
<style lang="scss" scoped>