修复:内测问题修改:免费课程及课程详情代码优化、积分支付默认值、书籍价格显示
This commit is contained in:
@@ -16,40 +16,23 @@
|
||||
<CourseInfo v-if="courseDetail" :course="courseDetail" :class="{'pt-10': !!vipTip}" />
|
||||
|
||||
<!-- 课程内容包装器 -->
|
||||
<view class="course-content-wrapper">
|
||||
<!-- 目录列表 -->
|
||||
<CatalogueList
|
||||
v-if="catalogueList.length > 0"
|
||||
:catalogues="catalogueList"
|
||||
:currentIndex="currentCatalogueIndex"
|
||||
:userVip="userVip"
|
||||
@change="handleCatalogueChange"
|
||||
/>
|
||||
|
||||
<!-- 章节列表 -->
|
||||
<ChapterList
|
||||
v-if="chapterList.length > 0"
|
||||
:chapters="chapterList"
|
||||
:catalogue="currentCatalogue"
|
||||
:userVip="userVip"
|
||||
:showRenewBtn="showRenewBtn"
|
||||
@purchase="handlePurchase"
|
||||
@toVip="goToVip"
|
||||
@renew="handleRenew"
|
||||
@click="handleChapterClick"
|
||||
/>
|
||||
</view>
|
||||
<CatalogueList
|
||||
v-if="catalogueList.length > 0"
|
||||
:catalogues="catalogueList"
|
||||
:userVip="userVip"
|
||||
@getFreeCourse="handleGetFreeCourse"
|
||||
@purchase="handlePurchase"
|
||||
@toVip="goToVip"
|
||||
@renew="handleRenew"
|
||||
@toDetail="handleToDetail"
|
||||
/>
|
||||
|
||||
<!-- 学习进度 -->
|
||||
<view class="learning-progress">
|
||||
<view class="progress-title">
|
||||
<text>{{ $t('courseDetails.progress') }}</text>
|
||||
</view>
|
||||
<wd-progress
|
||||
:percentage="learningProgress"
|
||||
show-text
|
||||
stroke-width="6"
|
||||
/>
|
||||
<wd-progress :percentage="learningProgress" show-text stroke-width="6" />
|
||||
</view>
|
||||
|
||||
<!-- 相关书籍 -->
|
||||
@@ -166,30 +149,24 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom, onShow } from '@dcloudio/uni-app'
|
||||
import { useCourseStore } from '@/stores/course'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { courseApi } from '@/api/modules/course'
|
||||
import CourseInfo from '@/components/course/CourseInfo.vue'
|
||||
import CatalogueList from '@/components/course/CatalogueList.vue'
|
||||
import ChapterList from '@/components/course/ChapterList.vue'
|
||||
import CourseInfo from './components/CourseInfo.vue'
|
||||
import CatalogueList from './components/CatalogueList.vue'
|
||||
import GoodsSelector from '@/components/order/GoodsSelector.vue'
|
||||
import CommentList from '@/components/comment/CommentList.vue'
|
||||
import CommentEditor from '@/components/comment/CommentEditor.vue'
|
||||
import NavBar from '@/components/nav-bar/nav-bar.vue'
|
||||
import type { ICourseDetail, ICatalogue, IChapter, IVipInfo } from '@/types/course'
|
||||
import type { IGoods } from '@/types/order'
|
||||
import type { IComment } from '@/types/comment'
|
||||
|
||||
// Stores
|
||||
const courseStore = useCourseStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 页面数据
|
||||
const courseId = ref<number>(0)
|
||||
const courseDetail = ref<ICourseDetail | null>(null)
|
||||
const catalogueList = ref<ICatalogue[]>([])
|
||||
const currentCatalogueIndex = ref(0)
|
||||
const chapterList = ref<IChapter[]>([])
|
||||
const userVip = ref<IVipInfo | null>(null)
|
||||
const vipModuleList = ref<string[]>([])
|
||||
const learningProgress = ref(0)
|
||||
@@ -202,7 +179,6 @@ const selectedGoods = ref<IGoods | null>(null)
|
||||
const showProtocol = ref(false)
|
||||
const isFudu = ref(false)
|
||||
const fuduCatalogueId = ref<number>(0)
|
||||
const showRenewBtn = ref(false)
|
||||
|
||||
// 评论相关
|
||||
const commentList = ref<IComment[]>([])
|
||||
@@ -215,14 +191,6 @@ const replyComment = ref<IComment | undefined>(undefined)
|
||||
// UI状态
|
||||
const scrollTop = ref(0)
|
||||
|
||||
/**
|
||||
* 当前目录
|
||||
*/
|
||||
const currentCatalogue = computed(() => {
|
||||
if (catalogueList.value.length === 0) return null
|
||||
return catalogueList.value[currentCatalogueIndex.value] || null
|
||||
})
|
||||
|
||||
/**
|
||||
* VIP提示文案
|
||||
*/
|
||||
@@ -286,11 +254,6 @@ const loadPageData = async () => {
|
||||
const totalProgress = catalogueList.value.reduce((sum, cat) => sum + cat.completion, 0)
|
||||
learningProgress.value = Number((totalProgress / catalogueList.value.length).toFixed(2))
|
||||
}
|
||||
|
||||
// 默认选择第一个目录
|
||||
if (catalogueList.value.length > 0) {
|
||||
await switchCatalogue(0)
|
||||
}
|
||||
}
|
||||
|
||||
// 检查VIP权益
|
||||
@@ -318,69 +281,50 @@ const checkVipStatus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换目录
|
||||
*/
|
||||
const switchCatalogue = async (index: number) => {
|
||||
currentCatalogueIndex.value = index
|
||||
const catalogue = catalogueList.value[index]
|
||||
|
||||
// 获取章节列表
|
||||
const res = await courseApi.getCatalogueChapterList(catalogue.id)
|
||||
if (res.code === 0) {
|
||||
chapterList.value = res.chapterList || []
|
||||
}
|
||||
|
||||
// 检查是否支持复读
|
||||
if (catalogue.isBuy === 0 && !userVip.value) {
|
||||
const renewRes = await courseApi.checkRenewPayment(catalogue.id)
|
||||
showRenewBtn.value = renewRes.canRelearn || false
|
||||
} else {
|
||||
showRenewBtn.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录切换事件
|
||||
*/
|
||||
const handleCatalogueChange = (index: number) => {
|
||||
switchCatalogue(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击章节
|
||||
*/
|
||||
const handleChapterClick = (chapter: IChapter) => {
|
||||
const noRecored = chapter.isAudition === 1 && currentCatalogue.value?.isBuy === 0 && !userVip.value
|
||||
const handleToDetail = (chapter: IChapter, catalogue: ICatalogue) => {
|
||||
const noRecored = chapter.isAudition === 1 && catalogue.isBuy === 0 && !userVip.value
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/course/details/chapter?id=${chapter.id}&courseId=${courseId.value}&courseTitle=${courseDetail.value?.title}&title=${chapter.title}&noRecored=${noRecored}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 去开通vip
|
||||
*/
|
||||
const goToVip = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/vip/course'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取免费课程
|
||||
*/
|
||||
const handleGetFreeCourse = async () => {
|
||||
if (!currentCatalogue.value) return
|
||||
const handleGetFreeCourse = async (catalogue: ICatalogue) => {
|
||||
if (!catalogue) return
|
||||
|
||||
uni.showLoading({ title: '领取中...' })
|
||||
const res = await courseApi.startStudyForMF(currentCatalogue.value.id)
|
||||
const res = await courseApi.startStudyForMF(catalogue.id)
|
||||
if (res.code === 0) {
|
||||
uni.showToast({ title: '领取成功', icon: 'success' })
|
||||
// 刷新页面数据
|
||||
await loadPageData()
|
||||
loadPageData()
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '领取失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购买课程
|
||||
*/
|
||||
const handlePurchase = async () => {
|
||||
if (!currentCatalogue.value) return
|
||||
const handlePurchase = async (catalogue: ICatalogue) => {
|
||||
if (!catalogue) return
|
||||
|
||||
isFudu.value = false
|
||||
const res = await courseApi.getProductListForCourse(currentCatalogue.value.id)
|
||||
const res = await courseApi.getProductListForCourse(catalogue.id)
|
||||
if (res.code === 0 && res.productList.length > 0) {
|
||||
goodsList.value = res.productList
|
||||
showGoodsSelector.value = true
|
||||
@@ -393,17 +337,17 @@ const handlePurchase = async () => {
|
||||
* 续费/复读
|
||||
*/
|
||||
const handleRenew = async () => {
|
||||
if (!currentCatalogue.value) return
|
||||
// if (!currentCatalogue.value) return
|
||||
|
||||
isFudu.value = true
|
||||
fuduCatalogueId.value = currentCatalogue.value.id
|
||||
const res = await courseApi.getRenewProductList(currentCatalogue.value.id)
|
||||
if (res.code === 0 && res.productList.length > 0) {
|
||||
goodsList.value = res.productList
|
||||
showGoodsSelector.value = true
|
||||
} else {
|
||||
uni.showToast({ title: '暂无复读方案', icon: 'none' })
|
||||
}
|
||||
// isFudu.value = true
|
||||
// fuduCatalogueId.value = currentCatalogue.value.id
|
||||
// const res = await courseApi.getRenewProductList(currentCatalogue.value.id)
|
||||
// if (res.code === 0 && res.productList.length > 0) {
|
||||
// goodsList.value = res.productList
|
||||
// showGoodsSelector.value = true
|
||||
// } else {
|
||||
// uni.showToast({ title: '暂无复读方案', icon: 'none' })
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,15 +387,6 @@ const confirmPurchase = () => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到VIP页面
|
||||
*/
|
||||
const goToVip = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/vip/course'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到书籍详情
|
||||
*/
|
||||
@@ -698,10 +633,6 @@ onReachBottom(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.course-content-wrapper {
|
||||
background: linear-gradient(108deg, #c3e7ff 0%, #59bafe 100%);
|
||||
}
|
||||
|
||||
.learning-progress {
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
|
||||
Reference in New Issue
Block a user