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

第二版迭代

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