From e69db66eab969c2221b54f0b0e952f45efcbbf2c Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Tue, 25 Aug 2026 10:43:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(my):=20=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=A1=B5=E5=9B=9E=E6=98=BE=E7=BC=93=E5=AD=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E4=B8=8E=E5=8D=95=E4=BD=8D=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- miniprogram/api/user.ts | 2 + .../personalInformation.ts | 50 +++++++++++++++---- .../personalInformation.wxml | 7 ++- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/miniprogram/api/user.ts b/miniprogram/api/user.ts index 0712402..b8a481e 100644 --- a/miniprogram/api/user.ts +++ b/miniprogram/api/user.ts @@ -26,6 +26,8 @@ export interface UserInfo { delFlag: number sn: string | null workNo: string | null + secondDepart: string | null + thirdDepart: string | null remark: string | null relationType: string | null sex_dictText: string diff --git a/miniprogram/pages/personalInformation/personalInformation.ts b/miniprogram/pages/personalInformation/personalInformation.ts index acb186b..adf54bd 100644 --- a/miniprogram/pages/personalInformation/personalInformation.ts +++ b/miniprogram/pages/personalInformation/personalInformation.ts @@ -1,15 +1,43 @@ +import { calcAge } from '../../utils/idCard/index' +import type { UserInfo } from '../../api/index' + // pages/personalInformation/personalInformation.ts Page({ data: { - userInfo: { - name: '狗蛋', - idCard: '4301**********1234', - gender: '男', - age: '45岁', - company: '健康科技公司', - department: '技术部-研发组', - height: '175cm', - weight: '72kg' - } - } + userInfo: null as { + avatar: string + name: string + idCard: string + gender: string + age: string + secondDepart: string + thirdDepart: string + height: string + weight: string + } | null, + }, + + onShow() { + this._loadUserInfo() + }, + + // 从缓存回显用户信息 + _loadUserInfo() { + const raw = wx.getStorageSync('userInfo') as UserInfo | null + if (!raw?.userId) return + const age = calcAge(raw.birthday) + this.setData({ + userInfo: { + avatar: raw.realname?.[0] ?? '', + name: raw.realname ?? '-', + idCard: raw.idCard ?? '-', + gender: raw.sex_dictText || (raw.sex === 1 ? '男' : raw.sex === 2 ? '女' : '-'), + age: age ? `${age}岁` : '-', + secondDepart: raw.secondDepart || '-', + thirdDepart: raw.thirdDepart || '-', + height: raw.height ? `${raw.height}cm` : '-', + weight: raw.weight ? `${raw.weight}kg` : '-', + }, + }) + }, }) diff --git a/miniprogram/pages/personalInformation/personalInformation.wxml b/miniprogram/pages/personalInformation/personalInformation.wxml index ee61d1d..80a5356 100644 --- a/miniprogram/pages/personalInformation/personalInformation.wxml +++ b/miniprogram/pages/personalInformation/personalInformation.wxml @@ -3,8 +3,7 @@ 头像 - - + {{ userInfo.avatar }} @@ -30,12 +29,12 @@ 单位 - {{ userInfo.company }} + {{ userInfo.secondDepart }} 部门 - {{ userInfo.department }} + {{ userInfo.thirdDepart }}