<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: 'CourseLearn',
  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/learn/${data.id}`
        wx.miniProgram.navigateTo({ url })
      } else {
        this.$router.push({ name: 'courseLearnItem', params: { id: data.id } })
      }
    }
  }
}
</script>
