<template>
  <view class="bg">
    <m-nav-bar theme="black"></m-nav-bar>
    <div class="result-box">
      <img class="img" v-if="score >= 90" :src="hege" />
      <img class="img" v-if="score < 90" :src="buhege" />
      <view class="intro">
        <div class="fraction-box">
          <text class="fraction">{{ score }}</text>
        </div>
        <view v-if="score >= 90" class="text">恭喜你，测试通过~</view>
        <view v-if="score < 90" class="text" style="color: red"
          >抱歉，测试未通过~</view
        >
        <view class="hint">（满分:100；合格:90）</view>

        <view class="time">
          <text class="time-content">用时：{{ useTime }}</text>
        </view>
        <view class="evaluation"
          ><text v-if="score >= 90"
            >天赋异禀、骨骼惊奇! \n 想来是百年难得一见的考试奇才!</text
          >
          <text v-if="score < 90"
            >学车之路，任重而道远！\n 路漫漫其修远兮，吾将上下而求索。</text
          >
        </view>
        <div class="btn-box">
          <m-button
            width="270rpx"
            height="90rpx"
            @tap="goExerciseSpecify"
            class="btn1"
            text="错题重做"
          />
          <m-button
            width="270rpx"
            height="90rpx"
            @tap="refreshTest"
            class="btn2"
            text="重新测试"
          />
        </div>
      </view>
    </div>
    <!-- <div class="result-box" >
      <img class="img" :src="buhege" />
      <view class="intro">
        <text class="text">抱歉,测试未通过~</text>
        <div class="fraction-box">
          <text class="fraction">{{ score }}</text
          >分
        </div>
        <text class="hint">（满分:100；合格:90）</text>
        <view class="time">
          <text class="time-content">用时：{{ useTime }}</text>
        </view>
        <text class="evaluation"
          >学车之路，任重而道远！路漫漫其修远兮，吾将上下而求索。</text
        >
      </view>
    </div> -->
  </view>
</template>
<script>
import api from "@/api/index";
import utils from "@/utils/index";
import mNavBar from "../../components/m-nav-bar/m-nav-bar.vue";
export default {
  components: { mNavBar },
  data() {
    return {
      hege: "https://ndata.zzxcx.net/ctjk/mp-wx/mockExamEnd/smile.png",
      buhege: "https://ndata.zzxcx.net/ctjk/mp-wx/mockExamEnd/sad.png",
      score: 0,
      useTime: "",
      subject: 1,
      query: {},
      gs: "",
      gsMap: {
        xc: "小车",
        hc: "货车",
        kc: "客车",
        mtc: "摩托车",
      },
    };
  },
  methods: {
    refreshTest() {
      let routes = getCurrentPages();
      if (routes.length < 2) {
        uni.showToast({
          title: "无法重新测试",
          icon: "fail",
        });
        return;
      }
      let prePage = routes[routes.length - 2];
      console.log(prePage);
      uni.redirectTo({
        url: decodeURIComponent(prePage.$page.fullPath),
      });
    },
    goExerciseSpecify() {
      if (!this.query.questionIds) {
        uni.showToast({
          title: "没有错题",
          icon: "none",
        });
        return;
      }
      uni.navigateTo({
        url:
          "/otherPages/exerciseSpecify/index?" +
          utils.mapToUrlQuery(this.query),
      });
    },
  },
  onLoad(query) {
    this.query = query;
    // console.log(getCurrentPages())
    this.score = query.score;
    this.useTime = query.useTime;
    this.subject = query.subject;
    this.gs = query.gs;
 
  },
};
//提交考试成绩
//score=1&useTime=0%3A5&liceCar=1&liceTruck=&liceBus=&liceMoto=&name=%E7%A7%91%E7%9B%AE%E4%B8%80&gs=xc&cert=C1%2FC2%2FC3&vehicle=%E8%BD%BF%E8%BD%A6&subject=1&title=%E6%A8%A1%E6%8B%9F%E8%80%83%E8%AF%95&sort=3&__id__=3
// createTestScores({
// 	type: query.vehicle as string,
// 	kskm: query.name as string,
// 	score: props.userTestData.testScores,
// });
</script>

<style lang="scss" scoped>
.bg {
  background-image: url("https://ndata.zzxcx.net/ctjk/mp-wx/mockExamEnd/bg.png");
}
.result-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30rpx 30rpx;
  .img {
    width: 624rpx;
    height: 529rpx;
    position: absolute;
    top: 0;
  }
  .intro {
    width: 100%;
    display: inline-block;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 20rpx;
    height: 906rpx;
    margin-top: 224rpx;
    .text {
      font-size: 15px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #01c18d;
      line-height: 23px;
      text-align: center;
    }
    .fraction-box {
      font-size: 15px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #8a9099;
      margin-top: 30px;
      width: 100%;
      text-align: center;
      margin-top: 220rpx;
      height: auto;
      .fraction {
        font-size: 87rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #ff4d53;
      }
    }
    .hint {
      font-size: 13px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #8a9099;
      line-height: 23px;
      width: 100%;
      text-align: center;
    }
    .time {
      border-radius: 10rpx;
      width: 100%;
      text-align: center;
      margin-top: 30rpx;
      .time-content {
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #498ef5;
        line-height: 60rpx;
        text-align: center;
        color: #498ef5;
        border-radius: 15rpx;
        background: #e4eefe;
        padding: 20rpx 60rpx;
        width: auto;
      }
    }

    .evaluation {
      margin-top: 30px;
      font-size: 15px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #5c6066;
      line-height: 23px;
      width: 100%;
      text-align: center;
    }
  }
}
.btn-box {
  margin: 0 auto;
  width: 600rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
  font-size: 15px;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 23px;
  margin-top: 90rpx;
  .btn1 {
    background-color: #498ef5;
    border-radius: 40rpx;
  }
  .btn2 {
    background-color: #01c18d;
    border-radius: 40rpx;
  }
}
</style>
