完成50%
This commit is contained in:
@@ -97,7 +97,7 @@
|
||||
<text
|
||||
class="result-card__relation"
|
||||
:class="`result-card__relation--${item.relation}`"
|
||||
>{{ item.actionLabel }}</text
|
||||
>{{ resultRelationLabel(item) }}</text
|
||||
>
|
||||
</view>
|
||||
<view class="result-card__facts">
|
||||
@@ -113,9 +113,10 @@
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
v-if="resultActionLabel(item)"
|
||||
class="result-card__action"
|
||||
@click.stop="handleResultAction(item)"
|
||||
>{{ item.actionLabel }}</view
|
||||
>{{ resultActionLabel(item) }}</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
@@ -159,6 +160,7 @@
|
||||
maxlength="12"
|
||||
placeholder="请输入邀请码"
|
||||
placeholder-class="search-input__placeholder"
|
||||
@input="resetInvite"
|
||||
/>
|
||||
</view>
|
||||
<view class="search-action" @click="verifyInvite">
|
||||
@@ -179,7 +181,7 @@
|
||||
>
|
||||
<text class="search-status__lead">通过邀请码直接定位家谱</text>
|
||||
<text class="search-status__copy"
|
||||
>验证有效后会显示目标家谱,确认关系后可直接加入。</text
|
||||
>验证有效后仅显示目标家谱,仍需填写身份关系;本地验证不会变更成员身份。</text
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
@@ -209,11 +211,11 @@
|
||||
>
|
||||
</view>
|
||||
<view class="result-card__action" @click="confirmInvite"
|
||||
>确认关系并加入</view
|
||||
>填写关系信息</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<text class="invite-result__note">提交后直接加入,无需等待审核</text>
|
||||
<text class="invite-result__note">当前为样式验证,不会变更成员身份</text>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
@@ -226,6 +228,12 @@ import { onLoad, onUnload } from "@dcloudio/uni-app";
|
||||
import AppLoading from "@/components/AppLoading.vue";
|
||||
import GenealogyPageBackground from "@/components/GenealogyPageBackground.vue";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import {
|
||||
getGenealogyFixtureAccess,
|
||||
isGenealogySearchVisible,
|
||||
publicGenealogies,
|
||||
} from "@/data/mock.js";
|
||||
import { goRoot, openPage } from "@/utils/navigation.js";
|
||||
|
||||
const mode = ref("search");
|
||||
const keyword = ref("");
|
||||
@@ -235,102 +243,14 @@ const inviteCode = ref("");
|
||||
const inviteState = ref("initial");
|
||||
const results = ref([]);
|
||||
let searchTimer = null;
|
||||
const invalidateSearch = () => {
|
||||
const timer = searchTimer;
|
||||
searchTimer = null;
|
||||
if (timer) clearTimeout(timer);
|
||||
};
|
||||
|
||||
const areas = ["全部", "河南", "山东"];
|
||||
const resultFixtures = [
|
||||
{
|
||||
id: 2001,
|
||||
surname: "汤",
|
||||
name: "汤氏南阳宗谱",
|
||||
hall: "敦睦堂",
|
||||
location: "河南·南阳",
|
||||
parentName: "汤氏中华总谱",
|
||||
branchName: "南阳主支",
|
||||
manager: "管理员 汤文礼",
|
||||
certification: "资料已认证",
|
||||
memberCount: 428,
|
||||
updatedAt: "2026-07-12",
|
||||
relation: "available",
|
||||
actionLabel: "申请加入",
|
||||
},
|
||||
{
|
||||
id: 2002,
|
||||
surname: "汤",
|
||||
name: "汤氏洛阳家谱",
|
||||
hall: "承志堂",
|
||||
location: "河南·洛阳",
|
||||
parentName: "汤氏中华总谱",
|
||||
branchName: "洛阳二支",
|
||||
manager: "管理员 汤文远",
|
||||
certification: "资料已认证",
|
||||
memberCount: 158,
|
||||
updatedAt: "2026-07-10",
|
||||
relation: "joined",
|
||||
actionLabel: "已加入",
|
||||
},
|
||||
{
|
||||
id: 2003,
|
||||
surname: "汤",
|
||||
name: "汤氏济宁宗谱",
|
||||
hall: "敬宗堂",
|
||||
location: "山东·济宁",
|
||||
parentName: "汤氏鲁西总谱",
|
||||
branchName: "济宁主支",
|
||||
manager: "管理员 汤正明",
|
||||
certification: "管理员已实名",
|
||||
memberCount: 286,
|
||||
updatedAt: "2026-07-08",
|
||||
relation: "pending",
|
||||
actionLabel: "审核中",
|
||||
},
|
||||
{
|
||||
id: 2004,
|
||||
surname: "汤",
|
||||
name: "汤氏清河家谱",
|
||||
hall: "思源堂",
|
||||
location: "山东·临清",
|
||||
parentName: "汤氏鲁西总谱",
|
||||
branchName: "清河支系",
|
||||
manager: "管理员 汤志成",
|
||||
certification: "资料已认证",
|
||||
memberCount: 96,
|
||||
updatedAt: "2026-07-05",
|
||||
relation: "rejected",
|
||||
actionLabel: "修改后重新申请",
|
||||
},
|
||||
{
|
||||
id: 2005,
|
||||
surname: "汤",
|
||||
name: "汤氏汝南支谱",
|
||||
hall: "崇本堂",
|
||||
location: "河南·驻马店",
|
||||
parentName: "汤氏中原总谱",
|
||||
branchName: "汝南三支",
|
||||
manager: "管理员 汤国安",
|
||||
certification: "管理员已实名",
|
||||
memberCount: 72,
|
||||
updatedAt: "2026-07-02",
|
||||
relation: "removed",
|
||||
actionLabel: "重新申请",
|
||||
},
|
||||
{
|
||||
id: 2006,
|
||||
surname: "汤",
|
||||
name: "汤氏新安家谱",
|
||||
hall: "继善堂",
|
||||
location: "河南·三门峡",
|
||||
parentName: "无上级谱",
|
||||
branchName: "新安主支",
|
||||
manager: "创建者 当前用户",
|
||||
certification: "资料待完善",
|
||||
memberCount: 34,
|
||||
updatedAt: "2026-06-28",
|
||||
relation: "owned",
|
||||
actionLabel: "我创建的",
|
||||
},
|
||||
];
|
||||
|
||||
const inviteTarget = computed(() => resultFixtures[0]);
|
||||
const inviteTarget = computed(() => publicGenealogies[0]);
|
||||
|
||||
const syncModeFromRoute = (query = {}) => {
|
||||
mode.value = query?.mode === "invite" ? "invite" : "search";
|
||||
@@ -339,81 +259,121 @@ const syncModeFromRoute = (query = {}) => {
|
||||
};
|
||||
|
||||
onLoad((query) => syncModeFromRoute(query));
|
||||
onUnload(() => {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
});
|
||||
onUnload(invalidateSearch);
|
||||
|
||||
const switchMode = (nextMode) => {
|
||||
invalidateSearch();
|
||||
mode.value = nextMode;
|
||||
results.value = [];
|
||||
searchState.value = "initial";
|
||||
inviteState.value = "initial";
|
||||
};
|
||||
|
||||
const search = () => {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
invalidateSearch();
|
||||
searchState.value = "loading";
|
||||
searchTimer = setTimeout(() => {
|
||||
const value = keyword.value.trim();
|
||||
const value = keyword.value.trim();
|
||||
const area = selectedArea.value;
|
||||
const timer = setTimeout(() => {
|
||||
if (searchTimer !== timer || mode.value !== "search") return;
|
||||
searchTimer = null;
|
||||
if (value === "失败") {
|
||||
searchState.value = "error";
|
||||
return;
|
||||
}
|
||||
results.value = resultFixtures.filter((item) => {
|
||||
results.value = publicGenealogies.filter((item) => {
|
||||
const matchesKeyword =
|
||||
!value ||
|
||||
`${item.name}${item.surname}${item.location}${item.hall}`.includes(
|
||||
value,
|
||||
);
|
||||
const matchesArea =
|
||||
selectedArea.value === "全部" ||
|
||||
item.location.includes(selectedArea.value);
|
||||
return matchesKeyword && matchesArea;
|
||||
area === "全部" || item.location.includes(area);
|
||||
return isGenealogySearchVisible(String(item.id)) && matchesKeyword && matchesArea;
|
||||
});
|
||||
searchState.value = results.value.length ? "results" : "empty";
|
||||
searchTimer = null;
|
||||
}, 260);
|
||||
searchTimer = timer;
|
||||
};
|
||||
|
||||
const clearSearch = () => {
|
||||
invalidateSearch();
|
||||
keyword.value = "";
|
||||
results.value = [];
|
||||
searchState.value = "initial";
|
||||
};
|
||||
|
||||
const openPreview = (item) => {
|
||||
if (item.relation === "available") {
|
||||
uni.navigateTo({
|
||||
url: `/pages/genealogy/g05-genealogy-overview?mode=public&genealogyId=${item.id}&genealogyName=${encodeURIComponent(item.name)}`,
|
||||
});
|
||||
if (
|
||||
item.relation === "available" &&
|
||||
getGenealogyFixtureAccess(String(item.id)).canApply
|
||||
) {
|
||||
return openPage(
|
||||
"G05",
|
||||
{ genealogyId: String(item.id) },
|
||||
"G06",
|
||||
);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const resultActionLabel = (item) => {
|
||||
if (item.relation === "pending") return "查看申请进度";
|
||||
if (item.relation === "joined") return "切换到该家谱";
|
||||
if (item.relation === "owned") return "进入我的家谱";
|
||||
if (!getGenealogyFixtureAccess(String(item.id)).canApply) return "";
|
||||
return {
|
||||
available: "申请加入",
|
||||
rejected: "修改后重新申请",
|
||||
removed: "重新申请",
|
||||
}[item.relation] || "";
|
||||
};
|
||||
const resultRelationLabel = (item) =>
|
||||
({
|
||||
available: "可申请",
|
||||
joined: "已加入",
|
||||
pending: "审核中",
|
||||
rejected: "已拒绝",
|
||||
removed: "已退出",
|
||||
owned: "我创建的",
|
||||
})[item.relation] || "关系待确认";
|
||||
|
||||
const handleResultAction = (item) => {
|
||||
if (item.relation === "available")
|
||||
return uni.navigateTo({
|
||||
url: `/pages/genealogy/g08-join-application?source=search&genealogyId=${item.id}&genealogyName=${encodeURIComponent(item.name)}`,
|
||||
});
|
||||
if (item.relation === "pending")
|
||||
return uni.navigateTo({
|
||||
url: "/pages/genealogy/g09-my-applications?status=pending",
|
||||
});
|
||||
if (item.relation === "rejected" || item.relation === "removed")
|
||||
return uni.navigateTo({
|
||||
url: `/pages/genealogy/g08-join-application?source=search&previous=${item.relation}&genealogyId=${item.id}&genealogyName=${encodeURIComponent(item.name)}`,
|
||||
});
|
||||
return uni.reLaunch({
|
||||
url: `/pages/genealogy/g01-my-genealogies?genealogyId=${item.id}`,
|
||||
});
|
||||
return openPage("G09", { status: "pending" }, "G06");
|
||||
if (
|
||||
["available", "rejected", "removed"].includes(item.relation) &&
|
||||
getGenealogyFixtureAccess(String(item.id)).canApply
|
||||
)
|
||||
return openPage(
|
||||
"G08",
|
||||
{ genealogyId: String(item.id), source: "search" },
|
||||
"G06",
|
||||
);
|
||||
if (item.relation === "joined" || item.relation === "owned")
|
||||
return goRoot("G01", { genealogyId: String(item.id) });
|
||||
return false;
|
||||
};
|
||||
|
||||
const verifyInvite = () => {
|
||||
inviteState.value =
|
||||
inviteCode.value.toUpperCase() === "JP2026" ? "valid" : "invalid";
|
||||
};
|
||||
const confirmInvite = () =>
|
||||
uni.navigateTo({
|
||||
url: `/pages/genealogy/g08-join-application?source=invite&genealogyId=${inviteTarget.value.id}&genealogyName=${encodeURIComponent(inviteTarget.value.name)}`,
|
||||
});
|
||||
const resetInvite = () => {
|
||||
inviteState.value = "initial";
|
||||
};
|
||||
const confirmInvite = () => {
|
||||
if (inviteState.value !== "valid") return false;
|
||||
if (inviteCode.value.trim().toUpperCase() !== "JP2026") return false;
|
||||
return openPage(
|
||||
"G08",
|
||||
{
|
||||
genealogyId: String(inviteTarget.value.id),
|
||||
source: "invite",
|
||||
},
|
||||
"G06",
|
||||
);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user