<style scoped>
.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}
.clearfix{overflow:hidden;_zoom:1;}
input{background:none;outline:none;border:0px;}
.text-gray{color:#717171;}
.text-orange{color:#eb7741;}
.text-danger{color:#c03546;}
.text-blue{color: #3A8AFB;}
.AnswerResult{background-color:#f3f6ff;}
.arContent{padding:1rem 3% 2rem;text-align: center;background-color:#fff;border-bottom:1px solid #f3f6ff;}
.arScore{position:relative;padding-bottom: 2rem;}
.arTitle{font-weight: 600;font-size: 0.9rem;margin-bottom:1.6rem;word-wrap:break-word;}
.arFraction{width:7.6rem;margin:0 auto;padding: 1.8rem 0;background-color: #3A8AFB;border-radius: 50%;color:#fff;height:4rem;overflow: hidden;
/*background: url(https://release-sup8-images.oss-cn-shanghai.aliyuncs.com/h5_key/studyCenter/icon-scoreCircle.png) no-repeat left 0.1rem;background-size: 100% 100%;*/}
.arFraction span:nth-of-type(1){font-size: 3rem;}
.arFraction span:nth-of-type(2){font-size: 0.7rem;}
.arTip{width:100%;position: absolute;top:5.6rem;text-align: center;color: #fff;}
.arTip p{width:12rem;margin:0 auto;padding:0.6rem 0;padding-bottom:2.4rem;background: url(https://release-sup8-images.oss-cn-shanghai.aliyuncs.com/h5_key/studyCenter/icon-colorBar.png) no-repeat left 0.1rem;background-size: 100% 100%;}
.arGift{font-size: 0.9rem;font-weight: 600;word-wrap:break-word;}
.arIntroduction{background-color:#fff;padding:1rem 10%;}
.arQuestion{display: flex;}
.arQuestion p{flex:1;text-align: center;}
.arQuestion p:nth-of-type(1){text-align: left;}
.arQuestion p:nth-last-of-type(1){text-align: right;}
.arAnswerTime{text-align: left;}
.mint-button{margin:0 auto;background-color:#3A8AFB;border-radius: 0.2rem;position: absolute;bottom:0;height: 3rem;}
</style>
<template v-cloak>     
  <div class="jfBaseSize AnswerResult" v-cloak v-bind:style="isShow.vh?'height:100vh':'height: 100%;'">
    <div class="arContent">
      <p class="arTitle" v-html="(model.PaperName?model.PaperName:'-')"></p>
      <div class="arScore">
        <div>
          <p class="arFraction">
            <span v-html="(model.Score?model.Score:'0')"></span>
            <span>分</span>
          </p>
        </div>
        <div class="arTip">
          <p>考试成绩</p>
        </div>
      </div>
      <p class="arGift text-blue" v-html="'获得奖励'+(model.Gift_Name?model.Gift_Name:'-')" v-if="model.PrizeId"></p>
    </div>
    <div class="arIntroduction">
      <div class="arQuestion">
        <p>题量：{{(model.QuestionCount)}}题</p>
        <p>正确：{{(model.RightCount)}}题</p>
        <p>错误：{{(model.QuestionCount-model.RightCount)}}题</p>
      </div>
      <div class="arAnswerTime">
        <p>考试用时：{{(model.AnswerTime?model.AnswerTime:'-')}}</p>
      </div>
    </div>
    <mt-button class="btnAddClerk" type="danger" size="large" v-on:click="repeatAnswerGO">重新答题</mt-button>
   <ReturnHome ref="returnhome"></ReturnHome>
  </div>
</template>
<script>
import Vue from 'vue';
import { Toast,Indicator } from 'mint-ui';
import channelHelper from "@/assets/js/channelHelper.js";
import '@/assets/js/libs/js.cookie';
	import ReturnHome from "@/components/channel/temp001/ReturnHome";
import utils from "@/assets/js/utils.js";
export default {
  props: [],
   components: {ReturnHome},
  provide(){       
     return{           
        goPage:this.goPage       
     }   
  },
  data() {
    return {
      isShow:{
        vh:true,
      },
      model:{
        ID:'',
        PaperId:'',
        PaperName:'',
        Score:'',
        AnswerTime:'',
        QuestionCount:'',
        RightCount:'',
        PrizeId:'',
        Gift_Name:'',
        GiftType:'',
        Amount:'',
        UnitPoints:'',
        UnitMoney:'',
      },
      searchRequest:{
        EnterpriseNo:'',
        UserToken:'',
        LanguageType:"zh-cn",
        ID:''
      },
    }
  },
  methods: {
    goPage(pagetype){
        this.$parent.changeSelectedPage(pagetype);
    },
    //配置获取
    H5GetPaperAnswerRecord(){
      var that=this;
      var url = "/channel/H5GetPaperAnswerRecord";
      var dataParams = that.searchRequest;
      Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          if(data&&data.ID){
            if(data.PrizeId){
              if(data.GiftType==2){
                if(data.Amount&&data.UnitMoney){
                  data.Gift_Name=Number(data.Amount)*Number(data.UnitMoney)+'元红包';
                }else{
                  data.Gift_Name='0元红包';
                }
              }else if(data.GiftType==4){
                if(data.Amount&&data.UnitPoints){
                  data.Gift_Name=parseInt(data.Amount)*parseInt(data.UnitPoints)+'积分';
                }else{
                  data.Gift_Name='0积分';
                }
              }
            }
            that.$set(that,'model',data);
          }else{
            Toast('未获取到相关记录，请稍后重试');
          }
        }else
        { 
            Toast(res.msg);
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        Toast(jqXHR.responseText);
      };
      //请求后端
      channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    repeatAnswerGO(){
      var that=this;
      sessionStorage.setItem('S_AnswerSendRepeatId',that.model.PaperId);
      this.goPage("S_AnswerD");
    },
    judgeLogin:function(){
      var eno = this.sup8.context.enterpriseno;
      if (!channelHelper.CheckLogin(this.$parent,eno,this.sup8.context.entranceid)) {
        this.$parent.changeSelectedPage('Key_Login');
        return false;
      }
    },
  },
  watch: {},
  created: function() {
    var that = this;
    //判断是否登录
    that.judgeLogin();
    var ID=sessionStorage.getItem('S_AnswerSendResultId');
    if(ID){
      that.$set(that,'model',ID);
      that.$set(that,'searchRequest',{
        EnterpriseNo:this.sup8.context.enterpriseno,
        UserToken:channelHelper.GetUserToken(),
        LanguageType:"zh-cn",
        ID:ID
      });
      that.H5GetPaperAnswerRecord();
      sessionStorage.removeItem('S_AnswerSendResultId');
    }else{
      Toast('未获取到相关记录，请稍后重试');
    }
  },
  mounted: function() {
    var that =this;
    var isDesign = location.pathname.indexOf('design');
    if (!(isDesign>-1)) {
        that.$set(that.isShow,'vh',true);
    }else{
        that.$set(that.isShow,'vh',false);
    }
  }
};
</script>

