<script setup lang="ts">
import { ref,computed } from "vue";
import { useI18n } from "vue-i18n";
// 使用接口定义
const { t } = useI18n()
const faqList = computed(()=>{
	return [
		{
			id: 1,
			title: t('helpCentre.faqItem1'),
			content: t('helpCentre.faqItem1Content'),
		},
		{
			id: 2,
			title: t('helpCentre.faqItem2'),
			content: t('helpCentre.faqItem2Content'),
		},
		{
			id: 3,
			title: t('helpCentre.faqItem3'),
			content: t('helpCentre.faqItem3Content'),
		},
		{
			id: 4,
			title: t('helpCentre.faqItem4'),
			content: t('helpCentre.faqItem4Content'),
		},
		{
			id: 5,
			title: t('helpCentre.faqItem5'),
			content: t('helpCentre.faqItem5Content'),
		},
		{
			id: 6,
			title: t('helpCentre.faqItem6'),
			content: t('helpCentre.faqItem6Content'),
		},
		{
			id: 7,
			title: t('helpCentre.faqItem7'),
			content: t('helpCentre.faqItem7Content'),
		},
	]
})
const openIdList = ref([])
const openInfo = (id) => {
	if(openIdList.value.includes(id)){
		openIdList.value = openIdList.value.filter(item => item !== id)
	}else{
		openIdList.value.push(id)
	}
}
defineExpose({})
</script>
<template>
	<section class="faq">
		<div class="content">
			<h2>{{ t('helpCentre.FAQ') }}</h2>
			<div class="faq-list">
				<div v-for="item in faqList" :key="item.id" class="faq-item">
					<h2 @click="openInfo(item.id)">
						{{ item.title }}
						<span class="iconfont icon-sanjiao_xia" :class="{'active': openIdList.includes(item.id)}"></span>
					</h2>
					<div class="info" :class="{'active': openIdList.includes(item.id)}">
						<p>{{ item.content }}</p>
					</div>
				</div>
			</div>
		</div>
	</section>
</template>
<style lang="less" scoped>
	.faq{
		width: 100%;
		padding: 60px 0;
		background-color: #f9f9f9;
		@media (max-width: 1000px) {
			padding: 40px 0;
		}
		> .content{
			max-width: 1140px;
			margin: 0 auto;
			@media (max-width: 1000px) {
				max-width: 1000px;
			}
			> h2{
				
				font-family: "Poppins", Sans-serif;
				font-size: 40px;
				font-weight: 600;
				letter-spacing: 1px;
				color: #000000;
				margin-bottom: 40px;
				line-height: 1;
				text-align: center;
				@media (max-width: 1000px) {
					font-size: 28px;
				}
			}
			
			> .faq-list{
				@media (max-width: 1000px) {
					padding: 0 20px;
				}
				> .faq-item{
					border-bottom: 1px solid #d5d8dc;
					> h2{
						padding: 40px 0px 40px 0px;
						font-family: "Poppins", Sans-serif;
						font-size: 24px;
						line-height: 1.5em;
						color: #333333;
						font-weight: 700;
						display: flex;
						align-items: flex-start;
						justify-content: space-between;
						cursor: pointer;
						@media (max-width: 1000px) {
							padding: 20px 0;
							font-size: 16px;
						}
						> span{
							font-size: 14px;
							transition: all .3s;
							&.active{
								transform: rotate(180deg);
							}
						}
					}
					> .info{
						height: 0;
						overflow: hidden;
						transition: all .3s;
						&.active{
							height: 70px;
						}
						> p{
							padding: 15px;
							color: #333333;
							font-weight: 400;
							font-size: 14px;
							line-height: 20px;
							margin-bottom: 20px;
							@media (max-width: 1000px) {
								padding: 12px;
							}
						}
					}
				}
			}
		}
	}
</style>
