<template>
	<m-nav-bar :title="query.title" />
	<div class="cell-box">
		<van-cell
			class="cell"
			:title="item.placeIssueName || item.classIssueName || item.excellIssueName || item.sequeIssueName"
			is-link
			center
			v-for="(item, index) in classData"
			:key="index"
			:border="false"
			@click="
				() => {
					push({
						name: 'exercise',
						query: {
							...query,
							classIssueName: item.classIssueName,
							placeIssueName: item.placeIssueName,
							excellIssueName: item.excellIssueName,
							sequeIssueName: item.sequeIssueName,
							placeIssue: item.placeIssue,
							classIssue: item.classIssue,
							excellIssue: item.excellIssue,
							sequeIssue: item.sequeIssue,
						},
					});
				}
			">
			<template #icon>
				<div class="icon">{{ index + 1 }}</div>
			</template>
		</van-cell>
		<view class="classify-tip">
			<m-classify-tip :content="classifyTip"></m-classify-tip>
		</view>
	</div>
</template>

<script setup lang="ts">
import { getTopicClass } from "@/api";
import { ref } from "vue";
import { RouterBus } from "@/hooks";
const {
	route: { query },
	router: { push },
} = new RouterBus();
const classData = ref([]);
const classifyTip = query.title === "地方专题" ? ref(["地方题库,如有个别地区增加【地方题库】,请选择该区域的【地方题库】+【必学题】学习,如果没有无需学习地方题库"]) : ref(["分类练习,学员可重点学习自己不懂的题目.", "建议新学员直接看软件必考题技巧,快速学习"]);
getTopicClass(query.path as string, query).then(({ data }) => {
	//地方专题第一个选项去掉
	if (query.title == "地方专题") {
		data.data?.shift();
	}

	classData.value = data.data;
});
</script>

<style lang="scss" scoped>
.classify-tip {
	width: 375px;
	margin-top: 20px;
}
.cell-box {
	display: flex;
	padding: 5px 15px;
	flex-wrap: wrap;
	justify-content: space-between;
	.cell {
		width: 167px;
		margin-top: 10px;
		box-shadow: 0px 0px 10px rgba(124, 129, 136, 0.2);
	}
	.icon {
		width: 20px;
		height: 20px;
		background: #498ef5;
		border-radius: 50%;
		font-weight: 500;
		font-family: PingFang SC;
		font-size: 13px;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #ffffff;
		margin-right: 5px;
	}
}
</style>
