336 lines
8.3 KiB
Vue
336 lines
8.3 KiB
Vue
<!-- 页面编号:T-07;用途:成员目录、搜索、空态与失败状态。 -->
|
||
<template>
|
||
<view
|
||
class="directory-page"
|
||
:class="{
|
||
'directory-state--loading': directoryState === 'loading',
|
||
'directory-state--list': directoryState === 'list',
|
||
'directory-state--empty': directoryState === 'empty',
|
||
'directory-state--error': directoryState === 'error',
|
||
}"
|
||
>
|
||
<ModulePageBackground module="tree" />
|
||
<view class="directory-page__header"><PageHeader title="成员目录" /></view>
|
||
<view class="directory-context">
|
||
<text class="directory-context__name">汤氏家谱</text>
|
||
<text class="directory-context__meta"
|
||
>主支 · {{ members.length }} 位成员</text
|
||
>
|
||
</view>
|
||
<view
|
||
v-if="directoryState === 'list' || directoryState === 'empty'"
|
||
class="directory-search"
|
||
>
|
||
<input
|
||
v-model="keyword"
|
||
aria-label="成员搜索关键词"
|
||
placeholder="按姓名、字辈或支系查找"
|
||
placeholder-class="directory-placeholder"
|
||
@confirm="searchMembers"
|
||
/>
|
||
<view
|
||
class="directory-search__action"
|
||
role="button"
|
||
aria-label="查找成员"
|
||
hover-class="action-hover"
|
||
@click="searchMembers"
|
||
><text>查找</text></view
|
||
>
|
||
</view>
|
||
<view class="directory-content">
|
||
<AppLoading
|
||
v-if="directoryState === 'loading'"
|
||
text="正在整理成员目录"
|
||
description="请稍候,正在读取成员与世代信息。"
|
||
/>
|
||
<template v-else-if="directoryState === 'list'">
|
||
<view class="directory-summary"
|
||
><text>家谱成员</text
|
||
><text>{{ filteredMembers.length }} 人 · 按世代排列</text></view
|
||
>
|
||
<view
|
||
v-for="item in filteredMembers"
|
||
:key="item.id"
|
||
class="directory-card"
|
||
@click="openMember(item)"
|
||
>
|
||
<view class="directory-card__copy">
|
||
<text class="directory-card__name">{{ item.name }}</text>
|
||
<text class="directory-card__meta"
|
||
>第 {{ item.generation }} 世 · {{ item.generationName }} ·
|
||
{{ item.branch }}</text
|
||
>
|
||
<text class="directory-card__status">{{ item.note }}</text>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
<view v-else class="directory-state-card">
|
||
<view
|
||
><text>{{
|
||
directoryState === "empty" ? "没有找到相关成员" : "成员目录暂不可用"
|
||
}}</text
|
||
><text>{{
|
||
directoryState === "empty"
|
||
? "换一个姓名、字辈或支系关键词再试。"
|
||
: "请从当前家谱重新进入,成员资料不会受到影响。"
|
||
}}</text></view
|
||
>
|
||
</view>
|
||
<AppButton
|
||
v-if="directoryState === 'error'"
|
||
block
|
||
type="secondary"
|
||
label="重新查看"
|
||
@click="retryDirectory"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
<script setup>
|
||
import { computed, ref } from "vue";
|
||
import { onLoad } from "@dcloudio/uni-app";
|
||
import AppButton from "@/components/AppButton.vue";
|
||
import AppLoading from "@/components/AppLoading.vue";
|
||
import ModulePageBackground from "@/components/ModulePageBackground.vue";
|
||
import PageHeader from "@/components/PageHeader.vue";
|
||
const genealogyId = ref("");
|
||
const keyword = ref("");
|
||
const directoryState = ref("loading");
|
||
const members = [
|
||
{
|
||
id: 101,
|
||
name: "汤文远",
|
||
generation: 12,
|
||
generationName: "文字辈",
|
||
branch: "主支",
|
||
note: "始祖 · 档案完整",
|
||
},
|
||
{
|
||
id: 102,
|
||
name: "汤正国",
|
||
generation: 13,
|
||
generationName: "正字辈",
|
||
branch: "长房",
|
||
note: "家谱管理员",
|
||
},
|
||
{
|
||
id: 103,
|
||
name: "汤正华",
|
||
generation: 13,
|
||
generationName: "正字辈",
|
||
branch: "二房",
|
||
note: "资料待补充",
|
||
},
|
||
];
|
||
const filteredMembers = computed(() => {
|
||
const value = keyword.value.trim();
|
||
if (!value) return members;
|
||
return members.filter((item) =>
|
||
`${item.name}${item.generationName}${item.branch}`.includes(value),
|
||
);
|
||
});
|
||
onLoad((query) => {
|
||
genealogyId.value = query.genealogyId || "";
|
||
directoryState.value =
|
||
query.state === "loading"
|
||
? "loading"
|
||
: query.state === "empty"
|
||
? "empty"
|
||
: query.state === "error"
|
||
? "error"
|
||
: "list";
|
||
});
|
||
const searchMembers = () => {
|
||
directoryState.value = filteredMembers.value.length ? "list" : "empty";
|
||
};
|
||
const retryDirectory = () => {
|
||
directoryState.value = "list";
|
||
};
|
||
const openMember = (item) =>
|
||
uni.navigateTo({
|
||
url: `/pages/tree/t03-member-profile?genealogyId=${genealogyId.value}&personId=${item.id}`,
|
||
});
|
||
</script>
|
||
<style scoped lang="scss">
|
||
.directory-page {
|
||
display: flex;
|
||
min-height: 100vh;
|
||
flex-direction: column;
|
||
overflow-y: auto;
|
||
background: $paper;
|
||
}
|
||
.directory-page__header,
|
||
.directory-context,
|
||
.directory-search,
|
||
.directory-content {
|
||
z-index: 2;
|
||
}
|
||
.directory-context {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
box-sizing: border-box;
|
||
padding: 22rpx 32rpx 0;
|
||
}
|
||
.directory-context__name {
|
||
color: $ink;
|
||
font-family: "STKaiti", "KaiTi", serif;
|
||
font-size: 32rpx;
|
||
font-weight: 700;
|
||
}
|
||
.directory-context__meta {
|
||
color: #62584c;
|
||
font-size: 24rpx;
|
||
font-weight: 500;
|
||
}
|
||
.directory-search {
|
||
display: grid;
|
||
width: calc(100% - 48rpx);
|
||
min-height: 44px;
|
||
margin: 20rpx auto 0;
|
||
background: url("/static/assets/modules/tree/transparent/t07-search-input-frame.png")
|
||
center / 100% 100% no-repeat;
|
||
}
|
||
.directory-search input {
|
||
z-index: 1;
|
||
grid-area: 1 / 1;
|
||
min-height: 44px;
|
||
margin-right: 110rpx;
|
||
margin-left: 26rpx;
|
||
color: $ink;
|
||
font-size: 26rpx;
|
||
line-height: 44px;
|
||
}
|
||
.directory-search__action {
|
||
z-index: 1;
|
||
display: flex;
|
||
grid-area: 1 / 1;
|
||
justify-self: end;
|
||
min-width: 88rpx;
|
||
min-height: 44px;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-right: 8rpx;
|
||
color: $brand-red;
|
||
font-size: 24rpx;
|
||
font-weight: 700;
|
||
}
|
||
.directory-placeholder {
|
||
color: #776956;
|
||
}
|
||
.directory-content {
|
||
padding: 22rpx 24rpx 50rpx;
|
||
}
|
||
.directory-summary {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
margin: 0 8rpx 18rpx;
|
||
}
|
||
.directory-summary text:first-child {
|
||
color: $ink;
|
||
font-family: "STKaiti", "KaiTi", serif;
|
||
font-size: 29rpx;
|
||
font-weight: 700;
|
||
}
|
||
.directory-summary text:last-child {
|
||
color: $ink-muted;
|
||
font-size: 23rpx;
|
||
}
|
||
.directory-card {
|
||
display: flex;
|
||
width: 100%;
|
||
min-height: 196rpx;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
margin-bottom: 16rpx;
|
||
padding: 18rpx 28rpx;
|
||
background: url("/static/assets/modules/genealogy/transparent/list-slip-frame.png")
|
||
center / 100% 100% no-repeat;
|
||
}
|
||
.directory-card__copy {
|
||
z-index: 1;
|
||
display: flex;
|
||
min-width: 0;
|
||
flex: 1;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
}
|
||
.directory-card__name {
|
||
color: $ink;
|
||
font-family: "STKaiti", "KaiTi", serif;
|
||
font-size: 31rpx;
|
||
font-weight: 700;
|
||
line-height: 1.3;
|
||
overflow-wrap: anywhere;
|
||
}
|
||
.directory-card__meta {
|
||
margin-top: 7rpx;
|
||
color: #62584c;
|
||
font-size: 24rpx;
|
||
line-height: 1.45;
|
||
overflow-wrap: anywhere;
|
||
}
|
||
.directory-card__status {
|
||
align-self: flex-start;
|
||
margin-top: 8rpx;
|
||
padding: 2rpx 10rpx;
|
||
border: 1rpx solid rgba(174, 45, 36, 0.32);
|
||
color: $brand-red;
|
||
font-size: 22rpx;
|
||
line-height: 30rpx;
|
||
}
|
||
.directory-state-card {
|
||
display: flex;
|
||
width: 100%;
|
||
min-height: 220rpx;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 16rpx;
|
||
padding: 48rpx 12%;
|
||
box-sizing: border-box;
|
||
background: url("/static/assets/modules/genealogy/transparent/list-slip-frame.png")
|
||
center / 100% 100% no-repeat;
|
||
}
|
||
.directory-state-card {
|
||
margin-top: 70rpx;
|
||
}
|
||
.directory-state-card > view {
|
||
z-index: 1;
|
||
text-align: center;
|
||
}
|
||
.directory-state-card text {
|
||
display: block;
|
||
}
|
||
.directory-state-card text:first-child {
|
||
color: $ink;
|
||
font-family: "STKaiti", "KaiTi", serif;
|
||
font-size: 30rpx;
|
||
font-weight: 700;
|
||
}
|
||
.directory-state-card text:last-child {
|
||
margin-top: 14rpx;
|
||
color: $ink-muted;
|
||
font-size: 24rpx;
|
||
line-height: 1.5;
|
||
}
|
||
.directory-content > .app-button {
|
||
margin: 20rpx auto 0;
|
||
}
|
||
@media screen and (max-width: 340px) {
|
||
.directory-card {
|
||
min-height: 192rpx;
|
||
padding-right: 22rpx;
|
||
padding-left: 22rpx;
|
||
}
|
||
.directory-card__name {
|
||
font-size: 29rpx;
|
||
}
|
||
.directory-card__meta {
|
||
font-size: 22rpx;
|
||
}
|
||
.directory-card__status {
|
||
font-size: 20rpx;
|
||
}
|
||
}
|
||
</style>
|