<template>
  <div class="main-container" v-show="loaded">
    <template v-if="list.length">
      <course-item v-for="item in list" :data="item" :key="item.course_id" />
    </template>
    <van-empty description="暂无内容" v-else />
  </div>
</template>

<script>
import * as api from '@/api/course.js'
import CourseItem from '@/components/CourseItem.vue'

export default {
  name: 'Course',
  components: { CourseItem },
  metaInfo: {
    title: '课程学习'
  },
  data() {
    return {
      loaded: false,
      list: []
    }
  },
  methods: {
    getCourseList() {
      api
        .getCourseList()
        .then(response => {
          this.list = response
        })
        .finally(() => {
          this.loaded = true
        })
    }
  },
  beforeMount() {
    this.getCourseList()
  }
}
</script>

<style lang="scss">
.course-item:last-child {
  border-bottom: 0;
}
</style>
