<template>
  <div class="content_left">
    <!-- 学生基本信息区域 -->
    <div class="title">学生基本信息</div>
    <div class="info">
      <div class="info_photo">
        <img
          class="img"
          src="https://img1.baidu.com/it/u=1398895526,1958525606&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800"
        />
        <div class="photo_icon">
          <el-icon size="20" color="#2493F1"><ArrowDownBold /></el-icon>
        </div>
      </div>
      <div class="info_form">
        <div class="form_item">姓名：张晓晓</div>
        <div class="form_item">学号：18930228199</div>
        <div class="form_item">班级：8（5）班</div>
        <div class="form_item">出生年月：1998年5月16日</div>
        <div class="form_item">标签：干饭达人，运动达人，北方人节约，19岁，小资生活</div>
      </div>
    </div>

    <!-- 学习报告区域 -->
    <div class="title">学习报告</div>
    <div class="report">
      <div class="report_top">
        <!-- 累计天数区域 -->
        <div class="top_box">
          <div class="icon_top" ref="addDayDom">{{ addDay }}</div>
          <div class="icon_bottom">
            <span>累计天数</span>
          </div>
        </div>

        <!-- 连续天数区域 -->
        <div class="top_box">
          <div class="icon_top" ref="conDayDom">{{ conDay }}</div>
          <div class="icon_bottom">
            <span>连续天数</span>
          </div>
        </div>
      </div>

      <div class="report_bottom">
        不积路步，无以至千里，不积小流，无以成江海
        <img class="icon" src="@/assets/images/report-bottom-icon.png" />
        <img class="icon2" src="@/assets/images/report-bottom-icon.png" />
      </div>
    </div>

    <!-- 学生完成情况分布区域 -->
    <div class="title">学生完成情况分布 <span> (本月)</span></div>
    <div class="finish">
      <!-- 总布置数区域 -->
      <div class="finish_box">
        <div class="box_img"></div>
        <div class="box_info">
          <div class="info_num" ref="totalNumDom">{{ totalNum }}</div>
          <div class="info_title">总布置数</div>
        </div>
      </div>

      <!-- 平均提交率区域 -->
      <div class="finish_box">
        <div class="box_img img2"></div>
        <div class="box_info">
          <div class="info_num yellow">
            <span ref="submitNumDom"> {{ submitNum }}</span
            >%
          </div>
          <div class="info_title">平均提交率</div>
        </div>
      </div>

      <!-- 平均正确率区域 -->
      <div class="finish_box">
        <div class="box_img img3"></div>
        <div class="box_info">
          <div class="info_num green">
            <span ref="correctNumDom">{{ correctNum }}</span
            >%
          </div>
          <div class="info_title">平均正确率</div>
        </div>
      </div>

      <!-- 日平均用时区域 -->
      <div class="finish_box">
        <div class="box_img"></div>
        <div class="box_info">
          <div class="info_num" ref="timeNumDom">{{ timeNum }}分钟</div>
          <div class="info_title">日平均用时</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { countUpNum } from '@/utils/countUpNum.js'

// 累计天数
const addDay = ref(321)
const addDayDom = ref()
// 连续天数
const conDay = ref(145)
const conDayDom = ref()

// 总布置数
const totalNum = ref(568)
const totalNumDom = ref()
// 平均提交率
const submitNum = ref(52)
const submitNumDom = ref()

// 平均正确率
const correctNum = ref(95)
const correctNumDom = ref()

// 日平均用时
const timeNum = ref(588)
const timeNumDom = ref()

onMounted(() => {
  countUpNum(addDayDom.value, addDay.value)
  countUpNum(conDayDom.value, conDay.value)
  countUpNum(totalNumDom.value, totalNum.value)
  countUpNum(submitNumDom.value, submitNum.value)
  countUpNum(correctNumDom.value, correctNum.value)
  countUpNum(timeNumDom.value, timeNum.value)
})
</script>
<style lang="scss" scoped>
.content_left {
  z-index: 1;
  margin-left: 44px;
  width: 490px;
  color: #fff;

  .title {
    box-sizing: border-box;
    padding-top: 2px;
    padding-left: 30px;
    height: 38px;
    font-size: 16px;
    font-weight: bold;
    background-image: url(@/assets/images/book-title-bg.png);
    background-size: 100% 100%;

    span {
      font-size: 14px;
    }
  }

  .info {
    display: flex;
    align-items: center;
    height: 270px;

    .info_photo {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 122px;
      height: 122px;
      border-radius: 50%;
      background-color: #2493f1;

      img {
        width: 112px;
        height: 112px;
        border-radius: 50%;
        object-fit: cover;
      }

      .photo_icon {
        position: absolute;
        top: 45px;
        right: -14px;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background-color: #fff;
      }
    }

    .info_form {
      margin-top: 10px;
      margin-left: 44px;
      width: 314px;
      font-size: 14px;

      .form_item {
        margin-bottom: 8px;
        line-height: 20px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
    }
  }
  .report {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    height: 270px;

    .report_top {
      display: flex;
      justify-content: space-evenly;
      margin-left: 20px;
      width: 430px;

      .top_box {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 98px;

        .icon_top {
          display: flex;
          justify-content: center;
          align-items: center;
          margin-bottom: -35px;
          width: 73px;
          height: 73px;
          font-size: 18px;
          font-weight: bold;
          background-image: url(@/assets/images/icon-top.png);
          background-size: 100% 100%;
          animation: float 5s linear infinite;
        }

        .icon_bottom {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 98px;
          height: 90px;
          background-image: url(@/assets/images/icon-bottom.png);
          background-size: 100% 100%;

          span {
            margin-top: 10px;
            padding: 2px 8px;
            height: 18px;
            font-size: 12px;
            border-radius: 9px;
            background-image: linear-gradient(#12fee0, #07889b);
          }
        }
      }
    }

    .report_bottom {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-left: 8px;
      width: 450px;
      height: 53px;
      font-size: 16px;
      background-color: rgba(20, 144, 245, 0.1);

      .icon {
        position: absolute;
        top: 0;
        left: 0;
        width: 9px;
        height: 13px;
      }

      .icon2 {
        position: absolute;
        top: 0;
        right: 0;
        width: 9px;
        height: 13px;
        transform: rotate(180deg) rotateX(180deg);
      }
    }
  }

  .finish {
    display: flex;
    flex-wrap: wrap;
    height: 250px;

    .finish_box {
      display: flex;
      align-items: center;
      width: 50%;
      .box_img {
        margin-left: 32px;
        width: 66px;
        height: 66px;
        background-image: url(@/assets/images/finish-box-bg.png);
        background-size: cover;
      }

      .img2 {
        background-image: url(@/assets/images/finish-box-bg2.png);
      }

      .img3 {
        background-image: url(@/assets/images/finish-box-bg3.png);
      }

      .box_info {
        margin-left: 20px;
        height: 66px;

        .info_num {
          margin-top: 5px;
          color: #5cb3ff;
          font-size: 24px;
        }

        .yellow {
          color: #ffeb3b;
        }

        .green {
          color: #57fff4;
        }

        .info_title {
          margin-top: 2px;
          font-size: 14px;
        }
      }
    }
  }
}
</style>
