<template>
  <div class="wrapper">
    <div class="top-wrapper">
      <div class="icon-time-duration">
        <u-icon :name="icon" size="13" />
        <div class="iconTitle">{{ iconTitle }}</div>
        <div>{{ duration }}</div>
      </div>
      <div class="studyTitle">{{ states.studyTitle }}</div>
    </div>
    <div class="progress">
      <u-line-progress :percentage="states.progress" activeColor="#1989FA" :showText="false" height="10" />
      <div style="margin-left: 5px;">{{ states.progress }}%</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    states: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      icon: '/static/images/pdf1.png',
      iconTitle: 'PDF',
      duration: '00:12:00',
      // 进度
      progress: 30
    }
  },
  mounted() {
    console.log('🚀 ~ mounted ~ this.states:', this.states)
    const url = this.states.url
    if (url.includes('.pdf')) {
      this.icon = '/static/images/pdf1.png'
      this.iconTitle = 'PDF'
    } else if (url.includes('.mp4')) {
      this.icon = '/static/images/mp4.png'
      this.iconTitle = '视频'
    }
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
.wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 5px;

  .top-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 55%;

    .icon-time-duration {
      display: flex;
      align-items: center;
      font-size: 13px;
      color: #676767;
      margin-bottom: 10px;
      .iconTitle {
        margin-left: 3px;
        margin-right: 15px;
      }
    }

    .studyTitle {
      font-size: 14px;
      font-weight: bold;
      color: #333;
    }
  }
  .progress {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    font-size: 12px;
    color: #9b9b9b;
    width: 40%;
  }
}
</style>
