<script>
import { getDetailsMap } from "@/api/user";
export default {
  name: "practiceSuccess",
  data() {
    return {
      score: 0,
      detailsMap: {},
    };
  },
  methods: {
    // 进入考场选择页面
    determine() {
      let params = sessionStorage.getItem("params");
      let data = JSON.parse(params);
      this.$router.push("/examModule?" + data.user_id);
    },
    //进入详情页面
    goDetails() {
      let params = sessionStorage.getItem("params");
      let data = JSON.parse(params);
      this.$router.push(
        `/examDetails?id=${this.detailsMap.result_id}&score=${this.detailsMap.score}&user_id=${data.user_id}&examine_time=${this.detailsMap.examine_time}&exam_name=${this.detailsMap.exam_name}&pass_score=${this.detailsMap.pass_score}`
      );
    },
    //通过resultId获取需要传到详情页的数据
    getDetailsData() {
      getDetailsMap({ result_id: this.$route.query.result_id })
        .then((res) => {
          this.detailsMap = res.data.data;
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  mounted() {
    this.score = this.$route.query.score;
    this.getDetailsData();
  },
};
</script>

<template>
  <div class="page">
    <div class="success-page">
      <div class="success-font">您已成功交卷，请继续下一场考试。</div>
      <div class="success-score">
        <p class="score">{{ score }}</p>
        <p class="unit">分</p>
      </div>
      <div class="success-btn">
        <img @click="goDetails" src="@/assets/image/viewAnalysis.png" />
        <img @click="determine" src="@/assets/image/returnList.png" />
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.page {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 100%;
  align-items: center;
  .success-page {
    width: 1773px;
    position: relative;
    height: 858px;
    background-image: url("../../assets/image/success-bg.png");
    background-size: 100% 100%;
  }
  .success-font {
    margin-top: 200px;
    text-align: center;
    font-size: 26px;
    color: rgba(255, 255, 255, 1);
  }
  .success-score {
    margin-top: 85px;
    text-align: center;
    .score {
      font-weight: 700;
      font-size: 72px;
      color: #658cf6;
    }
    .unit {
      font-weight: 400;
      font-size: 26px;
      color: #ffffff;
    }
  }
  .success-btn {
    width: 600px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    font-size: 20px;
    color: rgba(255, 255, 255, 1);
    position: absolute;
    bottom: 95px;
    left: 50%;
    margin-left: -300px;
    // background-image: url("../../assets/image/highlight-btn.png");
    display: flex;
    justify-content: space-between;
    img {
      cursor: pointer;
    }
  }
}
</style>
