<template>
  <view style="background-image:url('https://ct.zzxcx.net/ctjk/mp-wx/testScores/bg.png')" class="vh100">
    <div class="header-back">
      <m-nav-bar
        :transparent="true"
        title="模拟考试成绩"
        style="color: #ffffff"
      />
      <div class="user-data">
        <div class="left">
          <image class="head" :src="headImage"></image>
          <div class="name">
            <m-user-name />
            <span
              >最高成绩<span class="grade">{{ testScoresInfo.maxScore }}</span
              >分</span
            >
          </div>
        </div>
        <view class="right">
          <view
            @click="goMockTest"
            class="continue"
            width="90px"
            height="30px"
            text="继续考试"
          >
            继续考试
            <van-icon size="28rpx" color="#498EF5" name="arrow" />
          </view>
        </view>
      </div>
    </div>
    <div style="background-image:url('https://ct.zzxcx.net/ctjk/mp-wx/testScores/summaryBg1.png')" 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="w120">车型</view>
          <view class="w120">科目</view>
          <view class="w120">分数</view>
          <view style="text-align: center" class="flex-grow-1">时间</view>
        </view>
      </view>
      <view
        class="flex lh100"
        v-for="(item, index) in testScoresList"
        :key="index"
        :style="{
          background: index % 2 == 1 ? '#fff' : 'rgba(73,142,245,0.15);',
        }"
      >
        <view class="w120">{{ item.type }}</view>
        <view
          v-if="item.kskm == '科目四' || item.kskm == '科目一'"
          class="w120"
          >{{ item.kskm }}</view
        >
        <view v-else class="w120">{{
          item.kskm == 1 ? "科目一" : "科目四"
        }}</view>

        <view class="w120">{{ item.score }}</view>
        <view style="text-align: center" class="flex-grow-1">{{
          item.createTime
        }}</view>
      </view>
    </div>
    <view style="padding: 0 30rpx">
      <ad
        class="wxad"
        :ad-intervals="100"
        unit-id="adunit-f9ac1a546be5b3f0"
      ></ad>
    </view>
  </view>
</template>



<script>
import api from "@/api/index";
import utils from "@/utils/index";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      userInfo: uni.getStorageSync("userInfo"),
      query: {},
      testScoresList: [],
      testScoresInfo: {
        maxScore: 0,
        avgScore: 0,
        forecastScore: 0,
      },
    };
  },
  computed: {
    headImage() {
      return this.$store.state.user.userInfo.headImage;
    },
  },
  onLoad(query) {
    this.query = query;
    this.getTestScoresList();
    this.getTestScoresInfo();
  },
  methods: {
    goMockTest() {
      uni.navigateTo({
        url:
          "/otherPages/beforeMockExam/index?" + utils.mapToUrlQuery(this.query),
      });
    },
    getTestScoresInfo() {
      api.exam.studentScoreInfoGetScoreInfoAll({}).then((res) => {
        if (res.data) {
          this.testScoresInfo = res.data;
        }
      });
    },
    getTestScoresList() {
      api.exam
        .studentScoreInfoList({
          type: this.query.vehicle,
        })
        .then((res) => {
          console.log(res);

          this.testScoresList = res.rows;
        });
    },
  },
};
</script>

<style scoped lang="scss">
.vh100{
  height: 100vh;
}
.pl20 {
  padding-left: 20rpx;
}
.pr20 {
  padding-right: 20rpx;
}
.lh60 {
  line-height: 60rpx;
}
.lh100 {
  line-height: 100rpx;
}
.flex {
  display: flex;
  text-align: center;
}
.flex-grow-1 {
  flex-grow: 1;
}
.w25per {
  width: 25%;
}
.w20per {
  width: 25%;
}
.w120per {
  width: 40%;
}
.w120 {
  width: 120rpx;
}
.header-back {
  width: 750rpx;
  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-left: 30rpx;
    .left {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .head {
        width: 112rpx;
        height: 112rpx;
      }
      .name {
        display: flex;
        flex-direction: column;
        font-size: 13px;
        color: #ffffff;
        justify-content: space-between;
        margin-left: 6px;
        .grade {
          font-size: 48rpx;
          padding: 4px;
        }
      }
    }
    .right {
      display: inline-block;
      .continue {
        width: 200rpx;
        line-height: 60rpx;
        background: #ebf8ff;
        border-radius: 60rpx 0px 0px 60rpx;
        opacity: 1;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        line-height: 60rpx;
        color: #ffffff;
        background: #ebf8ff;
        color: #498ef5;
        padding-left: 36rpx;
      }
    }
  }
}
.content-box {
  width: 690rpx;

  box-shadow: 0px 0px 8px rgba(124, 129, 136, 0.2);
  border-radius: 10px;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  top: -82px;

}
.summary {
  display: flex;
  justify-content: space-around;
 padding-top: 60rpx;
 padding-bottom: 40rpx;
  box-sizing: border-box;
  background-size: 100%;
  background-repeat: no-repeat;
  width: 642rpx;

  .item {
    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 19px;
    color: #B3DBFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    .number {
      font-size: 24px;
      color: #fff;
      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;
  background: #fff;
  .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>
