<template>
  <div>
    <div class="header">
      <span> 测试时间:</span>
      <span>{{ store.state.beginTime }}</span>
      <span>~</span>
      <span>{{ store.state.endTime }}</span>
    </div>
    <div class="score">
      <div class="button1">得分</div>
      <canvas width="250" height="250" id="score"></canvas>
    </div>
    
    <div @click="backView" class="bottom-button">
      <button>结束考试</button>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted } from 'vue';
import Phone from '@/utils/phone';
import { useStore } from 'vuex';
import ScoreCirle from "@/utils/scoreCirle"
import { useRoute } from 'vue-router';
export default defineComponent({
  setup() {
    const store = useStore();
    const query = useRoute().query
    onMounted(() => {
      const c: HTMLCanvasElement = document.getElementById('score') as HTMLCanvasElement;
      const context: CanvasRenderingContext2D = c.getContext('2d') as CanvasRenderingContext2D;
        let scoreCirle = new ScoreCirle(context,{
            score:Number(query.score),
            total:Number(query.total),
            lineWidth:12
        })
        scoreCirle.init()
    });

    const phone = new Phone();
    //解决this指向的问题
    let backView = phone.backView.bind(phone)
    // phone.displayCol();
    return {
      store,
      backView
      
    
    };
  },
});
</script>

<style lang="scss" scoped>
.header {
  font-size: 24px;
  line-height: 64px;
  height: 64px;
  border-bottom: 1px solid #d8d8d8;
}
.bottom-button{

  bottom: 0;
  margin-top: 25px;
  button{
    border: 0;
    color: #fff;
    font-size: 35px;
    background: #2589fa;
    line-height: 100px;
    width: 250px;
    height: 100px;
    border-radius: 44px;

  }
  
}
.score {
  margin-top: 40px;
  display: flex;
  flex-flow: column wrap;
  align-content: center;
  align-items: center;
  #score{
    margin-top: 25px;
  }
  .button1 {
    width: 300px;
    height: 70px;
    border-radius: 24px;
    overflow: hidden;
    color: #fff;
    line-height: 70px;
    background-image: linear-gradient(to bottom right, rgb(112, 170, 252), #2589fa);
  }
}
</style>