黄琪勇 1 tahun lalu
induk
melakukan
54c223d484

+ 8 - 2
src/views/curriculum/components/courseCollapse/courseCollapse.vue

@@ -33,7 +33,7 @@
          </template>
          <div class="courseCollapseCon">
             <template v-if="item.materialList">
-               <div class="courseList" v-for="i in item.materialList" :key="i.id">
+               <div class="courseList" v-for="i in item.materialList" :key="i.id" @click="handleClick(i)">
                   <div class="courseTitleCon">
                      <img :src="require(`@/img/curriculum/${i.typeCode || i.type}.png`)" />
                      <div class="ellipsisBox">
@@ -43,7 +43,7 @@
                   <img class="iconArrow" src="@/img/curriculum/zkai.png" />
                </div>
             </template>
-            <courseCollapse v-else :courseList="item.children!" :titleType="'round'" />
+            <courseCollapse v-else :courseList="item.children || []" :titleType="'round'" @handleClick="handleClick" />
          </div>
       </el-collapse-item>
    </el-collapse>
@@ -65,6 +65,9 @@ type courseListType = {
    children: courseListType | null
 }[]
 
+const emits = defineEmits<{
+   (e: "handleClick", value: any): void
+}>()
 const props = withDefaults(
    defineProps<{
       courseList: courseListType
@@ -74,6 +77,9 @@ const props = withDefaults(
       titleType: "default"
    }
 )
+function handleClick(value: any) {
+   emits("handleClick", value)
+}
 </script>
 
 <style lang="scss" scoped>

+ 12 - 1
src/views/curriculum/curriculumDetail.vue

@@ -43,7 +43,7 @@
                </div>
                <div class="content">
                   <ElScrollbar class="elScrollbar">
-                     <courseCollapse :courseList="curriculumDetailData.pointList" />
+                     <courseCollapse :courseList="curriculumDetailData.pointList" @handleClick="handleCourseClick" />
                   </ElScrollbar>
                   <el-empty
                      v-if="!curriculumDetailData.pointList.length && !loading"
@@ -74,6 +74,7 @@ import { httpAjaxErrMsg } from "@/plugin/httpAjax"
 import { ref, shallowRef } from "vue"
 import { handleStartClass_gyt, handleStartClass_gym, isONLINE_gym } from "./hooks/useStartClass"
 import userStore from "@/store/modules/user"
+import router from "@/router"
 
 const userStoreHook = userStore()
 const props = defineProps<{
@@ -181,6 +182,16 @@ function handleSetUpCourseware(id: string) {
       getCurriculumDetailData()
    })
 }
+function handleCourseClick(item: any) {
+   const url = router.resolve({
+      name: "coursewarePlay",
+      params: { id: curriculumDetailData.value.id },
+      query: {
+         materialId: item.id
+      }
+   }).href
+   window.open(url, "_blank")
+}
 </script>
 
 <style lang="scss" scoped>

+ 31 - 3
src/views/curriculum/hooks/useStartClass.ts

@@ -3,11 +3,20 @@ import { getRecentCourseSchedule_gym } from "@/api/homePage.api"
 import { httpAjaxErrMsg } from "@/plugin/httpAjax"
 import useDialogConfirm from "@/hooks/useDialogConfirm"
 import { format } from "@/libs/tools"
+import router from "@/router"
 
 /* 管乐迷 开始上课 */
 export function handleStartClass_gym(id: string) {
    httpAjaxErrMsg(getRecentCourseSchedule_gym, id).then(res => {
       if (res.code === 200) {
+         if (!res.data) {
+            useDialogConfirm({
+               headImg: require("@/img/curriculum/ts4.png"),
+               text: `该课程已结束`,
+               btnShow: [true]
+            })
+            return
+         }
          const { signInStatusEnum, isCallNames, coursewareDetailId, startClassTime, endClassTime } = res.data
          if (signInStatusEnum === 3) {
             useDialogConfirm({
@@ -33,7 +42,7 @@ export function handleStartClass_gym(id: string) {
             })
             return
          }
-         alert("开始上课")
+         handlePaly(coursewareDetailId)
       }
    })
 }
@@ -53,7 +62,15 @@ export function isONLINE_gym(teachMode: string) {
 export function handleStartClass_gyt(id: string) {
    httpAjaxErrMsg(getCourseScheduleDetail_gyt, id).then(res => {
       if (res.code === 200) {
-         const { signIn, rollCall, lessonCoursewareId, startTime, endTime } = res.data
+         const { signIn, rollCall, lessonCoursewareId, startTime, endTime, status } = res.data
+         if (status === "COMPLETE") {
+            useDialogConfirm({
+               headImg: require("@/img/curriculum/ts4.png"),
+               text: `该课程已结束`,
+               btnShow: [true]
+            })
+            return
+         }
          if (!signIn) {
             useDialogConfirm({
                headImg: require("@/img/curriculum/ts2.png"),
@@ -78,7 +95,18 @@ export function handleStartClass_gyt(id: string) {
             })
             return
          }
-         alert("开始上课")
+         handlePaly(lessonCoursewareId)
       }
    })
 }
+
+function handlePaly(id: string) {
+   const url = router.resolve({
+      name: "coursewarePlay",
+      params: { id },
+      query: {
+         mode: "class"
+      }
+   }).href
+   window.open(url, "_blank")
+}