<template>
  <view class="item-container" @click="$emit('click')">
    <view class="book-item-box">
      <view class="item-box-left">
        <image
          class="img-item"
          :src="data.imgCover"
          mode="scaleToFill"
        />
      </view>
      <view class="item-box-right">
        <view class="item-title line-clamp-2">{{ data.title || '暂无标题' }}</view>
        <view>
          <text class="item-author">{{ data.nickname || '佚名' }}</text>
          <text class="item-publish">{{ data.publish || '暂无出版社数据' }}</text>
        </view>
        <view class="item-desc line-clamp-2">{{ data.desc || '暂无简介' }}</view>
      </view>
    </view>
    <view class="lending-info">
      <view class="lending-time">
        <text>借阅开始时间：{{ data.startTime || '' }}</text>
        <text>最后归还时间：{{ data.returnTime || '' }}</text>
        <text v-if="data.realityTime" style="color: #FF3871;">实际归还时间：{{ data.realityTime }}</text>
      </view>
      <!-- 临期 → 1 -->
      <image v-if="data.returnBook === 1" class="lending-status" src="@/static/images/mylending-img3.png" mode="heightFix" />
      <!-- 准时 → 2 -->
      <image v-if="data.returnBook === 2" class="lending-status" src="@/static/images/mylending-img2.png" mode="heightFix" />
      <!-- 逾期 → 3 -->
      <image v-if="data.returnBook === 3" class="lending-status" src="@/static/images/mylending-img1.png" mode="heightFix" />
    </view>
  </view>
</template>

<script>
export default {
  name: "lending-list-item",
  props: {
    data: {
      type: Object,
      required: true
    }
  },
  methods: {
  }
};
</script>

<style lang="scss" scoped>
.item-container {
  padding: 10px;
  background-color: #fff;
  border-radius: 6px;
  border-bottom: 1px solid #f4f4f4;
  margin-bottom: 10px;
  .book-item-box {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    .item-box-left {
      margin-right: 10px;
      .img-item{
        width: 64px;
        height: 90px;
        border-radius: 5px;
      }
    }
    .item-box-right {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      flex: 1;
      .item-title {
        font-size: 15px;
        font-weight: bold;
        color: #000;
        padding-bottom: 6px;
      }
      .item-author,
      .item-publish {
        font-size: 12px;
        color: #191A1A;
        padding: 2px 4px;
        border-radius: 2px;
        background-color: #F4F6FC;
      }
      .item-author{
        margin-right: 6px;
      }
      .item-desc {
        font-size: 12px;
        color: #191A1A;
        padding-top: 8px;
      }
    }
  }
}
.lending-info{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 10px 10px 0;
  .lending-time{
    font-size: 12px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    line-height: 22px;
  }
  .lending-status{
    height: 50px;
  }
}
</style>