<script lang="tsx">
import { defineComponent } from "vue";
import store from "@/store";
import { Dialog } from "vant";
import { useRouter } from "vue-router";
export default defineComponent({
	props: {
		audioPause:{
			type:Function,
			default:()=>{

			}
		},
		currentSubjectIndex: {
			type: Number,
			default: 0,
		},
		subjectTotal: {
			type: Number,
			default: 0,
		},
		trueNum: {
			type: Number,
			default: 0,
		},
		falseNum: {
			type: Number,
			default: 0,
		},
		officialShow: Boolean,
		showSubjectChangePopup: Boolean,
	},
	emits: {
		"update:officialShow": (value: boolean) => {
			return value;
		},
		"update:showSubjectChangePopup": (value: boolean) => {
			return value;
		},
		nextSubject: () => {},
		lastSubject: () => {},
	},
	setup(props, { emit }) {
		const router = useRouter();
		const isVip = store.getters.getIsVip;
		console.log(router.currentRoute.value)
		const vipClick = () => {
			if (store.getters.getIsVip||router.currentRoute.value.path=="/exerciseFree") {
				emit("update:officialShow", true);
			} else {
				Dialog.confirm({
					title: "温馨提示",
					message: "请购买会员后使用",
					confirmButtonText: "购买",
				}).then(() => {
					router.push("/buyVip");
				});
			}
		};

		return () => {
			return (
				<van-tabbar placeholder route>
					<van-tabbar-item
						onClick={() => {
							emit("lastSubject");
							props.audioPause()
						}}
						v-slots={{
							icon: () => <m-icon type="shangyiti" />,
						}}>
						上一题
					</van-tabbar-item>
					<van-tabbar-item
						v-slots={{
							icon: () => <m-icon type="dui" />,
						}}>
						{props.trueNum}
					</van-tabbar-item>
					<van-tabbar-item
						v-slots={{
							icon: () => <m-icon type="cuo" />,
						}}>
						{props.falseNum}
					</van-tabbar-item>
					<van-tabbar-item
						onClick={() => {
							emit("update:showSubjectChangePopup", true);
						}}
						v-slots={{
							icon: () => <m-icon type="zongtishu" />,
						}}>
						{props.currentSubjectIndex + 1}/{props.subjectTotal}
					</van-tabbar-item>
					<van-tabbar-item
						onClick={() => {
							vipClick()
						}}
						v-slots={{
							icon: () => <m-icon type="gfjs" />,
						}}>
						官方解释
					</van-tabbar-item>
					<van-tabbar-item
						onClick={() => {
							emit("nextSubject");
							props.audioPause()
						}}
						v-slots={{
							icon: () => <m-icon type="xiayiti" />,
						}}>
						下一题
					</van-tabbar-item>
				</van-tabbar>
			);
		};
	},
});
</script>
