<template>
  <view>
    <div class="header-back">
      <m-nav-bar
        :transparent="true"
        title="模拟考试成绩"
        style="color: #ffffff"
      />
      <div class="user-data">
        <div class="left">
          <m-user-avatar />
          <div class="name">
            <m-user-name />
            <span
              >最高成绩<span class="grade">{{ testScoresInfo.maxScore }}</span
              >分</span
            >
          </div>
        </div>
        <button
          @click="goMockTest"
          class="continue"
          width="90px"
          height="30px"
          text="继续考试"
        >继续考试</button>
      </div>
    </div>
    <div class="summary content-box">
      <div class="item">
        <div>
          <span class="number">{{ testScoresList.length }}</span
          >次
        </div>
        <div>考试次数</div>
      </div>
      <div class="item">
        <div>
          <span class="number">{{ testScoresInfo.avgScore }}</span
          >分
        </div>
        <div>平均成绩</div>
      </div>
      <div class="item">
        <div>
          <span class="number">{{ testScoresInfo.forecastScore }}</span
          >分
        </div>
        <div>成绩预测</div>
      </div>
    </div>
    <div class="test-scores content-box">
      <view class="table">
        <view class="flex lh60" style="font-weight:600">
          <view class="w25per">车型</view>
          <view class="w25per">科目</view>
          <view class="w25per">分数</view>
          <view class="w25per">时间</view>
        </view>
      </view>
      <view class="flex lh60" v-for="(item, index) in testScoresList" :key="index">
        <view class="w25per">{{ item.type }}</view>
        <view class="w25per">{{ item.kskm }}</view>
        <view class="w25per">{{ item.score }}</view>
        <view class="w25per">{{ item.createTime.split(" ")[0] }}</view>
      </view>
    </div>
  </view>
</template>



<script>
import api from "@/api/index";
import utils from "@/utils/index";
export default {
  data() {
    return {
      query:{

      },
      testScoresList: [
     
      ],
      testScoresInfo: {
        maxScore: 0,
        avgScore: 0,
        forecastScore: 0,
      },
    };
  },
  onLoad(query) {
    this.getTestScoresList();
    this.getTestScoresInfo();
    this.query = query
  },
  methods: {
    goMockTest(){
      uni.navigateTo({
        url:'/otherPages/beforeMockExam/index?'+utils.mapToUrlQuery(this.query)
      })

    },
    getTestScoresInfo() {
      api.exam.studentScoreInfoGetScoreInfoAll({}).then((res) => {
 
        this.testScoresInfo = res.data;
      });
    },
    getTestScoresList() {
      api.exam.studentScoreInfoList({}).then((res) => {
        console.log(res)
        this.testScoresList = res.rows;
      });
    },
  },
};
</script>

<style scoped lang="scss">
.lh60{
    line-height: 60rpx;
}
.flex {
  display: flex;
  text-align: center;
}
.w25per {
  width: 25%;
}
.header-back {
  width: 375px;
  padding-bottom: 82px;
  background: linear-gradient(180deg, #498ef5 0%, #4da8e6 100%);
  border-radius: 0px 0px 82px 82px;
  .user-data {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 19px 17px 24px;
    .left {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .name {
        display: flex;
        flex-direction: column;
        font-size: 13px;
        color: #ffffff;
        justify-content: space-between;
        margin-left: 6px;
        .grade {
          font-size: 24px;
          padding: 4px;
        }
      }
    }
    .continue {
      font-size: 24rpx;
      font-family: PingFang SC;
      font-weight: 400;
      line-height: 60rpx;
      color: #ffffff;
      background: #01c18d;
      border-radius:32rpx;
    }
  }
}
.content-box {
  width: 345px;
  background: #ffffff;
  box-shadow: 0px 0px 8px rgba(124, 129, 136, 0.2);
  border-radius: 10px;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  top: -82px;
  margin-top: 10px;
}
.summary {
  display: flex;
  justify-content: space-around;
  padding: 25px 30px;
  box-sizing: border-box;
  .item {
    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 19px;
    color: #8a9099;
    display: flex;
    flex-direction: column;
    align-items: center;
    .number {
      font-size: 24px;
      color: #0a1a33;
      padding: 4px;
    }
  }
}
.test-scores {
  font-size: 13px;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 19px;
  color: #0a1a33;
  padding: 15px;
  box-sizing: border-box;
  .table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    th {
      padding: 5px;
      color: #0a1a33;
    }
    td {
      text-align: center;
      padding: 5px;
      color: #8a9099;
    }
    tr {
      &:nth-of-type(n) {
        background: #ffffff;
      }
      &:nth-of-type(2n) {
        background: rgba(73, 142, 245, 0.15);
      }
    }
  }
}
</style>
