285 lines
7.9 KiB
Vue
285 lines
7.9 KiB
Vue
<script setup lang="ts">
|
|
import { doctorImageNeedsTopFocus, getDoctorImageAdjust } from '~/data/doctor-image-focus'
|
|
|
|
const { page, hospitals, doctors, getHospitalById, getDoctorsByHospitalId } =
|
|
useLocalizedHospitals()
|
|
const { locale } = useSiteLocale()
|
|
const localePath = useLocalePath()
|
|
|
|
const route = useRoute()
|
|
|
|
const hospitalIdFromRoute = computed(() => {
|
|
const h = route.query.hospital
|
|
return typeof h === 'string' ? h : ''
|
|
})
|
|
|
|
const selectedHospitalId = ref('')
|
|
const departmentQuery = ref('')
|
|
const nameQuery = ref('')
|
|
|
|
watch(
|
|
hospitalIdFromRoute,
|
|
(id) => {
|
|
selectedHospitalId.value = id
|
|
},
|
|
{ immediate: true }
|
|
)
|
|
|
|
const activeHospital = computed(() =>
|
|
selectedHospitalId.value ? getHospitalById(selectedHospitalId.value) : undefined
|
|
)
|
|
|
|
const baseDoctors = computed(() => {
|
|
if (selectedHospitalId.value) {
|
|
return getDoctorsByHospitalId(selectedHospitalId.value)
|
|
}
|
|
return doctors.value
|
|
})
|
|
|
|
const filteredDoctors = computed(() => {
|
|
const deptQ = departmentQuery.value.trim().toLowerCase()
|
|
const nameQ = nameQuery.value.trim().toLowerCase()
|
|
|
|
return baseDoctors.value.filter((d) => {
|
|
const dept = d.department?.toLowerCase() ?? ''
|
|
const name = d.name?.toLowerCase() ?? ''
|
|
const label = d.expertLabel?.toLowerCase() ?? ''
|
|
const info = d.expertInfo?.toLowerCase() ?? ''
|
|
|
|
if (deptQ && !dept.includes(deptQ)) return false
|
|
if (nameQ && !name.includes(nameQ) && !label.includes(nameQ) && !info.includes(nameQ)) {
|
|
return false
|
|
}
|
|
return true
|
|
})
|
|
})
|
|
|
|
const pageTitle = computed(() =>
|
|
activeHospital.value
|
|
? page.value.doctors.titleAtHospital(activeHospital.value.name)
|
|
: page.value.doctors.title
|
|
)
|
|
|
|
const specialistCountLabel = computed(() => {
|
|
const n = filteredDoctors.value.length
|
|
return locale.value === 'zh' ? `${n} 位专家` : `${n} specialist${n === 1 ? '' : 's'}`
|
|
})
|
|
|
|
usePageSeo({
|
|
routeKey: '/doctors',
|
|
titlePrefix: () => activeHospital.value?.name,
|
|
title: () => formatPageTitle(page.value.doctors.title, locale.value),
|
|
description: () =>
|
|
locale.value === 'zh'
|
|
? '优医合作医院科室主任与首席医师,可按医院与科室筛选。'
|
|
: 'Leading department heads and chief physicians from UMedGlobal partner hospitals in China. Filter by hospital and department.',
|
|
path: '/doctors'
|
|
})
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<section class="page-hero">
|
|
<div class="container">
|
|
<h1 class="page-hero__title">{{ pageTitle }}</h1>
|
|
<p class="page-hero__desc">
|
|
{{ activeHospital ? page.doctors.descAtHospital : page.doctors.descAll }}
|
|
</p>
|
|
<NuxtLink v-if="activeHospital" :to="localePath('/hospitals')" class="back-link">
|
|
{{ page.doctors.backLink }}
|
|
</NuxtLink>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="section section--tight" :class="{ 'section--soft': !activeHospital }">
|
|
<div class="container">
|
|
<div class="toolbar">
|
|
<label class="toolbar__field">
|
|
<span class="toolbar__label">{{ page.doctors.hospitalLabel }}</span>
|
|
<select
|
|
v-model="selectedHospitalId"
|
|
class="toolbar__select"
|
|
@change="navigateTo({ path: localePath('/doctors'), query: selectedHospitalId ? { hospital: selectedHospitalId } : {} })"
|
|
>
|
|
<option value="">{{ page.doctors.allHospitals }}</option>
|
|
<option v-for="h in hospitals" :key="h.id" :value="h.id">
|
|
{{ h.name }}
|
|
</option>
|
|
</select>
|
|
</label>
|
|
<label class="toolbar__field">
|
|
<span class="toolbar__label">{{ page.doctors.departmentLabel }}</span>
|
|
<input
|
|
v-model="departmentQuery"
|
|
type="search"
|
|
:placeholder="page.doctors.searchDepartment"
|
|
autocomplete="off"
|
|
/>
|
|
</label>
|
|
<label class="toolbar__field">
|
|
<span class="toolbar__label">{{ page.doctors.doctorNameLabel }}</span>
|
|
<input
|
|
v-model="nameQuery"
|
|
type="search"
|
|
:placeholder="page.doctors.searchDoctor"
|
|
autocomplete="off"
|
|
/>
|
|
</label>
|
|
<p class="toolbar__count">
|
|
{{ specialistCountLabel }}
|
|
</p>
|
|
<button
|
|
v-if="selectedHospitalId || departmentQuery || nameQuery"
|
|
type="button"
|
|
class="toolbar__reset"
|
|
@click="selectedHospitalId = ''; departmentQuery = ''; nameQuery = ''; navigateTo(localePath('/doctors'))"
|
|
>
|
|
{{ page.doctors.clearFilters }}
|
|
</button>
|
|
</div>
|
|
|
|
<div v-if="filteredDoctors.length" class="grid-d">
|
|
<DoctorCard
|
|
v-for="d in filteredDoctors"
|
|
:key="d.id"
|
|
:image="d.image"
|
|
:name="d.name"
|
|
:department="d.expertInfo ? undefined : d.department"
|
|
:expert-info="d.expertInfo"
|
|
:hospital-name="activeHospital ? undefined : d.hospitalName"
|
|
:image-focus-top="doctorImageNeedsTopFocus(d.id)"
|
|
:image-fit="getDoctorImageAdjust(d.id)?.fit"
|
|
:image-position="getDoctorImageAdjust(d.id)?.position"
|
|
:image-scale="getDoctorImageAdjust(d.id)?.scale"
|
|
:media-background="getDoctorImageAdjust(d.id)?.mediaBackground"
|
|
/>
|
|
</div>
|
|
<p v-else class="empty">{{ page.doctors.empty }}</p>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.page-hero {
|
|
background: linear-gradient(180deg, #f3f9ff 0%, #ffffff 100%);
|
|
padding: 32px 0 16px;
|
|
}
|
|
.section--tight {
|
|
padding-top: 24px;
|
|
}
|
|
.page-hero__title {
|
|
font-size: clamp(28px, 4vw, 44px);
|
|
font-weight: 800;
|
|
color: #0f2740;
|
|
margin: 0;
|
|
line-height: 1.2;
|
|
}
|
|
.page-hero__desc {
|
|
margin-top: 12px;
|
|
color: var(--muted);
|
|
max-width: 760px;
|
|
}
|
|
.back-link {
|
|
display: inline-block;
|
|
margin-top: 14px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: var(--blue);
|
|
}
|
|
.back-link:hover {
|
|
text-decoration: underline;
|
|
}
|
|
.toolbar {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: flex-end;
|
|
gap: 16px 20px;
|
|
margin-bottom: 32px;
|
|
}
|
|
.toolbar__field {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
min-width: min(100%, 200px);
|
|
flex: 1;
|
|
max-width: 280px;
|
|
}
|
|
.toolbar__label {
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
letter-spacing: 0.04em;
|
|
text-transform: uppercase;
|
|
color: var(--muted);
|
|
}
|
|
.toolbar__field input,
|
|
.toolbar__field select {
|
|
height: 44px;
|
|
padding: 0 12px;
|
|
border: 1px solid #d6e4f0;
|
|
border-radius: 10px;
|
|
font-size: 14px;
|
|
background: #fafcfe;
|
|
}
|
|
.toolbar__select {
|
|
appearance: none;
|
|
-webkit-appearance: none;
|
|
padding-right: 28px;
|
|
cursor: pointer;
|
|
background-color: #fafcfe;
|
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5 5 6.5 8 3.5' fill='none' stroke='%236b7f94' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
background-repeat: no-repeat;
|
|
background-position: right 16px center;
|
|
background-size: 10px 10px;
|
|
}
|
|
.toolbar__field input:focus,
|
|
.toolbar__field select:focus {
|
|
outline: none;
|
|
border-color: var(--blue-light);
|
|
box-shadow: 0 0 0 3px rgba(72, 164, 252, 0.2);
|
|
}
|
|
.toolbar__select:focus {
|
|
background-color: #fafcfe;
|
|
}
|
|
.toolbar__count {
|
|
display: flex;
|
|
align-items: center;
|
|
align-self: flex-end;
|
|
height: 44px;
|
|
margin: 0;
|
|
font-size: 14px;
|
|
color: var(--muted);
|
|
white-space: nowrap;
|
|
}
|
|
.toolbar__reset {
|
|
height: 44px;
|
|
padding: 0 16px;
|
|
border: 1px solid #d6e4f0;
|
|
border-radius: 10px;
|
|
background: #fff;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: var(--blue);
|
|
cursor: pointer;
|
|
}
|
|
.toolbar__reset:hover {
|
|
background: #f0f7ff;
|
|
}
|
|
.grid-d {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
gap: 28px;
|
|
}
|
|
.empty {
|
|
color: var(--muted);
|
|
font-size: 16px;
|
|
padding: 24px 0;
|
|
}
|
|
@media (max-width: 560px) {
|
|
.grid-d {
|
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
}
|
|
}
|
|
</style>
|