feat(my): 个人信息页回显缓存用户信息与单位部门字段

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-25 10:43:47 +08:00
co-authored by Claude Opus 4.7
parent 18704cbb76
commit e69db66eab
3 changed files with 44 additions and 15 deletions
+2
View File
@@ -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
@@ -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` : '-',
},
})
},
})
@@ -3,8 +3,7 @@
<view class="row row-avatar">
<view class="label">头像</view>
<view class="value">
<view class="avatar"></view>
<view class="arrow"></view>
<view class="avatar">{{ userInfo.avatar }}</view>
</view>
</view>
@@ -30,12 +29,12 @@
<view class="row">
<view class="label">单位</view>
<view class="value">{{ userInfo.company }}</view>
<view class="value">{{ userInfo.secondDepart }}</view>
</view>
<view class="row">
<view class="label">部门</view>
<view class="value">{{ userInfo.department }}</view>
<view class="value">{{ userInfo.thirdDepart }}</view>
</view>
<view class="row">