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

171 lines
4.1 KiB
Vue

<script setup lang="ts">
const { page, hospitals } = useLocalizedHospitals()
const { locale } = useSiteLocale()
const localePath = useLocalePath()
usePageSeo({
title: () => formatPageTitle(locale.value === 'zh' ? '特色医院' : 'Featured Hospitals', locale.value),
description: () =>
locale.value === 'zh'
? '浏览中国 JCI 认证及三甲合作医院,按名称搜索并查看简介与官网。'
: 'Browse JCI-accredited and Grade 3A partner hospitals in China. Search by name and view profiles with official website links.'
})
const query = ref('')
const filteredHospitals = computed(() => {
const q = query.value.trim().toLowerCase()
if (!q) return hospitals.value
return hospitals.value.filter(
(h) =>
h.name.toLowerCase().includes(q) ||
h.intro.toLowerCase().includes(q) ||
h.id.toLowerCase().includes(q)
)
})
const hospitalCountLabel = computed(() => {
const n = filteredHospitals.value.length
return locale.value === 'zh' ? `${n} 家医院` : `${n} hospital${n === 1 ? '' : 's'}`
})
</script>
<template>
<div>
<section class="page-hero">
<div class="container">
<h1 class="page-hero__title">{{ page.hospitals.title }}</h1>
<p class="page-hero__desc">{{ page.hospitals.desc }}</p>
</div>
</section>
<section class="section section--tight">
<div class="container">
<div class="toolbar">
<label class="toolbar__search">
<span class="sr-only">{{ page.hospitals.searchPlaceholder }}</span>
<input
v-model="query"
type="search"
:placeholder="page.hospitals.searchPlaceholder"
autocomplete="off"
/>
</label>
<p class="toolbar__count">{{ hospitalCountLabel }}</p>
</div>
<div v-if="filteredHospitals.length" class="grid-h">
<NuxtLink
v-for="h in filteredHospitals"
:key="h.id"
:to="{ path: localePath('/doctors'), query: { hospital: h.id } }"
class="grid-h__link"
>
<HospitalCard
:image="h.image"
:name="h.name"
:intro="h.intro"
:url="h.url"
:official-website-label="page.hospitals.officialWebsite"
/>
</NuxtLink>
</div>
<p v-else class="empty">{{ page.hospitals.empty }}</p>
</div>
</section>
</div>
</template>
<style scoped>
.page-hero {
background: linear-gradient(180deg, #f3f9ff 0%, #ffffff 100%);
padding: 32px 0 8px;
}
.section--tight {
padding-top: 12px;
}
.page-hero__title {
font-size: clamp(28px, 4vw, 44px);
font-weight: 800;
color: #0f2740;
margin: 0;
line-height: 1.2;
}
.page-hero__desc {
margin: 12px 0 0;
color: var(--muted);
max-width: 760px;
}
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px 24px;
margin-bottom: 28px;
}
.toolbar__search {
flex: 1;
min-width: min(100%, 280px);
max-width: 420px;
}
.toolbar__search input {
width: 100%;
height: 48px;
padding: 0 18px;
border: 1px solid #d6e4f0;
border-radius: 12px;
font-size: 15px;
background: #fafcfe;
transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.toolbar__search input:focus {
outline: none;
border-color: var(--blue-light);
box-shadow: 0 0 0 3px rgba(72, 164, 252, 0.2);
}
.toolbar__count {
font-size: 14px;
color: var(--muted);
}
.grid-h {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 28px;
}
.grid-h__link {
display: block;
text-decoration: none;
color: inherit;
border-radius: var(--radius);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.grid-h__link:hover {
transform: translateY(-4px);
box-shadow: var(--shadow-lg);
}
.grid-h__link:focus-visible {
outline: 2px solid var(--blue);
outline-offset: 4px;
}
.empty {
color: var(--muted);
font-size: 16px;
padding: 24px 0;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
@media (max-width: 560px) {
.grid-h {
grid-template-columns: 1fr;
}
}
</style>