<template>
<div v-loading="loading">
  <CourseDisscuss v-if="!loading" :nowCheckCourse="nowCheckCourse"/>
</div>
</template>

<script>
import CourseDisscuss from '@/views/online-course/components/course-disscuss.vue'
import {
  getCommentByCourseIdApi
} from '@/api/online-course/my-course'
// 评价页面
export default {
  activated () {
    console.log(this.$route, this.$route.params.courseId)
    this.editorCourse(this.$route.params.courseId)
  },
  components: {
    CourseDisscuss
  },
  data: _ => ({
    nowCheckCourse: {},
    loading: false
  }),
  methods: {
    async editorCourse (courseId) {
      try {
        this.loading = true
        this.nowCheckCourse = {}
        const res = await getCommentByCourseIdApi(courseId)
        if (res.code !== 0) {
          // eslint-disable-next-line no-throw-literal
          throw '获取课程详情失败'
        }
        this.nowCheckCourse = res.data
      } catch (error) {
        this.$message.error(error.toString())
      }
      this.loading = false
    }
  }
}
</script>

<style>

</style>
