<template>
  <view>
    <view class="h-16 bg-back my-32"></view>
    <view class="px-30 pt-13 pb-24 text-32 text-fore-title font-bold">真题&模拟</view>
    <view class="">
      <view class="overflow-hidden bg-white sticky z-2" :style="{ top: baseStickyTop + 'px' }">
        <view class="px-30 pt-24 pb-30 text-32 text-fore-title font-bold flex items-center gap-44 bg-back rounded-t-15">
          <view :class="['relative text-fore-light', { 'is-active': current === 0 }]" @click="handleChange(0)">公共课
          </view>
          <view :class="['relative text-fore-light', { 'is-active': current === 1 }]" @click="handleChange(1)">专业课
          </view>
        </view>
      </view>

      <view v-if="list.length > 0" class="px-30 pb-24 bg-back flex flex-col gap-20 sticky z-1 "
        :style="{ top: baseStickyTop + 20 + 'px' }">
        <vhs-exam-item v-for="(item, index) in list" :key="index" :data="item" :type="current" />
      </view>
      <view v-else class="bg-white">
        <z-paging-empty-view :empty-view-fixed="false" />
      </view>
    </view>
  </view>
</template>
<script lang="ts" setup>
import VhsExamItem from '@/pagesStudy/components/vhs-exam-item.vue';
import { useTransferPage } from '@/hooks/useTransferPage';
import { useNavbar } from '@/hooks/useNavbar';
import { getVHSPaperList } from '@/api/modules/study';
import { Study, Transfer } from '@/types';

const { transferTo } = useTransferPage();
const { baseStickyTop } = useNavbar();
const list = ref<Study.VHSPaper[]>([]);
const current = ref(0);
const handleChange = (index: number) => {
  current.value = index;
  loadData();
}
const loadData = async () => {
  list.value = [];
  const { data } = await getVHSPaperList({
    subjectId: current.value
  });
  list.value = data;
}
onShow(() => {
  loadData();
});
</script>
<style lang="scss" scoped>
.is-active {
  @apply text-fore-title;

  &::after {
    content: '';
    display: block;
    width: 20px;
    height: 4px;
    background: radial-gradient(0% 0% at 0% 0%, #31A0FC 0%, #70C8FD 100%);
    position: absolute;
    bottom: 0;
    border-radius: 4rpx;
    left: 50%;
    transform: translateX(-50%);
    bottom: -8rpx;
  }
}
</style>