<template>
  <div class="course-item" @click="onClick(data)">
    <div class="course-item-pic" v-if="curriculum.curriculum_picture">
      <img :src="curriculum.curriculum_picture" />
    </div>
    <div class="course-item-content">
      <h3 class="course-item__title">{{data.course_name}}</h3>
      <div class="course-item__text" v-html="curriculum.curriculum_represent"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CourseItem',
  props: {
    data: { type: Object, required: true }
  },
  computed: {
    curriculum() {
      return this.data.curriculum
    }
  },
  methods: {
    onClick(data) {
      this.$router.push({
        name: 'courseLearnItem',
        params: { id: data.course_id }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.course-item {
  display: flex;
  padding: 0.2rem 0;
  border-bottom: 1px solid #f1f1f1;
}
.course-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.course-item-pic {
  width: 2.4rem;
  height: 1.35rem;
  margin-right: 10px;
  border-radius: 6px;
  overflow: hidden;
  margin-right: 0.2rem;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
.course-item__title {
  margin: 0;
  font-size: 0.3rem;
  font-weight: 400;
  color: #222;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.course-item__text {
  max-height: 0.68rem;
  font-size: 0.26rem;
  color: #999;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
</style>
