This commit is contained in:
owenchen committed 2026-10-20 15:44:56 +08:00
1 parent 9b01c4a57a
commit 6417562c4f
37 files changed
+2767 -202

No files matched your search

+3
View File
@@ -112,6 +112,7 @@ export const ADMIN_FORM_KIND = {
TEXTAREA: "textarea",
SWITCH: "switch",
DATE: "date",
SELECT: "select",
} as const;
type FormKinds = typeof ADMIN_FORM_KIND;
@@ -134,6 +135,8 @@ export interface AdminFormField {
/** 只读模式按日期显示:true 取 yyyy-MM-dd,"datetime" 带时分秒 */
date?: boolean | "datetime";
maxlength?: number;
/** type 为 select 时的候选项(label 展示、value 落库) */
options?: AdminFilterChoice[];
}
/** 详情页的一张卡片(旧 ft-card 的等价物) */
@@ -0,0 +1,74 @@
/**
* 用户身份徽标字形:登录用户「未认证 / 普通用户 / VIP / SVIP」四类身份的小图标与配色。
* uview 图标集无皇冠/盾牌等语义图形,故沿用 brand.ts 的内联 SVG data URI 套路(跨端安全)。
* 图标统一白色描边/填充,压在各自配色的圆角胶囊上;普通用户跟随主题(--fg-gradient 兜底)。
*/
/** 未认证:盾牌 + 问号(灰) */
const unauthGlyph = `data:image/svg+xml,${encodeURIComponent(
[
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='#ffffff' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'>",
"<path d='M12 3 5 6v5c0 4.4 3 7.4 7 8.8 4-1.4 7-4.4 7-8.8V6l-7-3z'/>",
"<path d='M9.7 9.3a2.3 2.3 0 1 1 3.1 2.2c-.7.3-.9.7-.9 1.5'/>",
"<circle cx='11.9' cy='16.3' r='0.9' fill='#ffffff' stroke='none'/>",
"</svg>",
].join(""),
)}`;
/** 普通用户:人像 + 对勾(跟随主题绿) */
const normalGlyph = `data:image/svg+xml,${encodeURIComponent(
[
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='#ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'>",
"<circle cx='9.5' cy='8' r='3.2'/>",
"<path d='M4 19c0-3 2.5-5 5.5-5 1 0 2 .2 2.8.7'/>",
"<path d='M13.8 17.2 15.8 19.2 20 15'/>",
"</svg>",
].join(""),
)}`;
/** VIP:三尖皇冠 + 底座(金) */
const vipGlyph = `data:image/svg+xml,${encodeURIComponent(
[
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='#ffffff'>",
"<path d='M4 8 8 11 12 6 16 11 20 8 18.5 16.5h-13z'/>",
"<rect x='5' y='17.4' width='14' height='2.2' rx='1.1'/>",
"</svg>",
].join(""),
)}`;
/** SVIP:三尖皇冠 + 顶部四角星(紫,比 VIP 多一颗星以示尊贵) */
const svipGlyph = `data:image/svg+xml,${encodeURIComponent(
[
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='#ffffff'>",
"<path d='M12 1.8 12.9 3.9 15 4.8 12.9 5.7 12 7.8 11.1 5.7 9 4.8 11.1 3.9z'/>",
"<path d='M4 9.5 8 12.3 12 7.8 16 12.3 20 9.5 18.5 17.5h-13z'/>",
"<rect x='5' y='18.4' width='14' height='2.2' rx='1.1'/>",
"</svg>",
].join(""),
)}`;
/** UserType → 徽标字形 data URI(后端 UserType:U/N/V/S) */
export const USER_TYPE_GLYPHS: Record<string, string> = {
U: unauthGlyph,
N: normalGlyph,
V: vipGlyph,
S: svipGlyph,
};
/** UserType → 胶囊底色(身份卡为统一主题绿实底,四类胶囊统一用深色半透芯片 + 白字白图标,压住深底高对比) */
export const USER_TYPE_PILL_BG: Record<string, string> = {
U: "rgba(0, 0, 0, 0.16)",
N: "rgba(0, 0, 0, 0.16)",
V: "rgba(0, 0, 0, 0.16)",
S: "rgba(0, 0, 0, 0.16)",
};
/** 取字形 data URI,未知类型回退普通用户 */
export function userTypeGlyph(type?: string): string {
return USER_TYPE_GLYPHS[type ?? ""] ?? normalGlyph;
}
/** 取胶囊底色,未知类型回退普通用户 */
export function userTypePillBg(type?: string): string {
return USER_TYPE_PILL_BG[type ?? ""] ?? USER_TYPE_PILL_BG.N;
}
@@ -72,6 +72,9 @@ function displayValue(field: AdminFormField): string {
if (field.display) {
return field.display(props.model) || empty;
}
if (field.type === "select") {
return selectLabel(field) || empty;
}
const raw = rawValue(field);
if (raw === null || raw === undefined || raw === "") {
return empty;
@@ -82,6 +85,30 @@ function displayValue(field: AdminFormField): string {
return String(raw);
}
/** select 候选:无 options 时给空数组,避免模板 range 报错 */
function selectOptions(field: AdminFormField) {
return field.options ?? [];
}
/** select 当前值对应的展示文案(找不到返回空) */
function selectLabel(field: AdminFormField): string {
const cur = String(rawValue(field) ?? "");
return selectOptions(field).find(o => o.value === cur)?.label ?? "";
}
/** select 当前值在候选中的下标(找不到回退 0,picker 需合法 index) */
function selectIndex(field: AdminFormField): number {
const cur = String(rawValue(field) ?? "");
const i = selectOptions(field).findIndex(o => o.value === cur);
return i < 0 ? 0 : i;
}
function onSelectChange(field: AdminFormField, event: any): void {
const idx = Number(event?.detail?.value ?? 0);
const opt = selectOptions(field)[idx];
setInputValue(field, opt ? opt.value : "");
}
/** 编辑态控件的值:统一成字符串,switch 例外(u-switch 只吃布尔) */
function inputValue(field: AdminFormField): string {
const raw = rawValue(field);
@@ -178,6 +205,16 @@ function onTapAction(action: AdminFormAction): void {
<u-icon name="arrow-right" size="24" color="#c4c8cf" />
</view>
</picker>
<picker v-else-if="field.type === 'select'" mode="selector" :range="selectOptions(field)"
range-key="label" :value="selectIndex(field)" :disabled="field.lock"
@change="onSelectChange(field, $event)">
<view class="picker-box" :class="{ 'is-empty': !selectLabel(field) }">
<text>
{{ selectLabel(field) || field.placeholder || t('AdminPage.notSetTip') }}
</text>
<u-icon name="arrow-right" size="24" color="#c4c8cf" />
</view>
</picker>
<!-- uview-pro 的 u-input border 是布尔,不是旧 uview 的 'surround' 字符串 -->
<u-input v-else :model-value="inputValue(field)" :type="field.type || 'text'"
:disabled="field.lock" :border="false" input-align="right"
@@ -13,9 +13,13 @@ import type { FamilyPersonDisplayData } from "@/data/auto/familyPersonDisplayDat
import type { AdminRow } from "@/admin/admin-types";
import type { ExchangeScope } from "@/composables/useFamilyTreeExchange";
import type { FamilyTreeExchangeFileInfo } from "@/data/auto/familyTreeExchangeFileInfo";
import { StorageUsageData } from "@/data/auto/storageUsageData";
import { useLocale } from "uview-pro";
import { computed, onMounted, ref } from "vue";
import { useThemeGradient, useThemeTokens } from "@/composables";
import { brandGlyph } from "@/common/brand";
import { buildChunkFileName, uploadFile } from "@/common/http.interceptor";
import { userTypeGlyph, userTypePillBg } from "@/common/userTypeIcons";
import { useIdCardVerify, useThemeGradient, useThemeTokens } from "@/composables";
import { formatFileSize, formatFileTime, useFamilyTreeExchange } from "@/composables/useFamilyTreeExchange";
import { usePersonPickConfig } from "@/composables/usePickerConfigs";
import { usePolicyOptions } from "@/composables/usePolicyOptions";
@@ -31,6 +35,8 @@ import { FamilyTreeSpouseMapViewEntity } from "@/data/auto/familyTreeSpouseMapVi
import { FamilyTreeViewEntity } from "@/data/auto/familyTreeViewEntity";
import familyPersonService from "@/service/master/familyPersonService";
import familyTreeService from "@/service/master/familyTreeService";
import dmsFileService from "@/service/master/dmsFileService";
import { useLoginProfileStore } from "@/stores";
/** ready:组件挂载完成通知(时序口径见文件底部 onMounted 注释) */
const emit = defineEmits<{ (e: "ready"): void }>();
@@ -74,6 +80,117 @@ const inDetail = ref(false);
/** 列表整体收起态:卡区缩成一条窄横条(伸缩钮在列表右缘) */
const listCollapsed = ref(false);
// ===== 顶部两张卡片:登录用户身份 + 网盘用量(列表态,静默拉取,失败不阻断族谱列表) =====
const loginProfile = useLoginProfileStore();
const displayName = computed(() => loginProfile.userLocalName || loginProfile.username || "");
const storage = ref<StorageUsageData>(new StorageUsageData());
/** 当前用户类型:优先异步用量快照,未就绪时回退登录档案同步值,保证首帧徽标/文字即为真实等级 */
const currentType = computed(() => storage.value.UserType || loginProfile.userType);
const userTypeText = computed(() => {
const map: Record<string, string> = {
U: "storage.typeUnauth",
N: "storage.typeNormal",
V: "storage.typeVip",
S: "storage.typeSvip",
};
return t(map[currentType.value] ?? "storage.typeNormal");
});
// 后端 file_size/额度均为 KB,formatFileSize 期望字节 → ×1024 对齐
const storageUsedText = computed(() => formatFileSize(storage.value.UsedKB * 1024));
const storageQuotaText = computed(() => storage.value.QuotaKB > 0 ? formatFileSize(storage.value.QuotaKB * 1024) : "-");
const storageOver = computed(() => storage.value.QuotaKB > 0 && storage.value.UsedKB > storage.value.QuotaKB);
/** 占比在前端按小数重算(后端 Percent 为整数会截断成 0),极小用量也能如实显示 */
const storagePercentNum = computed(() => (storage.value.QuotaKB > 0 ? (storage.value.UsedKB / storage.value.QuotaKB) * 100 : 0));
const storagePercentText = computed(() => {
const v = storagePercentNum.value;
if (v <= 0) {
return "0%";
}
if (v < 0.1) {
return "0.1%";
}
if (v < 10) {
return `${v.toFixed(1)}%`;
}
return `${Math.round(v)}%`;
});
/** 进度条宽度:按重算占比取区间;有用量但占比极小时给 2% 最小可见宽度,避免完全空条 */
const storageBarWidth = computed(() => {
const clamped = Math.min(Math.max(storagePercentNum.value, 0), 100);
const min = storage.value.UsedKB > 0 ? 2 : 0;
return `${Math.max(clamped, min)}%`;
});
/** 身份徽标字形与胶囊底色:随 UserType(U/N/V/S)切换,未认证灰、普通跟随主题、VIP 金、SVIP 紫 */
const userTypeIcon = computed(() => userTypeGlyph(currentType.value));
const userTypeBg = computed(() => userTypePillBg(currentType.value));
/** 网盘存储卡图标:内联云形 SVG(同 treeGlyph 套路),绿描边置于柔光圆内(存储卡为浅色渐变描边底) */
const cloudGlyph = `data:image/svg+xml,${encodeURIComponent([
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='#2f9e6b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'>",
"<path d='M6.8 18.5a4.3 4.3 0 0 1-.5-8.56 5.6 5.6 0 0 1 10.75-1.06A3.9 3.9 0 0 1 17.4 18.5z'/>",
"<path d='M9.5 14.2l1.9 1.9 3.6-3.9'/>",
"</svg>",
].join(""))}`;
/** 未认证底部弹层:单击「未认证」徽标从底部弹出身份证认证,复用 useIdCardVerify(与身份验证页同一套流程) */
const idPopup = ref(false);
const {
imageUrl: idvImage,
uploading: idvUploading,
isVerified: idvVerified,
buttonText: idvButtonText,
onUploadIdCard,
} = useIdCardVerify(() => {
idPopup.value = false;
void fetchStorage();
});
/** 仅未认证(U)可单击弹层去认证,其余身份为只读展示 */
function onTapUserType(): void {
if (currentType.value === "U") {
idPopup.value = true;
}
}
async function fetchStorage(): Promise<void> {
try {
const res = await dmsFileService.GetMyStorageUsage();
if (res) storage.value = res;
}
catch { /* 静默:卡片留占位,不打扰族谱列表主流程 */ }
}
/** 点头像上传当前用户头像:单图 -> /DmsFile/UploadUserAvatar(后端落盘 UserAvatar 目录并回写 user_icon_img_path)-> 成功后重拉用量刷新卡片 */
const avatarUploading = ref(false);
function onUploadAvatar(): void {
if (avatarUploading.value) {
return;
}
uni.chooseImage({
count: 1,
success: async (res: any) => {
const filePath = String(res?.tempFilePaths?.[0] ?? "");
const fileName = String(res?.tempFiles?.[0]?.name || `avatar-${Date.now()}.png`);
if (!filePath) {
return;
}
try {
avatarUploading.value = true;
await uploadFile({
url: "/DmsFile/UploadUserAvatar",
filePath,
name: fileName,
fileName: buildChunkFileName(fileName),
});
await fetchStorage();
uni.showToast({ title: t("storage.avatarUploadedTip"), icon: "none" });
}
catch { /* uploadFile 已统一弹错,这里只补一个失败落点 */ }
finally {
avatarUploading.value = false;
}
},
});
}
/** 关键字过滤:族谱名称/简介 前端包含匹配(列表量级小,不再走后端筛选链) */
const filteredTrees = computed(() => {
const kw = keyword.value.trim().toLowerCase();
@@ -1366,18 +1483,67 @@ defineExpose({
reloadIfList(): void {
if (!inDetail.value) {
loadTrees();
void fetchStorage();
}
},
});
</script>
<template>
<!-- 列表态显示 tabbar,进详情(或弹层展开)收起 -->
<app-page :hide-nav="true" :show-tabbar="!inDetail">
<!-- 列表态显示 tabbar,进详情(或弹层展开)收起;未认证底部弹层也在列表态弹出,须一并隐 tabbar,否则盖住底部按钮 -->
<app-page :hide-nav="true" :show-tabbar="!inDetail && !idPopup">
<view class="tree-page" :style="[{ background: themeBackground }, themeVars]">
<!-- ===== 列表态:软底分区面板(标题 + 搜索/新建/伸缩圆钮组 + 白底族谱卡) ===== -->
<!-- 隐藏原生滚动条:否则 Chrome 滚动条占右侧 ~17px,面板左右留白不对称 -->
<scroll-view v-if="!inDetail" scroll-y :show-scrollbar="false" class="tree-page__body tree-page__body--list">
<!-- ===== 顶部两张卡片:用户身份 + 网盘用量 ===== -->
<view class="home-cards">
<view class="home-card home-card--user">
<view class="home-card__sheen" />
<view class="home-card__glow" />
<image class="home-card__mark" :src="brandGlyph" mode="aspectFit" />
<view class="home-card__avatar" @tap="onUploadAvatar">
<image v-if="storage.AvatarUrl" class="home-card__avatar-img" :src="storage.AvatarUrl"
mode="aspectFill" />
<text v-else class="home-card__avatar-ph">{{ displayName ? displayName.slice(0, 1) : "?" }}</text>
<view class="home-card__avatar-cam">
<u-icon name="camera-fill" size="24" color="#ffffff" />
</view>
</view>
<view class="home-card__uinfo">
<view class="home-card__uname-row">
<text class="home-card__uname">{{ displayName || "-" }}</text>
<view class="home-card__utype" :class="{ 'home-card__utype--tap': currentType === 'U' }"
:style="{ background: userTypeBg }" @tap="onTapUserType">
<image class="home-card__utype-icon" :src="userTypeIcon" mode="aspectFit" />
<text class="home-card__utype-text">{{ userTypeText }}</text>
</view>
</view>
<text class="home-card__welcome">{{ t("storage.welcome") }}</text>
</view>
</view>
<view class="home-card home-card--storage">
<view class="home-card__sglow" />
<view class="home-card__srow">
<view class="home-card__stitle-wrap">
<view class="home-card__sicon">
<image class="home-card__sicon-img" :src="cloudGlyph" mode="aspectFit" />
</view>
<text class="home-card__stitle">{{ t("storage.title") }}</text>
</view>
<text class="home-card__spct" :class="{ 'home-card__spct--over': storageOver }">{{ storagePercentText
}}</text>
</view>
<view class="home-card__bar">
<view class="home-card__bar-fill" :class="{ 'home-card__bar-fill--over': storageOver }"
:style="{ width: storageBarWidth }" />
</view>
<view class="home-card__snums">
<text class="home-card__snum">{{ t("storage.used") }} {{ storageUsedText }}</text>
<text class="home-card__snum">{{ t("storage.total") }} {{ storageQuotaText }}</text>
</view>
</view>
</view>
<view class="tree-panel">
<view class="tree-panel__head">
<text class="tree-panel__title">{{ t("FamilyTreePage.listTitle") }}</text>
@@ -1462,7 +1628,7 @@ defineExpose({
<u-switch v-if="data.IsManager" :model-value="tree.PublicIndc === 'Y'" size="40"
:active-color="primary" @change="onPublicToggle" />
<text v-if="data.IsManager" class="ft-badge ft-badge--admin">{{ t("FamilyTreePage.managerTag")
}}</text>
}}</text>
</view>
</view>
</view>
@@ -1569,7 +1735,7 @@ defineExpose({
<!-- 当前族员:从概览移入,夫妻/子女列表都是相对此人 -->
<view v-if="loaded && currentPerson" class="ft-card">
<view class="ft-card__head"><text class="ft-card__title">{{ t("FamilyTreePage.currentPerson")
}}</text></view>
}}</text></view>
<view class="person-hero">
<view class="person-hero__avatar"
:style="avatarFallbackStyle(!!currentPerson?.AvatarUrl, currentPerson?.Gender)">
@@ -1584,7 +1750,7 @@ defineExpose({
</view>
<view class="person-hero__chips">
<text v-if="currentPerson?.PersonId" class="person-hero__chip">{{ personChipText(currentPerson)
}}</text>
}}</text>
</view>
</view>
</view>
@@ -1627,12 +1793,12 @@ defineExpose({
<!-- 新增入口与行尾操作同一把闸:当前锚点不可编(未绑定/出支系)时隐藏 -->
<view class="ft-card__head">
<view class="ft-card__title-group"><text class="ft-card__title">{{ t("FamilyTreePage.spouseTitle")
}}</text><text class="ft-card__count">{{ spouseMaps.length }}</text></view>
}}</text><text class="ft-card__count">{{ spouseMaps.length }}</text></view>
<view v-if="data.IsCanAmend" class="ft-card__add" @tap="openQuickCreate('spouse')"><u-icon
name="plus" size="26" :color="primary" /><text>{{ t("FamilyTreePage.addSpouse") }}</text></view>
</view>
<view v-if="!visibleSpouses.length" class="ft-empty"><text>{{ t("FamilyTreePage.spouseEmpty")
}}</text></view>
}}</text></view>
<view v-for="record in visibleSpouses" :key="record.SpouseId" class="ft-mrow">
<view class="ft-av"
:style="avatarFallbackStyle(!!personAvatar(record.SpouseId), personGender(record.SpouseId, record.Gender))">
@@ -1668,13 +1834,13 @@ defineExpose({
<view class="ft-card">
<view class="ft-card__head">
<view class="ft-card__title-group"><text class="ft-card__title">{{ t("FamilyTreePage.childTitle")
}}</text><text class="ft-card__count">{{ childMaps.length }}</text></view>
}}</text><text class="ft-card__count">{{ childMaps.length }}</text></view>
<view v-if="data.IsCanAmend" class="ft-card__add" @tap="openQuickCreate('child')"><u-icon
name="plus" size="26" :color="primary" /><text>{{ t("FamilyTreePage.addChildBtn") }}</text>
</view>
</view>
<view v-if="!visibleChildren.length" class="ft-empty"><text>{{ t("FamilyTreePage.childEmpty")
}}</text></view>
}}</text></view>
<view v-for="record in visibleChildren" :key="record.ChildrenId" class="ft-mrow">
<view class="ft-av"
:style="avatarFallbackStyle(!!personAvatar(record.ChildrenId), personGender(record.ChildrenId, record.Gender))">
@@ -1714,12 +1880,12 @@ defineExpose({
<view v-if="data.IsManager && pendingPermissions.length" class="ft-card">
<view class="ft-card__head">
<view class="ft-card__title-group"><text class="ft-card__title">{{ t("FamilyTreePage.permPending")
}}</text><text class="ft-card__count">{{ pendingPermissions.length }}</text></view>
}}</text><text class="ft-card__count">{{ pendingPermissions.length }}</text></view>
</view>
<view v-for="record in pendingPermissions" :key="record.UserName" class="ft-perm-row">
<view class="ft-perm-row__main"><text class="ft-perm-row__name">{{ record.UserLocalName ||
record.UserName
}}</text><text v-if="record.PersonLocalName" class="ft-perm-row__sub">{{ record.PersonLocalName
}}</text><text v-if="record.PersonLocalName" class="ft-perm-row__sub">{{ record.PersonLocalName
}}</text>
</view>
<view class="ft-perm-ops">
@@ -1738,14 +1904,14 @@ defineExpose({
<view v-if="data.IsManager" class="ft-card">
<view class="ft-card__head">
<view class="ft-card__title-group"><text class="ft-card__title">{{ t("FamilyTreePage.permManager")
}}</text><text class="ft-card__count">{{ managerPermissions.length }}</text></view>
}}</text><text class="ft-card__count">{{ managerPermissions.length }}</text></view>
</view>
<view v-if="!managerPermissions.length" class="ft-empty"><text>{{ t("FamilyTreePage.permEmpty")
}}</text></view>
}}</text></view>
<view v-for="record in managerPermissions" :key="record.UserName" class="ft-perm-row">
<view class="ft-perm-row__main"><text class="ft-perm-row__name">{{ record.UserLocalName ||
record.UserName
}}</text><text class="ft-perm-row__sub">{{ record.ManagerIndc === "Y" ?
}}</text><text class="ft-perm-row__sub">{{ record.ManagerIndc === "Y" ?
t("FamilyTreePage.managerTag") :
t("FamilyTreePage.memberTag") }}</text></view>
<view class="ft-perm-ops">
@@ -1976,7 +2142,7 @@ defineExpose({
<view class="person-hero__line">
<text class="rel-name">{{ record.SpouseSurname }}{{ record.SpouseGenealogyName }}</text>
<text class="person-hero__gender">{{ genderText(personGender(record.SpouseId, record.Gender))
}}</text>
}}</text>
</view>
<view class="person-hero__chips">
<text class="person-hero__chip">
@@ -2013,7 +2179,7 @@ defineExpose({
<text class="sub-label">{{ t("FamilyTreePage.marryDate") }}</text>
<view class="sub-picker">
<text class="sub-picker-text">{{ datePart(record.MarryDate) || t("AdminPage.notSetTip")
}}</text>
}}</text>
<u-icon name="arrow-right" size="24" color="#c4c8cf" />
</view>
</view>
@@ -2029,7 +2195,7 @@ defineExpose({
<view class="sub-picker">
<text class="sub-picker-text">{{
datePart(record.DivorceDate) || t("AdminPage.notSetTip")
}}</text>
}}</text>
<u-icon name="arrow-right" size="24" color="#c4c8cf" />
</view>
</view>
@@ -2115,7 +2281,7 @@ defineExpose({
<view class="person-hero__line">
<text class="rel-name">{{ record.ChildrenSurname }}{{ record.ChildrenGenealogyName }}</text>
<text class="person-hero__gender">{{ genderText(personGender(record.ChildrenId, record.Gender))
}}</text>
}}</text>
</view>
<view class="person-hero__chips">
<text class="person-hero__chip">
@@ -2226,7 +2392,7 @@ defineExpose({
<text class="rel-name">{{ record.UserLocalName || record.UserName }}</text>
<text class="rel-sub">{{
record.ManagerIndc === "Y" ? t("FamilyTreePage.managerTag") : t("FamilyTreePage.memberTag")
}}</text>
}}</text>
</view>
<view class="perm-ops">
<view class="perm-op perm-op--danger" @tap="rejectPermission(record)">
@@ -2283,6 +2449,38 @@ defineExpose({
<!-- 族人档案弹层已取消:始祖卡单击不再弹窗,编辑走卡头「编辑资料」文字链 -->
<!-- ===== 未认证底部弹层:单击「未认证」徽标从底部弹出身份证认证(与身份验证页共用 useIdCardVerify) ===== -->
<u-popup :model-value="idPopup" mode="bottom" round="24" @close="idPopup = false">
<view class="ft-sheet">
<view class="ft-sheet__head">
<text class="ft-sheet__title">{{ t("IdentityVerificationPage.title") }}</text>
<u-icon name="close" size="32" color="#8f959e" @click="idPopup = false" />
</view>
<text class="home-verify__intro">{{ t("IdentityVerificationPage.intro") }}</text>
<view v-if="idvVerified" class="home-verify__verified">
<u-icon name="checkmark-circle-fill" size="70" color="#52c41a" />
<text class="home-verify__verified-text">{{ t("IdentityVerificationPage.verifiedDone") }}</text>
</view>
<template v-else>
<view class="home-verify__thumb" @tap="onUploadIdCard">
<image v-if="idvImage" class="home-verify__thumb-img" :src="idvImage" mode="aspectFill" />
<view v-else class="home-verify__empty">
<u-icon name="camera" size="44" color="#c4c8cf" />
<text class="home-verify__empty-text">{{ t("IdentityVerificationPage.uploadBut") }}</text>
</view>
<view v-if="idvUploading" class="home-verify__mask">
<text class="home-verify__mask-text">{{ t("IdentityVerificationPage.uploadingTip") }}</text>
</view>
</view>
<view class="ft-sheet__foot">
<view class="ft-sheet__btn" @tap="idPopup = false"><text>{{ t("AdminPage.cancelBut") }}</text></view>
<view class="ft-sheet__btn ft-sheet__btn--primary" @tap="onUploadIdCard"><text>{{ idvButtonText }}</text>
</view>
</view>
</template>
</view>
</u-popup>
<!-- ===== 编辑族谱信息弹层(仅名称/始祖谱名/简介/公开四字段,关系与成员分开维护) ===== -->
<!-- ===== 交换文件导出弹层(信封加密在前端,密码只当密钥材料、后端不校验)===== -->
<u-popup :model-value="exportVisible" mode="bottom" round="24" @close="exportVisible = false">
@@ -2371,7 +2569,7 @@ defineExpose({
<!-- 服务器文件列表限高滚动:文件多了不挤掉密码框/警告/按钮 -->
<scroll-view v-if="!localFileName" scroll-y class="ft-exchange__list">
<view v-if="importFilesLoading" class="ft-empty"><text>{{ t("FamilyTreePage.exchangeFileLoading")
}}</text></view>
}}</text></view>
<view v-else-if="!importFiles.length" class="ft-empty"><text>{{ t(imScope === "SUB" ?
"FamilyTreePage.exchangeFileEmptySub" : "FamilyTreePage.exchangeFileEmpty") }}</text></view>
<view v-for="file in importFiles" :key="file.FileName" class="ft-exchange__row"
@@ -2392,7 +2590,7 @@ defineExpose({
<view v-if="backupLoading" class="ft-empty"><text>{{ t("FamilyTreePage.exchangeFileLoading") }}</text>
</view>
<view v-else-if="!backupFiles.length" class="ft-empty"><text>{{ t("FamilyTreePage.exchangeBackupEmpty")
}}</text></view>
}}</text></view>
<view v-for="bk in backupFiles" :key="bk.FileName" class="ft-exchange__row"
:class="{ 'ft-exchange__row--on': pickedBackup === bk.FileName }" @tap="pickedBackup = bk.FileName">
<view class="ft-exchange__row-main">
@@ -2458,7 +2656,7 @@ defineExpose({
<view class="ft-sheet__foot">
<view class="ft-sheet__btn" @tap="cancelTreeEdit"><text>{{ t("AdminPage.cancelBut") }}</text></view>
<view class="ft-sheet__btn ft-sheet__btn--primary" @tap="saveTreeEdit"><text>{{ t("AdminPage.saveBut")
}}</text>
}}</text>
</view>
</view>
</view>
@@ -2507,6 +2705,350 @@ defineExpose({
padding: 20rpx;
}
/* ===== 顶部两张卡片:用户身份 + 网盘用量(白底圆角,与下方族谱面板同宽同调) ===== */
.home-cards {
display: flex;
flex-direction: column;
gap: 20rpx;
margin: 0 0 22rpx;
}
.home-card {
box-sizing: border-box;
flex: 1;
min-width: 0;
padding: 24rpx;
border-radius: 32rpx;
background: #ffffff;
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.04);
}
.home-card--user {
position: relative;
overflow: hidden;
display: flex;
align-items: center;
gap: 30rpx;
min-height: 236rpx;
padding: 48rpx 44rpx;
border-radius: 40rpx;
background: var(--fg-gradient, linear-gradient(135deg, #2f9e6b 0%, #1f7d55 55%, #14664a 100%));
box-shadow: 0 20rpx 48rpx rgba(0, 0, 0, 0.26), inset 0 2rpx 0 rgba(255, 255, 255, 0.30);
}
/* 装饰层:斜向高光 + 右上柔光圆 + 品牌水印,纯装饰不拦截点击 */
.home-card__sheen {
position: absolute;
top: 0;
left: -30%;
width: 55%;
height: 100%;
background: linear-gradient(115deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
transform: skewX(-18deg);
pointer-events: none;
}
.home-card__glow {
position: absolute;
top: -70rpx;
right: -50rpx;
width: 240rpx;
height: 240rpx;
border-radius: 50%;
background: radial-gradient(circle, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%);
pointer-events: none;
}
.home-card__mark {
position: absolute;
right: 24rpx;
bottom: 18rpx;
width: 120rpx;
height: 120rpx;
opacity: 0.14;
pointer-events: none;
}
.home-card__avatar {
position: relative;
z-index: 1;
width: 128rpx;
height: 128rpx;
border-radius: 50%;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.22);
border: 4rpx solid rgba(255, 255, 255, 0.75);
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.20);
}
.home-card__avatar-img {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
}
.home-card__avatar-cam {
position: absolute;
right: 2rpx;
bottom: 2rpx;
width: 44rpx;
height: 44rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.45);
border: 2rpx solid #ffffff;
pointer-events: none;
}
.home-card__avatar-ph {
font-size: 60rpx;
font-weight: 600;
color: #ffffff;
}
.home-card__uinfo {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
min-width: 0;
}
.home-card__uname-row {
display: flex;
align-items: center;
gap: 16rpx;
}
.home-card__uname {
max-width: 340rpx;
font-size: 42rpx;
font-weight: 700;
color: #ffffff;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.home-card__welcome {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.85);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.home-card__utype {
display: flex;
align-self: center;
align-items: center;
gap: 10rpx;
padding: 7rpx 22rpx 7rpx 16rpx;
border: 1rpx solid rgba(255, 255, 255, 0.5);
border-radius: 999rpx;
font-size: 26rpx;
color: #ffffff;
background: var(--fg-primary, #d98a3d);
}
.home-card__utype--tap {
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.12);
}
.home-card__utype-icon {
width: 32rpx;
height: 32rpx;
flex-shrink: 0;
}
.home-card__utype-text {
color: #ffffff;
font-size: 26rpx;
line-height: 1.4;
}
/* 未认证底部弹层:身份证缩略图与说明(复用 ft-sheet 头部/底部按钮) */
.home-verify__intro {
margin-bottom: 20rpx;
font-size: 24rpx;
line-height: 1.6;
color: #9aa0a6;
}
.home-verify__thumb {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 300rpx;
overflow: hidden;
border: 2rpx dashed #d6d9de;
border-radius: 16rpx;
background-color: #f5f6f8;
}
.home-verify__thumb-img {
width: 100%;
height: 100%;
}
.home-verify__empty {
display: flex;
flex-direction: column;
align-items: center;
gap: 12rpx;
}
.home-verify__empty-text {
font-size: 26rpx;
color: #9aa0a6;
}
.home-verify__mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.35);
}
.home-verify__mask-text {
font-size: 24rpx;
color: #ffffff;
}
.home-verify__verified {
display: flex;
flex-direction: column;
align-items: center;
gap: 20rpx;
padding: 48rpx 0;
}
.home-verify__verified-text {
font-size: 28rpx;
font-weight: 600;
color: #52c41a;
}
.home-card--storage {
position: relative;
overflow: hidden;
margin: 0 16rpx;
padding: 40rpx 44rpx;
border: 2rpx solid transparent;
border-radius: 40rpx;
background:
linear-gradient(135deg, #ffffff 0%, #f1f7f3 100%) padding-box,
linear-gradient(135deg, rgba(47, 158, 107, 0.55), rgba(47, 158, 107, 0.05)) border-box;
box-shadow: 0 16rpx 40rpx rgba(31, 45, 38, 0.10), inset 0 2rpx 0 rgba(255, 255, 255, 0.9);
}
.home-card__sglow {
position: absolute;
top: -60rpx;
right: -40rpx;
z-index: 0;
width: 220rpx;
height: 220rpx;
border-radius: 50%;
background: radial-gradient(circle, rgba(47, 158, 107, 0.16), rgba(47, 158, 107, 0) 70%);
pointer-events: none;
}
.home-card__stitle-wrap {
position: relative;
z-index: 1;
display: flex;
align-items: center;
gap: 14rpx;
}
.home-card__sicon {
display: flex;
align-items: center;
justify-content: center;
width: 56rpx;
height: 56rpx;
border-radius: 16rpx;
background: var(--fg-soft, #e6f6ec);
}
.home-card__sicon-img {
width: 34rpx;
height: 34rpx;
}
.home-card__srow {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
}
.home-card__stitle {
font-size: 30rpx;
font-weight: 700;
color: #1f2329;
}
.home-card__spct {
font-size: 28rpx;
font-weight: 700;
color: var(--fg-primary, #d98a3d);
}
.home-card__spct--over {
color: #e5484d;
}
.home-card__bar {
position: relative;
z-index: 1;
height: 16rpx;
border-radius: 999rpx;
background: #e9edf0;
overflow: hidden;
}
.home-card__bar-fill {
height: 100%;
border-radius: 999rpx;
background: linear-gradient(90deg, var(--fg-primary, #d98a3d), #f0b877);
transition: width 0.3s ease;
}
.home-card__bar-fill--over {
background: linear-gradient(90deg, #e5484d, #ff8a80);
}
.home-card__snums {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 18rpx;
}
.home-card__snum {
font-size: 26rpx;
color: #7a827f;
}
/* ===== 列表态分区面板:主题浅底圆角,标题与圆钮组同行,白底族谱卡嵌在其中 ===== */
.tree-panel {
padding: 28rpx;
+1
View File
@@ -4,6 +4,7 @@ export * from "./useAdminPick";
export * from "./useAuthGuard";
export * from "./useDmsFiles";
export * from "./useFamilyGroups";
export * from "./useIdCardVerify";
export * from "./useLang";
export * from "./useMediaShow";
export * from "./usePublishAlbums";
@@ -53,6 +53,9 @@ export function buildExportFileName(
/** 文件字节数友好显示(列表行小字) */
export function formatFileSize(size: number): string {
if (size >= 1024 * 1024 * 1024) {
return `${(size / 1024 / 1024 / 1024).toFixed(1)} GB`;
}
if (size >= 1024 * 1024) {
return `${(size / 1024 / 1024).toFixed(1)} MB`;
}
@@ -0,0 +1,169 @@
import { useLocale } from "uview-pro";
import { computed, ref } from "vue";
import { buildChunkFileName, uploadFile } from "@/common/http.interceptor";
import { SecurityUserDisplayData } from "@/data/auto/securityUserDisplayData";
import securityUserService from "@/service/security/securityUserService";
import { useLoginProfileStore } from "@/stores";
/** 后端 UpdateSecurityUserIdCard 会把 UserType 置为 NORMAL_USERS("N")代表已认证;此处与后端口径保持一致 */
const NORMAL_USERS = "N";
/**
* 身份证认证流程(页面与首页底部弹层共用):
* chooseImage 单图 → 复用同源后端 DmsFile/UploadIdCardFile(后端落盘 idcard 目录 + server-to-server 调 OCR,
* 返回带识别结果的 FamilyPersonDisplayData)→ 把「全部识别信息」格式化写入 UserRemark,昵称取身份证姓名,
* 再调 SecurityUser/UpdateSecurityUserIdCard 落库并把 UserType 置为 NORMAL_USERS(已认证)。
*
* @param onSuccess 认证成功(已落库 + 本地态已同步 + 已弹 toast)后的回调:
* 页面传「延时返回」,首页弹层传「关闭弹层 + 重拉用量」。
*/
export function useIdCardVerify(onSuccess?: () => void) {
const { t } = useLocale();
const loginProfileStore = useLoginProfileStore();
const imageUrl = ref("");
const remark = ref("");
const recognizedName = ref("");
const uploading = ref(false);
const saving = ref(false);
const busy = computed(() => uploading.value || saving.value);
/** 已认证(UserType=NORMAL_USERS):禁止重复认证,仅展示认证状态 */
const isVerified = computed(
() => loginProfileStore.userType === NORMAL_USERS,
);
const buttonText = computed(() => {
if (uploading.value) {
return t("IdentityVerificationPage.uploadingTip");
}
if (saving.value) {
return t("IdentityVerificationPage.savingTip");
}
return t("IdentityVerificationPage.uploadBut");
});
/** 出生日期归一为 yyyy-MM-dd(兼容 yyyyMMdd 与带分隔符/时间戳);不足 8 位数字则原样返回 */
function formatBirth(raw: string): string {
const digits = String(raw ?? "").replace(/\D/g, "");
if (digits.length < 8) {
return String(raw ?? "").trim();
}
return `${digits.slice(0, 4)}-${digits.slice(4, 6)}-${digits.slice(6, 8)}`;
}
/** 取后端识别结果字段:兼容 PascalCase(服务端默认)与 camelCase(前端缓存转键) */
function pick(info: any, pascal: string, camel: string): string {
return String(info?.[pascal] ?? info?.[camel] ?? "").trim();
}
/** 把全部识别信息拼成 UserRemark 文本(有值才成行,逐行「标签: 值」);返回拼接文本与身份证姓名 */
function buildRemark(info: any): { text: string; name: string } {
const name = pick(info, "CommonName", "commonName");
const rows: string[] = [];
const push = (label: string, val: string): void => {
if (val) {
rows.push(`${label}: ${val}`);
}
};
push(t("FamilyPersonPage.commonName"), name);
push(t("FamilyPersonPage.gender"), pick(info, "Gender", "gender"));
push(
t("FamilyPersonPage.birthDate"),
formatBirth(pick(info, "BirthDate", "birthDate")),
);
push(t("FamilyPersonPage.nation"), pick(info, "Nation", "nation"));
push(t("FamilyPersonPage.address"), pick(info, "Address", "address"));
push(t("FamilyPersonPage.idNumber"), pick(info, "IdNumber", "idNumber"));
push(t("FamilyPersonPage.issuer"), pick(info, "Issuer", "issuer"));
push(t("FamilyPersonPage.validity"), pick(info, "Validity", "validity"));
return { text: rows.join("\n"), name };
}
/** 提交认证:昵称取身份证姓名(识别不到则沿用当前昵称),UserRemark 整体覆盖为识别信息 */
async function save(): Promise<void> {
try {
saving.value = true;
const payload = new SecurityUserDisplayData();
payload.UserLocalName =
recognizedName.value || loginProfileStore.userLocalName || "";
payload.UserRemark = remark.value;
await securityUserService.UpdateSecurityUserIdCard(payload);
// 后端已将 UserType 置为 NORMAL_USERS、昵称改为身份证姓名;
// 登录快照是登录时的旧值,这里同步本地态,返回「我的」/刷新首页即可立即显示「已认证」
loginProfileStore.loginProfile.UserType = NORMAL_USERS;
if (payload.UserLocalName) {
loginProfileStore.loginProfile.UserLocalName = payload.UserLocalName;
}
uni.showToast({
title: t("IdentityVerificationPage.success"),
icon: "none",
});
onSuccess?.();
} finally {
saving.value = false;
}
}
/** 上传身份证:单图 → 后端 OCR → 拼 UserRemark(整体覆盖)→ UpdateSecurityUserIdCard 落库并置认证态 */
function onUploadIdCard(): void {
if (uploading.value || saving.value || isVerified.value) {
return;
}
uni.chooseImage({
count: 1,
success: async (res: any) => {
const filePath = String(res?.tempFilePaths?.[0] ?? "");
const fileName = String(
res?.tempFiles?.[0]?.name || `idcard-${Date.now()}.jpg`,
);
if (!filePath) {
return;
}
try {
uploading.value = true;
const physicalName = buildChunkFileName(fileName);
imageUrl.value = filePath;
const result = await uploadFile({
url: "/DmsFile/UploadIdCardFile",
filePath,
name: fileName,
fileName: physicalName,
header: { FilePath: "idcard" },
formData: { side: "auto" },
});
const info = result?.Data ?? result?.data ?? result;
const { text, name } = buildRemark(info);
if (!text) {
uni.showToast({
title: t("IdentityVerificationPage.noResult"),
icon: "none",
});
return;
}
remark.value = text;
recognizedName.value = name;
await save();
} catch (error) {
console.error(error);
uni.showToast({
title: t("IdentityVerificationPage.failed"),
icon: "none",
});
} finally {
uploading.value = false;
}
},
});
}
return {
imageUrl,
remark,
uploading,
saving,
busy,
isVerified,
buttonText,
onUploadIdCard,
};
}
@@ -0,0 +1,16 @@
export class DmsFileUsageViewEntity
{
public OwerId: string = "";
public FileCount: number = 0;
public UsedKb: number = 0;
static readonly OWER_ID : string ='OwerId';
static readonly FILE_COUNT : string ='FileCount';
static readonly USED_KB : string ='UsedKb';
static readonly DB_NAME_DMS_FILE_USAGE_VIEW : string ='dms_file_usage_view';
static readonly DB_NAME_FIELDS : string ='ower_id,file_count,used_kb';
static readonly DB_OWER_ID : string ='ower_id';
static readonly DB_FILE_COUNT : string ='file_count';
static readonly DB_USED_KB : string ='used_kb';
}
@@ -0,0 +1,10 @@
export class StorageUsageData
{
public UserType: string = "";
public AvatarUrl: string = "";
public UsedKB: number = 0;
public QuotaKB: number = 0;
public Percent: number = 0;
}
+18 -1
View File
@@ -1,5 +1,17 @@
{
"name": "en-US",
"storage": {
"title": "Cloud Storage Space",
"used": "Used",
"total": "Total",
"welcome": "Welcome back to Youjiala, carry on the family memory",
"typeUnauth": "Unverified",
"typeNormal": "Standard",
"typeVip": "VIP",
"typeSvip": "SVIP",
"avatarUploadedTip": "Avatar updated",
"avatarUploadFailed": "Avatar upload failed"
},
"LoginForm": {
"userLabel": "Username",
"passwordLabel": "Password",
@@ -14,7 +26,7 @@
},
"TabBar": {
"home": "Home",
"file": "Files",
"file": "Cloud Drive",
"media": "Media",
"share": "Share",
"mine": "Me"
@@ -830,6 +842,11 @@
"userLocalName": "Local Name",
"userEngName": "English Name",
"userMobile": "Mobile",
"userType": "User Type",
"userTypeUnauth": "Unverified",
"userTypeNormal": "Standard",
"userTypeVip": "VIP",
"userTypeSvip": "SVIP",
"userPassword": "Password",
"createdDatetime": "Created Date",
"account": "Account",
+18 -1
View File
@@ -1,5 +1,17 @@
{
"name": "zh-CN",
"storage": {
"title": "网盘存储空间",
"used": "已使用",
"total": "总容量",
"welcome": "欢迎回到有家,传承家族记忆",
"typeUnauth": "未认证",
"typeNormal": "普通用户",
"typeVip": "VIP",
"typeSvip": "SVIP",
"avatarUploadedTip": "头像已更新",
"avatarUploadFailed": "头像上传失败"
},
"LoginForm": {
"userLabel": "用户名",
"passwordLabel": "密码",
@@ -14,7 +26,7 @@
},
"TabBar": {
"home": "首页",
"file": "文件",
"file": "网盘",
"media": "多媒体",
"share": "共享",
"mine": "我的"
@@ -830,6 +842,11 @@
"userLocalName": "中文名称",
"userEngName": "英文名称",
"userMobile": "手机",
"userType": "用户类型",
"userTypeUnauth": "未认证",
"userTypeNormal": "普通用户",
"userTypeVip": "VIP",
"userTypeSvip": "SVIP",
"userPassword": "登录密码",
"createdDatetime": "创建日期",
"account": "账号",
@@ -1,59 +1,22 @@
<script setup lang="ts">
/**
* 身份验证页:从「我的」跳入(短地址 /identity-verification)。
* 流程:chooseImage 单图 → 复用同源后端 DmsFile/UploadIdCardFile(后端落盘 idcard 目录 +
* server-to-server 调同 docker 的 OCR,返回带识别结果的 FamilyPersonDisplayData,避免浏览器跨域)→
* 把「全部识别信息」格式化写入 UserRemark,昵称取身份证姓名,再调 SecurityUser/UpdateSecurityUserIdCard
* 落库并把 UserType 置为 NORMAL_USERS(已认证)。
* 上传 + OCR + 落库 + 置认证态的完整流程抽到 useIdCardVerify(首页底部弹层共用同一套逻辑)。
* 与 family-person 的身份证不同:那边把无列信息并入「简介」;这里 UserRemark 是真实列,整体覆盖为识别信息。
* 注意:后端 UpdateSecurityUserIdCard 对「可查看全部用户」(管理员)会直接 return 不更新——普通用户自助认证场景。
*/
import { useLocale } from "uview-pro";
import { computed, ref } from "vue";
import { buildChunkFileName, uploadFile } from "@/common/http.interceptor";
import { useAuthGuard, useThemeGradient, useThemeTokens } from "@/composables";
import { SecurityUserDisplayData } from "@/data/auto/securityUserDisplayData";
import { computed } from "vue";
import { useAuthGuard, useIdCardVerify, useThemeGradient, useThemeTokens } from "@/composables";
import { pageUrl } from "@/router/routes";
import securityUserService from "@/service/security/securityUserService";
import { useLoginProfileStore } from "@/stores";
const { t } = useLocale();
useAuthGuard();
const loginProfileStore = useLoginProfileStore();
/** 后端 UpdateSecurityUserIdCard 会把 UserType 置为 NORMAL_USERS("N")代表已认证;此处与后端口径保持一致 */
const NORMAL_USERS = "N";
const imageUrl = ref("");
const remark = ref("");
const recognizedName = ref("");
const uploading = ref(false);
const saving = ref(false);
const busy = computed(() => uploading.value || saving.value);
const buttonText = computed(() => {
if (uploading.value) {
return t("IdentityVerificationPage.uploadingTip");
}
if (saving.value) {
return t("IdentityVerificationPage.savingTip");
}
return t("IdentityVerificationPage.uploadBut");
});
/** 已认证(UserType=NORMAL_USERS):禁止重复认证,仅展示认证状态 */
const isVerified = computed(() => loginProfileStore.userType === NORMAL_USERS);
/** 返回:有历史则回退,冷启动直达时兜底切回「我的」tab */
function onBack(): void {
if (getCurrentPages().length > 1) {
uni.navigateBack();
}
else {
uni.switchTab({ url: pageUrl("mineTab") });
}
}
/** 认证成功:短延时返回「我的」,让 toast 露出 */
const { imageUrl, remark, uploading, busy, isVerified, buttonText, onUploadIdCard } = useIdCardVerify(() =>
setTimeout(() => uni.navigateBack(), 800),
);
/* 主题渐变底 + 主题色变量(与「我的」页同一接线口径) */
const { themeBackground } = useThemeGradient();
@@ -65,106 +28,13 @@ const themeVars = computed(() => ({
"--fg-shadow": accentShadow.value,
}));
/** 出生日期归一为 yyyy-MM-dd(兼容 yyyyMMdd 与带分隔符/时间戳);不足 8 位数字则原样返回 */
function formatBirth(raw: string): string {
const digits = String(raw ?? "").replace(/\D/g, "");
if (digits.length < 8) {
return String(raw ?? "").trim();
/** 返回:有历史则回退,冷启动直达时兜底切回「我的」tab */
function onBack(): void {
if (getCurrentPages().length > 1) {
uni.navigateBack();
}
return `${digits.slice(0, 4)}-${digits.slice(4, 6)}-${digits.slice(6, 8)}`;
}
/** 取后端识别结果字段:兼容 PascalCase(服务端默认)与 camelCase(前端缓存转键) */
function pick(info: any, pascal: string, camel: string): string {
return String(info?.[pascal] ?? info?.[camel] ?? "").trim();
}
/** 把全部识别信息拼成 UserRemark 文本(有值才成行,逐行「标签: 值」);返回拼接文本与身份证姓名 */
function buildRemark(info: any): { text: string; name: string } {
const name = pick(info, "CommonName", "commonName");
const rows: string[] = [];
const push = (label: string, val: string): void => {
if (val) {
rows.push(`${label}: ${val}`);
}
};
push(t("FamilyPersonPage.commonName"), name);
push(t("FamilyPersonPage.gender"), pick(info, "Gender", "gender"));
push(t("FamilyPersonPage.birthDate"), formatBirth(pick(info, "BirthDate", "birthDate")));
push(t("FamilyPersonPage.nation"), pick(info, "Nation", "nation"));
push(t("FamilyPersonPage.address"), pick(info, "Address", "address"));
push(t("FamilyPersonPage.idNumber"), pick(info, "IdNumber", "idNumber"));
push(t("FamilyPersonPage.issuer"), pick(info, "Issuer", "issuer"));
push(t("FamilyPersonPage.validity"), pick(info, "Validity", "validity"));
return { text: rows.join("\n"), name };
}
/** 上传身份证:单图 → 后端 OCR → 拼 UserRemark(整体覆盖)→ UpdateSecurityUserIdCard 落库并置认证态 */
function onUploadIdCard(): void {
if (uploading.value || saving.value || isVerified.value) {
return;
}
uni.chooseImage({
count: 1,
success: async (res: any) => {
const filePath = String(res?.tempFilePaths?.[0] ?? "");
const fileName = String(res?.tempFiles?.[0]?.name || `idcard-${Date.now()}.jpg`);
if (!filePath) {
return;
}
try {
uploading.value = true;
const physicalName = buildChunkFileName(fileName);
imageUrl.value = filePath;
const result = await uploadFile({
url: "/DmsFile/UploadIdCardFile",
filePath,
name: fileName,
fileName: physicalName,
header: { FilePath: "idcard" },
formData: { side: "auto" },
});
const info = result?.Data ?? result?.data ?? result;
const { text, name } = buildRemark(info);
if (!text) {
uni.showToast({ title: t("IdentityVerificationPage.noResult"), icon: "none" });
return;
}
remark.value = text;
recognizedName.value = name;
await save();
}
catch (error) {
console.error(error);
uni.showToast({ title: t("IdentityVerificationPage.failed"), icon: "none" });
}
finally {
uploading.value = false;
}
},
});
}
/** 提交认证:昵称取身份证姓名(识别不到则沿用当前昵称),UserRemark 整体覆盖为识别信息 */
async function save(): Promise<void> {
try {
saving.value = true;
const payload = new SecurityUserDisplayData();
payload.UserLocalName = recognizedName.value || loginProfileStore.userLocalName || "";
payload.UserRemark = remark.value;
await securityUserService.UpdateSecurityUserIdCard(payload);
// 后端已将 UserType 置为 NORMAL_USERS、昵称改为身份证姓名;
// 登录快照是登录时的旧值,这里同步本地态,返回「我的」即可立即显示「已认证」
loginProfileStore.loginProfile.UserType = NORMAL_USERS;
if (payload.UserLocalName) {
loginProfileStore.loginProfile.UserLocalName = payload.UserLocalName;
}
uni.showToast({ title: t("IdentityVerificationPage.success"), icon: "none" });
// 成功后短延时返回「我的」,让 toast 露出
setTimeout(() => uni.navigateBack(), 800);
}
finally {
saving.value = false;
else {
uni.switchTab({ url: pageUrl("mineTab") });
}
}
</script>
@@ -65,6 +65,17 @@ const sections = computed<AdminFormSection[]>(() => {
{ label: t("UserPage.userLocalName"), prop: "UserLocalName", required: true },
{ label: t("UserPage.userEngName"), prop: "UserEngName" },
{ label: t("UserPage.userMobile"), prop: "UserMobile" },
{
label: t("UserPage.userType"),
prop: "UserType",
type: "select",
options: [
{ label: t("UserPage.userTypeUnauth"), value: "U" },
{ label: t("UserPage.userTypeNormal"), value: "N" },
{ label: t("UserPage.userTypeVip"), value: "V" },
{ label: t("UserPage.userTypeSvip"), value: "S" },
],
},
{ label: t("UserPage.createdDatetime"), prop: "CreatedDatetime", date: "datetime", lock: true },
];
// 密码只在编辑态出现:查看态没必要显示(即便是掩码)
@@ -8,6 +8,7 @@ import { request,download } from "@/utils/request";
import type { SelectOption } from "@/data/auto/selectOption";
import type { DmsFolderData } from "@/data/auto/dmsFolderData";
import type { FamilyPersonDisplayData } from "@/data/auto/familyPersonDisplayData";
import type { StorageUsageData } from "@/data/auto/storageUsageData";
import type { FamilyGroupFolderEntity } from "@/data/auto/familyGroupFolderEntity";
class DmsFileService{
@@ -267,6 +268,24 @@ class DmsFileService{
)
};
async GetMyStorageUsage() {
return request<StorageUsageData>(
{
url: "/DmsFile/GetMyStorageUsage",
method: "post",
}
)
};
async UploadUserAvatar() {
return request<string>(
{
url: "/DmsFile/UploadUserAvatar",
method: "post",
}
)
};
async DownloadFile(data: number) {
return request<any>(
{
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="#059669" d="M6.8 18.5a4.3 4.3 0 0 1-.5-8.56 5.6 5.6 0 0 1 10.75-1.06A3.9 3.9 0 0 1 17.4 18.5z"/>
<path fill="none" stroke="#ffffff" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" d="M12 16.4v-4.6M9.9 13.7 12 11.6l2.1 2.1"/>
</svg>

After

Width:  |  Height:  |  Size: 327 B

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#606266" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
<path d="M6.8 18.5a4.3 4.3 0 0 1-.5-8.56 5.6 5.6 0 0 1 10.75-1.06A3.9 3.9 0 0 1 17.4 18.5z"/>
<path d="M12 16.4v-4.6"/>
<path d="M9.9 13.7 12 11.6l2.1 2.1"/>
</svg>

After

Width:  |  Height:  |  Size: 327 B

+5 -3
View File
@@ -18,7 +18,7 @@ export const useTabbarStore = defineStore(
"tabbar",
() => {
const activeIndex = ref(0);
// 顺序必须与 routes.ts 的 TAB_PAGES 逐项对齐(首页/文件/多媒体/共享/我的)。
// 顺序必须与 routes.ts 的 TAB_PAGES 逐项对齐(首页/网盘/多媒体/共享/我的)。
// 刻意不写 pagePath:u-tabbar 一旦拿到 pagePath 就会调 uni.switchTab,而本项目没有原生
// tabBar,switchTab 会 fail。跳转统一由 app-tabbar 的 @change 用 reLaunch 完成,
// 高亮由当前页面路由反推下标(见 app-tabbar 的 onMounted)。
@@ -30,8 +30,10 @@ export const useTabbarStore = defineStore(
},
{
langKey: "TabBar.file",
iconPath: "file-text",
selectedIconPath: "file-text-fill",
// 网盘无对应 uview 字体图标,改用自定义云形 SVG(含 '/' → u-icon 走 <image> 渲染);
// 图片图标不吃 color,故未选中/选中各烘一色(描边灰 #606266 / 实心绿 #059669)
iconPath: "/static/tabbar/netdisk.svg",
selectedIconPath: "/static/tabbar/netdisk-active.svg",
},
{
langKey: "TabBar.media",