<template>
  <ks-page-scroll-container :page="page" :page-count="pageCount" @page-change="getList">
    <div class="practiceRecord">
      <!-- 头部标题 -->
      <van-nav-bar title="每日一练" left-arrow @click-left="onClickLeft()" />
      <!-- 间距 -->
      <div class="margin20"></div>

      <!-- 练习记录列表 -->
      <div class="practiceRecord-item" v-if="showList" style="padding-top:10px;">
        <div class="practiceRecord-box" v-for="(item, i) in allData" :key="i">
          <div class="practiceRecord-box_top">
            <div class="practiceRecord-box_title">
              <ul>
                <li>{{ item.time }}</li>
              </ul>
            </div>
            <!-- <span>正确率：{{item.zhunquelv}}%</span> -->
          </div>
          <div class="practiceRecord-box_bottom">
            <div class="practiceRecord-box_type">
              <div>练习时间：{{ item.week }}</div>
              <div class="type-flex">练习类型：每日一练</div>
            </div>
            <router-link
              tag="div"
              :to="{
                name: 'Exercise',
                query: { type:6, title:item.time, categoryid: $route.query.categoryid, day: item.day }
              }"
              class="practiceRecord-box_see"
            >开始做题</router-link>
          </div>
        </div>
      </div>
      <!-- 无数据提示 -->
      <Nodata v-if="showNodata" />
    </div>
  </ks-page-scroll-container>
</template>

<script>
import { GetDailyTestDateList } from "@/api/paper";
export default {
  name: "PracticeDaily",
  data() {
    return {
      value: null,
      allData: [],
      pageCount: 0,
      page: 0,
      showList: true,
      showNodata: false
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    getList(p = 1) {
      GetDailyTestDateList({
        page: p,
        pagesize: 10,
        categoryid: this.$route.query.categoryid
      }).then(res => {
        if (res.result == true) {
          this.allData = this.allData.concat(res.data);
          this.page = p;
          this.pageCount = res.pagecount;
          this.showList = true;
          this.showNodata = false;
        } else {
          this.showList = false;
          this.showNodata = true;
          this.page = 0;
          this.pageCount = 0;
        }
      });
    }
  },
  mounted() {},
  activated() {
    document.title = "每日一练";
    this.allData = [];
    this.getList();
  }
};
</script>

<style scoped>
.van-icon-arrow-left {
  color: #4d4c4c !important;
}
.practiceRecord {
  width: 100%;
  min-height: 100vh;
  background: #fff;
}
/* 间距 */
.margin20 {
  width: 100%;
  height: 10px;
  background: #f5f5f5;
}

/* 练习记录列表 */
.practiceRecord-item {
  width: 90%;
  margin: 0 auto;
  background: #fff;
}
.practiceRecord-box {
  margin-bottom: 13px;
  border-bottom: 1px solid #ebedef;
}
.practiceRecord-box_top {
  margin-top: 3px;
  width: 100%;
  min-height: 16px;
}
.practiceRecord-box_title {
  width: 75%;
  font-size: 14px;
  color: #333;
  float: left;
}
.practiceRecord-box_title ul li {
  list-style: disc inside none;
}
.practiceRecord-box_top span {
  width: 25%;
  float: right;
  text-align: right;
}
.practiceRecord-box_bottom {
  margin-top: 6px;
  width: 100%;
  height: 32px;
  display: flex;
  justify-content: space-between;
}

.practiceRecord-box_type {
  width: 75%;
  font-size: 10px;
  color: #999;
  display: flex;
  justify-content: space-between;
}
.practiceRecord-box_see {
  font-size: 11px;
  color: #fff;
  width: 58px;
  height: 18px;
  border-radius: 9px;
  background: #ff795c;
  text-align: center;
  line-height: 18px;
}
.type-flex {
  display: flex;
}
</style>
