Files
umed/web/pages/faq.vue
T
2026-07-09 14:35:32 +08:00

490 lines
13 KiB
Vue

<script setup lang="ts">
import {
faqContentBundle,
type FaqItem,
type FaqAnswerBlock
} from '~/data/faq-content'
import { officialSocialLinks } from '~/data/social-links'
import { buildFaqPageJsonLd } from '~/utils/faq-jsonld'
import { siteVisibility } from '~/data/site-visibility'
if (!siteVisibility.showFaqPage) {
throw createError({ statusCode: 404, statusMessage: 'Not Found' })
}
const content = useLocalized(faqContentBundle)
usePageSeo({
title: () => content.value.faqMeta.pageTitle,
description: () => content.value.faqMeta.description,
ogTitle: () => content.value.faqMeta.ogTitle,
ogImage: () => content.value.faqHero.image,
jsonLd: () => buildFaqPageJsonLd(content.value.faqItems)
})
const searchQuery = ref('')
const filteredItems = computed(() => {
const q = searchQuery.value.trim().toLowerCase()
if (!q) return content.value.faqItems
return content.value.faqItems.filter((item) => faqMatchesQuery(item, q))
})
function faqMatchesQuery(item: FaqItem, q: string): boolean {
if (item.question.toLowerCase().includes(q)) return true
return item.blocks.some((block) => blockText(block).toLowerCase().includes(q))
}
function blockText(block: FaqAnswerBlock): string {
if (block.type === 'paragraph') {
return block.parts.map((p) => p.value).join('')
}
return block.items.map((row) => row.map((p) => p.value).join('')).join(' ')
}
</script>
<template>
<div class="faq-page">
<section class="faq-hero" :aria-label="content.faqUi.heroAriaLabel">
<img
class="faq-hero__bg"
:src="content.faqHero.image"
:alt="content.faqHero.imageAlt"
fetchpriority="high"
/>
<div class="faq-hero__wash" aria-hidden="true" />
<div class="container faq-hero__inner">
<h1 class="faq-hero__title">{{ content.faqHero.title }}</h1>
<div class="faq-hero__intro">
<template v-for="(block, bi) in content.faqIntro" :key="`intro-${bi}`">
<p v-if="block.type === 'paragraph'" class="faq-hero__p">
<template v-for="(part, pi) in block.parts" :key="pi">
<NuxtLink
v-if="part.kind === 'link'"
:to="part.to"
class="faq-hero__link"
>
{{ part.label }}
</NuxtLink>
<template v-else>{{ part.value }}</template>
</template>
</p>
</template>
</div>
</div>
</section>
<div class="container faq-page__inner">
<header class="faq-head">
<h2 class="faq-head__title">{{ content.faqPageTitle }}</h2>
<div class="faq-search" role="search">
<div class="faq-search__field">
<input
id="faq-search-input"
v-model="searchQuery"
type="search"
class="faq-search__input"
:placeholder="content.faqSearchLabel"
autocomplete="off"
:aria-label="content.faqSearchLabel"
/>
<svg
class="faq-search__icon"
width="18"
height="18"
viewBox="0 0 24 24"
aria-hidden="true"
>
<circle
cx="11"
cy="11"
r="7"
fill="none"
stroke="currentColor"
stroke-width="2"
/>
<path
d="M16 16l5 5"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
/>
</svg>
</div>
</div>
</header>
<p v-if="filteredItems.length === 0" class="faq-empty">
{{ content.faqUi.emptyBeforeLink }}
<NuxtLink to="/#contact" class="faq-intro__link">{{
content.faqUi.emptyContactLabel
}}</NuxtLink>{{ content.faqUi.emptySuffix }}
</p>
<article
v-for="item in filteredItems"
:id="item.id"
:key="item.id"
class="faq-item"
>
<h2 class="faq-item__q">{{ item.question }}</h2>
<div class="faq-item__body">
<template v-for="(block, bi) in item.blocks" :key="`${item.id}-${bi}`">
<p v-if="block.type === 'paragraph'" class="faq-item__p">
<template v-for="(part, pi) in block.parts" :key="pi">
<NuxtLink
v-if="part.kind === 'link'"
:to="part.to"
class="faq-intro__link"
>
{{ part.label }}
</NuxtLink>
<template v-else>{{ part.value }}</template>
</template>
</p>
<ul v-else class="faq-item__list">
<li v-for="(row, ri) in block.items" :key="ri">
<template v-for="(part, pi) in row" :key="pi">
<NuxtLink
v-if="part.kind === 'link'"
:to="part.to"
class="faq-intro__link"
>
{{ part.label }}
</NuxtLink>
<template v-else>{{ part.value }}</template>
</template>
</li>
</ul>
</template>
<div class="faq-item__share" :aria-label="content.faqUi.shareAriaLabel">
<a
:href="officialSocialLinks.tiktok"
target="_blank"
rel="noopener noreferrer"
class="faq-item__share-btn"
:title="content.faqUi.shareTikTokTitle"
:aria-label="content.faqUi.shareTikTokAriaLabel"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path
fill="currentColor"
d="M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 0 1-5.2 1.74 2.89 2.89 0 0 1 2.31-4.64 2.93 2.93 0 0 1 .88.13V9.4a6.84 6.84 0 0 0-1-.05A6.33 6.33 0 0 0 5 20.1a6.34 6.34 0 0 0 10.86-4.43v-7a8.16 8.16 0 0 0 4.77 1.52v-3.4a4.85 4.85 0 0 1-1-.1z"
/>
</svg>
</a>
<a
:href="officialSocialLinks.youtube"
target="_blank"
rel="noopener noreferrer"
class="faq-item__share-btn"
:title="content.faqUi.shareYouTubeTitle"
:aria-label="content.faqUi.shareYouTubeAriaLabel"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path
fill="currentColor"
d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"
/>
</svg>
</a>
<a
v-if="siteVisibility.showXiaohongshuSocial"
:href="officialSocialLinks.xiaohongshu"
target="_blank"
rel="noopener noreferrer"
class="faq-item__share-btn"
:title="content.faqUi.shareXiaohongshuTitle"
:aria-label="content.faqUi.shareXiaohongshuAriaLabel"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path
fill="currentColor"
d="M6 2h12a1 1 0 0 1 1 1v18l-2.5-1.5L14 21l-2.5-1.5L9 21l-2.5-1.5L4 21V3a1 1 0 0 1 1-1z"
/>
</svg>
</a>
<a
:href="officialSocialLinks.whatsapp"
target="_blank"
rel="noopener noreferrer"
class="faq-item__share-btn"
:title="content.faqUi.shareWhatsAppTitle"
:aria-label="content.faqUi.shareWhatsAppAriaLabel"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path
fill="currentColor"
d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 0 1-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 0 1-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 0 1 2.893 6.994c-.003 5.45-4.435 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0 0 12.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 0 0 5.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413z"
/>
</svg>
</a>
</div>
</div>
</article>
</div>
</div>
</template>
<style scoped>
.faq-page {
background: #fff;
}
/* Hero — 虚化医疗场景 + 高亮蒙层 + 居中标题/导语 */
.faq-hero {
position: relative;
overflow: hidden;
min-height: 280px;
display: flex;
align-items: center;
justify-content: center;
padding: 56px 0 60px;
}
.faq-hero__bg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center 35%;
filter: blur(6px);
transform: scale(1.06);
}
.faq-hero__wash {
position: absolute;
inset: 0;
background: linear-gradient(
180deg,
rgba(255, 255, 255, 0.88) 0%,
rgba(248, 252, 255, 0.82) 50%,
rgba(255, 255, 255, 0.9) 100%
);
pointer-events: none;
}
.faq-hero__inner {
position: relative;
z-index: 1;
max-width: 820px;
text-align: center;
}
.faq-hero__title {
margin: 0 0 22px;
font-size: clamp(26px, 3.2vw, 36px);
font-weight: 700;
line-height: 1.3;
color: #1d63a3;
}
.faq-hero__intro {
margin: 0;
}
.faq-hero__p {
margin: 0;
font-size: 15px;
line-height: 1.75;
color: var(--ink);
text-align: center;
}
.faq-hero__link {
color: inherit;
text-decoration: underline;
text-underline-offset: 3px;
}
.faq-hero__link:hover {
color: var(--blue);
}
.faq-page__inner {
max-width: 920px;
padding: 48px 32px 72px;
}
.faq-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 32px;
margin-bottom: 24px;
flex-wrap: wrap;
}
.faq-head__title {
font-size: clamp(28px, 3.5vw, 40px);
font-weight: 700;
color: var(--blue-light);
line-height: 1.2;
margin: 0;
flex: 1;
min-width: 240px;
}
.faq-search {
flex-shrink: 0;
min-width: 220px;
max-width: 280px;
}
.faq-search__field {
position: relative;
display: flex;
align-items: center;
border-bottom: 1px solid var(--ink);
padding-bottom: 4px;
}
.faq-search__input {
width: 100%;
border: none;
background: transparent;
font-size: 14px;
font-family: inherit;
color: var(--ink);
padding: 6px 28px 6px 0;
outline: none;
}
.faq-search__input::placeholder {
color: var(--ink);
opacity: 1;
}
.faq-search__input::-webkit-search-cancel-button {
-webkit-appearance: none;
}
.faq-search__icon {
position: absolute;
right: 0;
bottom: 8px;
color: var(--ink);
pointer-events: none;
}
.faq-intro__link {
color: var(--blue);
font-weight: 600;
text-decoration: underline;
text-underline-offset: 3px;
}
.faq-intro__link:hover {
color: var(--blue-light);
}
.faq-empty {
font-size: 15px;
color: var(--muted);
padding: 24px 0;
}
.faq-item {
padding: 0 0 28px;
margin-bottom: 28px;
border-bottom: 1px solid #d8dde3;
}
.faq-item:last-child {
border-bottom: none;
margin-bottom: 0;
padding-bottom: 0;
}
.faq-item__q {
font-size: 17px;
font-weight: 700;
color: var(--ink);
line-height: 1.45;
margin: 0 0 14px;
}
.faq-item__body {
margin-bottom: 0;
}
.faq-item__p {
font-size: 15px;
line-height: 1.75;
color: var(--ink);
margin: 0 0 12px;
}
.faq-item__p:last-child {
margin-bottom: 0;
}
.faq-item__list {
margin: 0 0 12px;
padding-left: 1.25rem;
font-size: 15px;
line-height: 1.75;
color: var(--ink);
}
.faq-item__list li {
margin-bottom: 8px;
}
.faq-item__list li:last-child {
margin-bottom: 0;
}
.faq-item__share {
display: flex;
align-items: center;
gap: 20px;
margin: 14px 0 0;
}
.faq-item__share-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
border: 0;
background: transparent;
color: #111;
padding: 0;
cursor: pointer;
line-height: 1;
}
.faq-item__share-btn svg {
width: 14px;
height: 14px;
display: block;
}
@media (max-width: 720px) {
.faq-hero {
padding: 40px 0 44px;
min-height: 240px;
}
.faq-page__inner {
padding: 32px 20px 56px;
}
.faq-head {
flex-direction: column;
align-items: stretch;
}
.faq-search {
max-width: none;
width: 100%;
}
}
</style>