提交 f4f61766 authored 作者: lhh's avatar lhh

第二版迭代

上级 4604ca2a
...@@ -23,6 +23,7 @@ const secondsToHms = function (d: any) { ...@@ -23,6 +23,7 @@ const secondsToHms = function (d: any) {
} }
const handleChapter = function (item: any, cItem: any) { const handleChapter = function (item: any, cItem: any) {
if (props.isFree === '已过期') return
if (route.path === '/course/detail') { if (route.path === '/course/detail') {
router.push(`/course/chapter?id=${route.query?.id}&chapterId=${item.id}`) router.push(`/course/chapter?id=${route.query?.id}&chapterId=${item.id}`)
} else { } else {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import AppContainer from '@/components/base/AppContainer.vue' import AppContainer from '@/components/base/AppContainer.vue'
import { getCourseDetail } from '../api' import { getCourseDetail } from '../api'
import CourseCatalog from '../components/CourseCatalog.vue' import CourseCatalog from '../components/CourseCatalog.vue'
import { Dialog } from 'vant'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
...@@ -25,8 +26,37 @@ getCourseDetail({ id: route.query?.id as string }).then((res: any) => { ...@@ -25,8 +26,37 @@ getCourseDetail({ id: route.query?.id as string }).then((res: any) => {
}) })
const goExam = function () { const goExam = function () {
router.push(`/exam?type=course&id=${route.query?.id}&eId=${data.course?.exams[0].examination_id}`) // 考试有成绩
if (isExam?.status !== 0) {
Dialog.alert({
title: data.course.category_name,
message: `您的考试成绩:${data.course?.exams?.[0]?.score || 0}`,
confirmButtonText: `${(data.course?.exams?.[0]?.score || 0) >= 60 ? '查看证书' : '重新考试'}`
}).then(() => {
if ((data.course?.exams?.[0]?.score || 0) >= 60) {
router.push('/my')
} else {
router.push(`/exam?is_new=1&type=course&id=${route.query?.id}&eId=${data.course?.exams[0].examination_id}`)
}
})
} else {
// 没提交考试
if (data.course.progress >= 80) {
router.push(`/exam?type=course&id=${route.query?.id}&eId=${data.course?.exams[0].examination_id}`)
} else {
Dialog.alert({
title: '提示',
message: '课程学习进度未达到80%以上,不能进行考试'
}).then(() => {
// on close
})
}
}
} }
const isExam = $computed(() => {
return data.course?.exams?.[0] || {}
})
</script> </script>
<template> <template>
...@@ -41,18 +71,13 @@ const goExam = function () { ...@@ -41,18 +71,13 @@ const goExam = function () {
></CourseCatalog> ></CourseCatalog>
</div> </div>
<van-button <van-button
v-if=" v-if="data.course?.exams && data.course?.exams.length && data.course.is_free_name !== '收费'"
data.course?.exams &&
data.course?.exams.length &&
data.course?.exams[0].status !== 1 &&
data.course.is_free_name !== '收费'
"
@click="goExam" @click="goExam"
type="primary" type="primary"
size="large" size="large"
color="#aa1941" color="#aa1941"
style="margin-bottom: 1rem" style="margin-bottom: 1rem"
>课程考试</van-button >{{ isExam?.status !== 0 ? '查看考试成绩' : '课程考试' }}</van-button
> >
</template> </template>
......
...@@ -25,26 +25,9 @@ getCourseDetail({ id: route.query?.id as string }).then((res: any) => { ...@@ -25,26 +25,9 @@ getCourseDetail({ id: route.query?.id as string }).then((res: any) => {
}) })
const handleStudy = function () { const handleStudy = function () {
router.push(`/course/chapter?id=${route.query?.id}&chapterId=${data.course?.id}`) if (data.course?.is_free_name !== '已过期') {
// const videoId = data.course.last_play_video router.push(`/course/chapter?id=${route.query?.id}&chapterId=${data.course?.id}`)
// let query = { }
// cId: '',
// rId: '',
// zId: ''
// }
// data.course.chapters.forEach((item: any) => {
// const findItem = item.children.find((cItem: any) => cItem.resource_id === videoId)
// query = {
// cId: findItem?.id || '',
// rId: findItem?.resource_id || '',
// zId: item.id
// }
// })
// if (videoId === '' || query.cId === '' || query.rId === '') {
// router.push(`/course/chapter?id=${route.query?.id}&chapterId=${data.course?.id}`)
// } else {
// router.push(`/course/player?id=${route.query?.id}&chapterId=${query.cId}&rId=${query.rId}&&zId=${query.zId}`)
// }
} }
const isExam = function () { const isExam = function () {
...@@ -61,9 +44,14 @@ const isExam = function () { ...@@ -61,9 +44,14 @@ const isExam = function () {
const viewResult = function () { const viewResult = function () {
Dialog.alert({ Dialog.alert({
title: data.course.category_name, title: data.course.category_name,
message: `您的考试成绩:${data.course?.exams[0].score}` message: `您的考试成绩:${data.course?.exams?.[0]?.score || 0}`,
confirmButtonText: `${(data.course?.exams?.[0]?.score || 0) >= 60 ? '查看证书' : '重新考试'}`
}).then(() => { }).then(() => {
// on close if ((data.course?.exams?.[0]?.score || 0) >= 60) {
router.push('/my')
} else {
router.push(`/exam?is_new=1&type=course&id=${route.query?.id}&eId=${data.course?.exams[0].examination_id}`)
}
}) })
} }
</script> </script>
...@@ -107,7 +95,9 @@ const viewResult = function () { ...@@ -107,7 +95,9 @@ const viewResult = function () {
<div class="btn">立即购买</div> <div class="btn">立即购买</div>
</div> </div>
<!-- 已购买没考试 --> <!-- 已购买没考试 -->
<div class="btn-s2" v-else @click="handleStudy">立即学习</div> <div :class="data.course?.is_free_name === '已过期' ? 'btn-s2 free' : 'btn-s2'" v-else @click="handleStudy">
立即学习
</div>
</template> </template>
</div> </div>
</div> </div>
...@@ -257,6 +247,10 @@ const viewResult = function () { ...@@ -257,6 +247,10 @@ const viewResult = function () {
color: #ffffff; color: #ffffff;
text-align: center; text-align: center;
box-shadow: 0 0 5px 1px rgba(170, 25, 65, 0.5); box-shadow: 0 0 5px 1px rgba(170, 25, 65, 0.5);
&.free {
background: #ccc;
box-shadow: none;
}
} }
} }
</style> </style>
...@@ -21,6 +21,9 @@ if (route.query.type) { ...@@ -21,6 +21,9 @@ if (route.query.type) {
} else { } else {
initParams.chapter_id = route.query?.cId initParams.chapter_id = route.query?.cId
} }
if (route.query.is_new) {
initParams.is_new = true
}
getExam(initParams).then((res: any) => { getExam(initParams).then((res: any) => {
data = res.data data = res.data
if (res.data?.questions || res.data?.questions !== '') { if (res.data?.questions || res.data?.questions !== '') {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论