<template>
  <div class="item-wrap" @click="router.push(`videoPlay?id=${item.video?.id}`)">
    <img class="cover" :src="item.video?.imgUrl" alt="" />
    <div class="content">
      <div>
        <!-- 直播中或者已暂停 -->
        <span
          :class="['status', 'status0']"
          v-if="
            [$liveStatusObj.InLive, $liveStatusObj.PausePlay].includes(
              item.video?.liveStatus
            )
          "
          >{{
            item.video?.liveStatus === $liveStatusObj.InLive
              ? "直播中"
              : "已暂停"
          }}</span
        >
        <!-- 未开始 -->
        <span
          :class="[
            'status',
            item.video?.isSubscribe === 1 ? 'status2' : 'status3',
          ]"
          v-else-if="item.video?.liveStatus === $liveStatusObj.NotStart"
          >{{ item.video?.isSubscribe === 1 ? "已预约" : "已预约" }}｜{{
            formTime
          }}后开播</span
        >
        <div>
          <!-- 已结束，有回放视频 -->
          <span
            :class="['status', 'status3']"
            v-if="
              item.video?.liveStatus === $liveStatusObj.FinishPlay &&
              item.video?.libraryList &&
              item.video?.libraryList.length
            "
            >回看视频</span
          >
          <!-- 已结束，无回放视频 -->
          <span
            :class="['status', 'status3']"
            v-if="item.video?.liveStatus === $liveStatusObj.FinishPlay"
            >已结束</span
          >
          <h3>{{ item.video?.title }}</h3>
          <p class="point">
            {{ item.video?.viewPoint }}
          </p>
        </div>
        <div class="info">
          <div class="user">
            <img :src="item.video?.imgUrl" alt="" srcset="" />
            <p>{{ item.video?.advisorBasic?.showName }}</p>
          </div>
          <span>{{ item.time }} 浏览</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from "vue";
import { useRouter } from "vue-router";
import useCountDown from "@/hooks/useCountDown";
import useGetLiveStatusObj from "@/hooks/useGetLiveStatusObj";
const $liveStatusObj = useGetLiveStatusObj();

const router = useRouter();
const props = defineProps({
  item: {
    type: Object,
    default: () => ({}),
  },
});

const { formTime, startDownTime } = useCountDown();

startDownTime(props.item.video?.startTime);
</script>
<style scoped lang="scss">
.item-wrap {
  display: flex;
  text-align: left;
  padding: 20px 0 24px;
  border-bottom: 0.5px solid var(---, #ebeced);
  .cover {
    width: 208px;
    height: 280px;
    border-radius: 16px;
    margin-right: 24px;
  }
  .content {
    flex: 1;
    width: 0;
  }
  .status {
    display: inline-block;
    padding: 0 12px 0 40px;
    align-items: flex-start;
    border-radius: 8px;

    background: #fff;
    font-size: 24px;
    line-height: 40px;
    height: 40px;
    margin-bottom: 16px;
  }
  .status0,
  .status1,
  .status2 {
    color: rgba(46, 120, 250, 1);
    border: 0.5px solid rgba(46, 120, 250, 0.5);
  }
  .status0 {
    padding-left: 12px;
  }
  .status1 {
    background: url(../../../assets/images/status2.png) no-repeat left 16px
      center;
    background-size: 24px 24px;
  }
  .status2 {
    background: url(../../../assets/images/status3.png) no-repeat left 16px
      center;
    background-size: 24px 24px;
  }
  .status3,
  .status4 {
    color: rgb(102, 102, 102);
    border: 0.5px solid rgba(153, 153, 153, 0.5);
  }
  .status3 {
    background: url(../../../assets/images/status1.png) no-repeat left 16px
      center;
    background-size: 24px 24px;
  }
  .status3 {
    background: url(../../../assets/images/status4.png) no-repeat left 16px
      center;
    background-size: 24px 24px;
  }
  h3 {
    color: rgb(51, 51, 51);
    font-size: 32px;
    font-style: normal;
    font-weight: 500;
    line-height: 48px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .point {
    color: rgb(102, 102, 102);
    font-size: 28px;
    font-style: normal;
    font-weight: 400;
    line-height: 44px;
    margin-bottom: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #666666;
  font-family: "PingFang SC";
  font-size: 24px;
  font-style: normal;
  font-weight: 400;
  line-height: 32px;
  padding-bottom: 20px;
  .user {
    display: flex;
    align-items: center;
    img {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      margin-right: 8px;
    }
  }
}
</style>
