|
|
@@ -1,11 +1,11 @@
|
|
|
<template>
|
|
|
<div class="CourseDetail container-height">
|
|
|
<Breadcrumb />
|
|
|
- <div>
|
|
|
+ <div v-loading="isLoading">
|
|
|
<div class="flex_1 bg_color_fff padding16 border_radius_16 box_shadow_card fit_content">
|
|
|
<div class="gap10">
|
|
|
<el-button type="primary">{{info.skillTagName}}</el-button>
|
|
|
- <div class="bold font_size30">{{info.courseCategoryName}}(第1期)</div>
|
|
|
+ <div class="bold font_size30">{{info.courseCategoryName}}({{chapterInfo.chapterOrderName}})</div>
|
|
|
</div>
|
|
|
<div class="gap5 mt10">
|
|
|
<img :src="riliIcon" alt="" style="width: 16px; height: 16px;">
|
|
|
@@ -63,7 +63,7 @@
|
|
|
</div>
|
|
|
<div class="detail_right">
|
|
|
<div class="bg_color_fff padding16 border_radius_16 box_shadow_card" v-show="!isShowNote">
|
|
|
- <CourseDirectory :info="info" />
|
|
|
+ <CourseDirectory :info="info" ref="courseDirectory" :chapterId="chapterId" @purchaseFn="purchaseFn"/>
|
|
|
</div>
|
|
|
<div class=" bg_color_fff padding16 border_radius_16 box_shadow_card mt10" v-show="!isShowNote">
|
|
|
<OtherCourse />
|
|
|
@@ -93,7 +93,8 @@ import VideoPlayer from '@/components/VideoPlayer.vue'
|
|
|
import Pinglun from './components/pinglun.vue'
|
|
|
import Xuxibiji from './components/Xuxibiji.vue'
|
|
|
import DGTMessage from '@/utils/message'
|
|
|
-import { copyText } from '@/utils/util'
|
|
|
+import { copyText, confirmBuy } from '@/utils/util'
|
|
|
+import { purchase } from '@/api/common.js'
|
|
|
|
|
|
// 引入api
|
|
|
import { getCourseDetail,collect } from '@/api/course.js'
|
|
|
@@ -108,10 +109,12 @@ const appStore = useAppStore()
|
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
const { t } = useI18n()
|
|
|
-
|
|
|
+const isLoading = ref(false);
|
|
|
//获取参数
|
|
|
const query = route.query;
|
|
|
-const courseId = ref(route.params.courseId || '');
|
|
|
+const courseId = ref(route.params.courseId || '');//课程id
|
|
|
+const chapterId = ref(route.query.chapterId || '');//章节id
|
|
|
+const chapterInfo = ref({})
|
|
|
const info = ref({})
|
|
|
|
|
|
// 视频相关
|
|
|
@@ -126,17 +129,45 @@ const currentPlayTime = ref(0)
|
|
|
const videoPlayer = ref(null)
|
|
|
|
|
|
onMounted(() => {
|
|
|
- getDetail();
|
|
|
+ getDetail();
|
|
|
});
|
|
|
const getDetail = async () => {
|
|
|
- getCourseDetail({id: courseId.value}).then(res => {
|
|
|
+ await getCourseDetail({id: courseId.value}).then(res => {
|
|
|
+ if(res.code === 200){
|
|
|
+ console.log(res)
|
|
|
+ info.value = res.data || {};
|
|
|
+ currentCourseCover.value = info.value.coverImageUrl || ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+};
|
|
|
+const purchaseFn = async (chapterId, chapterInfoItem={}) => {
|
|
|
+ console.log(chapterId, chapterInfoItem)
|
|
|
+ isLoading.value = true;
|
|
|
+ chapterInfo.value = chapterInfoItem || {};
|
|
|
+ await purchase({
|
|
|
+ buyType: 2,
|
|
|
+ chapterId,
|
|
|
+ }).then(res => {
|
|
|
+ isLoading.value = false;
|
|
|
if(res.code === 200){
|
|
|
- console.log(res)
|
|
|
- info.value = res.data || {};
|
|
|
- currentCourseCover.value = info.value.coverImageUrl || ''
|
|
|
+ if(res.data?.buyFlag == 1){
|
|
|
+ currentVideoUrl.value = res.data?.contentUrl || ''
|
|
|
+ }else{
|
|
|
+ confirmBuy({
|
|
|
+ callback:purchaseFn,
|
|
|
+ callbackParams:chapterId,
|
|
|
+ appStore,
|
|
|
+ router,
|
|
|
+ price:info.value.coursePrice,
|
|
|
+ t,
|
|
|
+ productId:info.value.courseId,
|
|
|
+ orderType:'course_purchase',
|
|
|
+ payMethod:'BMI'
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
// 打开添加对话框
|
|
|
const isShowNote = ref(false)
|
|
|
@@ -177,7 +208,7 @@ const onPlayerEnded = () => {
|
|
|
console.log('视频播放结束')
|
|
|
|
|
|
// 自动播放下一个视频
|
|
|
- playNextVideo()
|
|
|
+ // playNextVideo()
|
|
|
}
|
|
|
|
|
|
const onPlayerTimeupdate = (time) => {
|
|
|
@@ -247,7 +278,7 @@ const collectFn = () => {
|
|
|
// 复制当前页面地址
|
|
|
const copyCurrentUrl = () => {
|
|
|
copyText(window.location.href, t)
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
|
|
|
|