提交 1f6e37bc authored 作者: lihuihui's avatar lihuihui

update

上级 7192def1
<script setup lang="ts"> <script setup lang="ts">
import { getVideoDetails } from '../api' import { getVideoDetails } from '../api'
import AppVideoPlayer from '@/components/base/AppVideoPlayer.vue' import AppVideoPlayer from '@/components/base/AppVideoPlayer.vue'
// import PreviewFiles from '@/components/base/PreviewFiles.vue'
const props: any = defineProps({ const props: any = defineProps({
data: { data: {
type: Array type: Array
...@@ -22,7 +24,7 @@ const videoOptions = computed(() => { ...@@ -22,7 +24,7 @@ const videoOptions = computed(() => {
return { return {
sources: [ sources: [
{ {
src: resourceData.play_auth?.play_info_list[0].PlayURL src: resourceData.play_auth?.play_info_list.find((item: any) => { return item.Definition === 'SD' }).PlayURL
} }
] ]
} }
...@@ -65,6 +67,7 @@ const changeVideo = (index: number) => { ...@@ -65,6 +67,7 @@ const changeVideo = (index: number) => {
<style lang="scss" scoped> <style lang="scss" scoped>
.cover-box { .cover-box {
display: flex; display: flex;
margin-bottom: 20px;
} }
.cover-img { .cover-img {
width: 200px; width: 200px;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { getCharacter } from '../api' import { getCharacter } from '../api'
import ViewCourseChapter from '../components/ViewCourseChapter.vue' import ViewCourseChapter from '../components/ViewCourseChapter.vue'
import ViewDetailsVideo from '../components/ViewDetailsVideo.vue' import ViewDetailsVideo from '../components/ViewDetailsVideo.vue'
import PreviewFiles from '@/components/base/PreviewFiles.vue'
interface IChapterDetails { interface IChapterDetails {
name: string name: string
...@@ -10,6 +11,7 @@ interface IChapterDetails { ...@@ -10,6 +11,7 @@ interface IChapterDetails {
// 路由 // 路由
const route = useRoute() const route = useRoute()
const router = useRouter()
const courseId = route.params.courseId as string const courseId = route.params.courseId as string
const chapterId = route.params.id const chapterId = route.params.id
...@@ -18,6 +20,10 @@ const chapterTree: any = ref([]) ...@@ -18,6 +20,10 @@ const chapterTree: any = ref([])
// 当前章节的资源内容 // 当前章节的资源内容
const chapterDetails = ref<IChapterDetails>() const chapterDetails = ref<IChapterDetails>()
onMounted(() => { onMounted(() => {
initData()
})
const initData = () => {
getCharacter({ course_id: courseId, type: 'tree' }).then((res: any) => { getCharacter({ course_id: courseId, type: 'tree' }).then((res: any) => {
if (res.code === 0) { if (res.code === 0) {
chapterTree.value = res.data[0]?.children || [] chapterTree.value = res.data[0]?.children || []
...@@ -28,61 +34,149 @@ onMounted(() => { ...@@ -28,61 +34,149 @@ onMounted(() => {
} }
}) })
} }
getChapterVideo() getChapterResource()
}) })
}
// 所有资源集合
interface IResourceAll {
videoData: { cover: string; id: string }[]
courseware: { id: string; url: string }[]
lessonPlan: { id: string; url: string }[]
data: { id: string; url: string }[],
exam: any[],
live: any[]
}
// 所有要渲染的资源
const resourceData = reactive<IResourceAll>({
videoData: [],
courseware: [],
lessonPlan: [],
data: [],
exam: [],
live: []
}) })
// 获取树结构里面的视频资源 // 分配资源
interface IResource { interface IResource {
resource_type: string
resource: {
cover: string cover: string
id: string id: string
url: string
}
} }
const videoData = ref<IResource[]>([]) const getChapterResource = () => {
const getChapterVideo = () => { chapterDetails.value?.children.forEach((item: IResource) => {
chapterDetails.value?.children.forEach((item: { resource_type: string; resource: IResource }) => { switch (item.resource_type) {
if (item.resource_type === '2') { case '2':
videoData.value.push(item.resource) resourceData.videoData.push(item.resource)
break
case '10':
resourceData.courseware.push(item.resource)
break
case '11':
resourceData.lessonPlan.push(item.resource)
break
case '4':
resourceData.data.push(item.resource)
break
case '9':
resourceData.exam.push(item.resource)
break
case '6':
resourceData.live.push(item.resource)
break
} }
}) })
} }
// 获取当前视频详情
// const currentVideoDetails = (id: string) => {
// getVideoDetails({ id: id }).then((res: any) => {
// videoData.currentVideo = res.data
// videoData.currentId = id
// })
// }
// const btnList = [ // 资料切换
// { const activeName = ref('1')
// btn_name: '视频',
// resource_type: '2' // 考试参数
// }, const listOptions = computed(() => {
// { return {
// btn_name: '课件', columns: [
// resource_type: '10' { type: 'index', label: '序号', fixed: 'left' },
// }, {
// { label: '组卷模式',
// btn_name: '教案', prop: 'paper_type',
// resource_type: '11' computed: (row: any) => {
// }, return row.row.paper_type === 1 ? '选题组卷' : '自动组卷'
// { }
// btn_name: '资料', },
// resource_type: '4' {
// }, label: '试卷用途',
// { prop: 'paper_uses',
// btn_name: '作业', computed: (row: any) => {
// resource_type: '3' const map = { 1: '考试', 2: '课后作业', 3: '课程测试' }
// }, return map[row.row.paper_uses] || row.row.paper_uses
// { }
// btn_name: '考试', },
// resource_type: '9' { label: '试卷分类', prop: 'paper_category.name' },
// }, { label: '试卷名称', prop: 'paper_title' },
// { { label: '总分', prop: 'paper_total_score' },
// btn_name: '直播', { label: '及格分数', prop: 'pass_score' },
// resource_type: '6' { label: '更新时间', prop: 'updated_at' }
// } ],
// ] data: resourceData.exam
}
})
// 直播
const add0 = (m: number) => {
return m < 10 ? '0' + m : m
}
const format = (n: number) => {
const time = new Date(n)
const y = time.getFullYear()
const m = time.getMonth() + 1
const d = time.getDate()
const h = time.getHours()
const mm = time.getMinutes()
const s = time.getSeconds()
return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s)
}
const liveOptions = computed(() => {
return {
columns: [
{ label: '会议code', prop: 'meeting_code', align: 'center' },
{ label: '主题', prop: 'subject', align: 'center' },
{
label: '开始时间',
prop: 'start_time',
align: 'center',
computed({ row }: any) {
return format(parseInt(row.start_time))
}
},
{
label: '结束时间',
prop: 'end_time',
align: 'center',
computed({ row }: any) {
return format(parseInt(row.end_time))
}
},
{ label: '操作', slots: 'table-operate', align: 'center' }
],
data: resourceData.live
}
})
const goLive = (url: string) => {
window.open(url)
}
// 监听路由变化重新渲染页面
watch(
() => route.params.id,
() => {
initData()
router.go(0)
}
)
</script> </script>
<template> <template>
<AppCard title="查阅课程"> <AppCard title="查阅课程">
...@@ -90,7 +184,35 @@ const getChapterVideo = () => { ...@@ -90,7 +184,35 @@ const getChapterVideo = () => {
<div class="title">{{ chapterDetails?.name }}</div> <div class="title">{{ chapterDetails?.name }}</div>
<div class="chapter-content"> <div class="chapter-content">
<div class="content-left"> <div class="content-left">
<ViewDetailsVideo v-if="Object.keys(videoData).length" :data="videoData"></ViewDetailsVideo> <ViewDetailsVideo
v-if="Object.keys(resourceData.videoData).length"
:data="resourceData.videoData"
></ViewDetailsVideo>
<el-empty description="暂无数据" v-else/>
<el-tabs :lazy="true" v-model="activeName" class="demo-tabs">
<el-tab-pane label="课件" name="1">
<PreviewFiles v-for="item in resourceData.courseware" :key="item.id" :url="item.url"></PreviewFiles>
<el-empty description="暂无数据" v-if="!resourceData.courseware.length"/>
</el-tab-pane>
<el-tab-pane label="教案" name="2">
<PreviewFiles :url="item.url" v-for="item in resourceData.courseware" :key="item.id"></PreviewFiles>
<el-empty description="暂无数据" v-if="!resourceData.courseware.length"/>
</el-tab-pane>
<el-tab-pane label="资料" name="3">
<PreviewFiles :url="item.url" v-for="item in resourceData.courseware" :key="item.id"></PreviewFiles>
<el-empty description="暂无数据" v-if="!resourceData.courseware.length"/>
</el-tab-pane>
<el-tab-pane label="考试 / 测验" name="4">
<AppList v-bind="listOptions"></AppList>
</el-tab-pane>
<el-tab-pane label="直播" name="5">
<AppList v-bind="liveOptions">
<template #table-operate="{ row }">
<el-button plain @click="goLive(row.join_url)">查看</el-button>
</template>
</AppList>
</el-tab-pane>
</el-tabs>
</div> </div>
<ViewCourseChapter :isBlack="true" :data="chapterTree"></ViewCourseChapter> <ViewCourseChapter :isBlack="true" :data="chapterTree"></ViewCourseChapter>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论