<template>
  <div class="com-bg topic">
    <div class="com-title"></div>
    <div class="com-card">
      <div class="result">
        <div class="top">
          <p>本次答对题目数</p>
          <h6>{{ num || 0 }}</h6>
        </div>
        <div class="text">
          <div class="li">正确率：{{ Math.round(num/all * 100) }}%</div>
          <div class="li">错题数：{{ all - num }}</div>
        </div>
        <div class="btn-cont">
          <div class="com-btn" @click="fnGoTopic">再来一组</div>
          <div class="com-btn" @click="fnGoOut">点击进入</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Result",
  data() {
    return {
      all: 0,
      num: 0,
    }
  },
  created() {
    this.all = this.$route.query.all ? Number(this.$route.query.all) : 0;
    this.num = this.$route.query.num ? Number(this.$route.query.num) : 0;
  },
  methods: {
    fnGoTopic() {
      this.$router.push(`/topic`);
    },
    fnGoOut() {
      // 跳转到安徽小康
      // window.location.href = 'http://wap.ahjlxkgc.cn';
      
      window.parent.postMessage('quiz over', '*')
    }
  }
};
</script>

<style lang="less" scoped>
.topic {
  min-height: 100vh;
  box-sizing: border-box;
  padding: 29px 16px;
  text-align: right;
}
.result {
  .top {
    min-height: 144px;
    background: url(../../assets/images/contbg.png) top center no-repeat;
    background-size: 100% auto;
    box-sizing: border-box;
    padding: 30px 0 0 33px;
    font-size: 16px;
    font-weight: 400;
    color: #56390F;
    line-height: 24px;
    h6 {
      font-size: 40px;
      font-weight: 400;
      color: #56390F;
      line-height: 50px;
      margin-top: 15px;
    }
  }
  .text {
    font-size: 16px;
    font-weight: 400;
    color: #181E24;
    line-height: 26px;
    margin-top: 30px;
    margin-bottom: 60px;
    box-sizing: border-box;
    padding: 0 30px;
    .li {
      display: inline-block;
      width: 50%;
      box-sizing: border-box;
      padding-left: 10px;
    }
  }
  .btn-cont {
    .com-btn {
      width: 145px;
      height: 43px;
      line-height: 43px;
      margin-left: 18px;
      &:nth-child(2n+1) {
        box-sizing: border-box;
        border: 1px solid #B4A387;
        background: #ffffff;
        color: #B59F87;
        line-height: 41px;
      }
    }
  }
}
.com-title {
  height: 18px;
  background: url(../../assets/images/title.png) center no-repeat;
  background-size: auto 100%;
  margin-bottom: 26px;
}
.com-bg {
  background: #F6F6F6 url(../../assets/images/bg.png) center top no-repeat;
  background-size: 100% auto;
}
.com-btn {
  cursor: pointer;
  display: inline-block;
  min-width: 70px;
  text-align: center;
  box-sizing: border-box;
  padding: 0 14px;
  background: #b59f87;
  border-radius: 4px;
  height: 32px;
  line-height: 32px;
  font-size: 14px;
  font-weight: 500;
  color: #ffffff;
  margin-left: 10px;
}
.com-card {
  margin-top: 17px;
  background: #ffffff;
  box-shadow: 0px 4px 4px 0px rgba(225, 225, 225, 0.5);
  border-radius: 4px;
  box-sizing: border-box;
  padding-bottom: 15px;
  font-size: 16px;
  font-weight: 400;
  color: #181e24;
  line-height: 30px;
  text-align: left;
  .title {
    font-size: 19px;
    font-weight: 600;
    color: #181e24;
    line-height: 58px;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0 12px 0 25px;
    border-bottom: 1px solid #ededed;
    position: relative;
    &::before {
      content: "";
      position: absolute;
      left: 14px;
      top: 20px;
      width: 3px;
      height: 18px;
      background: #e51d0e;
    }
    .right {
      float: right;
      font-size: 19px;
      color: #999999;
      line-height: 50px;
      & > span {
        font-size: 35px;
        font-weight: 500;
        color: #181e24;
        line-height: 50px;
      }
    }
  }
  .content {
    box-sizing: border-box;
    padding: 20px 12px 0;
    .tit {
      margin-bottom: 25px;
    }
  }
}
.com-option {
  background: #fbfcfe;
  border: 1px solid #f3f4f6;
  border-radius: 4px;
  box-sizing: border-box;
  margin-bottom: 12px;
  padding: 11px 19px;
  font-size: 16px;
  font-weight: 400;
  color: #999999;
  line-height: 28px;
  overflow: hidden;
  &>span {
    float: left;
    width: 28px;
    height: 28px;
    text-align: right;
    box-sizing: border-box;
    padding-right: 10px;
  }
  &.act {
    background: #F6F5F3;
    border: 1px solid #B4A387;
    font-weight: 500;
    color: #B7A08B;
    &>span {
      color: #ffffff;
      background: url(../../assets/images/fingerprint.png) left center no-repeat;
      background-size: auto 100%;
    }
  }
  &.true {
    background: #E7F7EC;
    font-weight: 500;
    color: #2CC638;
    border-color: #E7F7EC;
    &>span {
      color: transparent;
      background: url(../../assets/images/true.png) left center no-repeat;
      background-size: 15px auto;
    }
  }
  &.false {
    background: #FBEDED;
    font-weight: 500;
    color: #E55352;
    border-color: #FBEDED;
    &>span {
      color: transparent;
      background: url(../../assets/images/false.png) left center no-repeat;
      background-size: 15px auto;
    }
  }
}
</style>