<template>
  <div class="collectBank">
    <div class="collectBank-box">
      <!-- 头部标题 -->
      <div class="collectBank-box__head">
        <van-nav-bar title="收藏" left-arrow @click-left="onClickLeft()" />
      </div>
      <!-- 间距 -->
      <div class="margin20"></div>
      <!-- 中部收藏数量显示 -->
      <div class="collectBank-box__item">
        <img src="../../assets/user/record.png" />
        <p>
          <span>{{ allData.collect_num }}</span
          >题
        </p>
      </div>
      <!-- 间距 -->
      <div class="margin20"></div>
      <!-- 底部内容显示 -->
      <div class="collectBank-box__bottom">
        <div class="collectBank-box__bottom-text">
          今日收藏： {{ allData.today_collect }}
        </div>
        <van-button
          style="height:32px;line-height:30px"
          round
          type="warning"
          @click="openSort"
          >开始练习</van-button
        >
      </div>
    </div>
    <sort
      v-if="showSort"
      @closeSort="closeSort"
      :type="type"
      name="Exercise"
      :categoryid="categoryid"
    />
  </div>
</template>

<script>
import { CollectTkHome, GetCountCollectTk } from "@/api/user";
export default {
  name: "CollectBank",
  data() {
    return {
      allData: {},
      allDataList: [],
      showSort: false,
      categoryid: this.$route.query.categoryid || 0,
      type: 3
    };
  },
  methods: {
    openSort() {
      this.showSort = true;
    },
    closeSort() {
      this.showSort = false;
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    collectTkHome() {
      CollectTkHome({
        categoryid: this.$route.query.categoryid
      }).then(res => {
        if (res.result == true) {
          this.allData = res.data;
        }
      }),
        GetCountCollectTk({
          categoryid: this.$route.query.categoryid
        }).then(res => {
          if (res.result == true) {
            this.allDataList = res.data;
          }
        });
    }
  },
  created() {
    this.collectTkHome();
  },
  activated() {
    document.title = "收藏练习";
    this.collectTkHome();
  }
};
</script>

<style scoped>
.van-icon-arrow-left {
  color: #4d4c4c !important;
}
.collectBank-box {
  width: 100%;
  min-height: 100vh;
  background: #fff;
}
/* 头部 */
.collectBank-box__head {
  width: 100%;
  position: relative;
  font-size: 0.875rem;
}
.collectBank-box__head-title {
  text-align: center;
  line-height: 2.5rem;
}
.collectBank-box__head-retrun {
  height: 2.5rem;
  line-height: 2.5rem;
  position: absolute;
  top: 0;
  left: 0.625rem;
}
/* 间距 */
.margin20 {
  width: 100%;
  height: 0.3125rem;
  background: #f5f5f5;
}
/* 内容区 */
.collectBank-box__item {
  width: 100%;
  height: 10.5rem;
  position: relative;
}

.collectBank-box__item img {
  width: 10rem;
  height: 7.5rem;
  position: absolute;
  left: 50%;
  margin-left: -5rem;
  top: 1.5rem;
}
.collectBank-box__item p {
  /* font-weight: bold; */
  font-size: 0.8rem;
  color: #000;
  width: 80px;
  position: absolute;
  left: 50%;
  margin-left: -40px;
  top: 4.2rem;
  color: #fff;
  text-align: center;
}
.collectBank-box__item p span {
  font-size: 2rem;
}
/* 查看收藏按钮 */
.seeBtn {
  width: 6rem;
  height: 1.7rem;
  color: #fff;
  font-size: 18px;
  background: #fca492;
  border-radius: 0.75rem;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 9.3rem;
  left: 50%;
  margin-left: -3rem;
  font-weight: bold;
  letter-spacing: 2px;
}
/* 底部内容显示 */
.collectBank-box__bottom {
  margin-top: 1rem;
  color: #333;
  /* font-weight: bold; */
  width: 90%;
  margin: 1.5rem auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.collectBank-box__bottom-text {
  font-size: 14px;
  /* font-family: PingFang-SC-Medium; */
  font-weight: 500;
  color: rgba(51, 51, 51, 1);
}
.collectBank-box__bottom-btn {
  width: 116px;
  height: 34px;
  line-height: 34px;
  border-radius: 34px;
  border: 1px solid #ff795c;
  background: #ff795c;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  /* font-family: PingFang-SC-Bold;
  font-weight: bold;
  color: rgba(51, 51, 51, 1); */
}
</style>
