<template>
  <div class="main-container" style="margin:0 0.15rem">
    <course-list @on-click="handleClick" />
  </div>
</template>

<script>
import CourseList from '@/components/CourseList.vue'

export default {
  name: 'CoursePlayer',
  components: { CourseList },
  metaInfo: {
    title: '考证课程'
  },
  computed: {
    isWeapp() {
      return this.$store.state.isWeapp
    }
  },
  methods: {
    handleClick(data) {
      if (this.isWeapp) {
        const url = `/pages/web/index?src=${window.location.origin}/course/player/${data.id}`
        wx.miniProgram.navigateTo({ url })
      } else {
        this.$router.push({ name: 'coursePlayerItem', params: { id: data.id } })
      }
    }
  }
}
</script>
