feat(my): 个人信息页回显缓存用户信息与单位部门字段
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
18704cbb76
commit
e69db66eab
@@ -26,6 +26,8 @@ export interface UserInfo {
|
|||||||
delFlag: number
|
delFlag: number
|
||||||
sn: string | null
|
sn: string | null
|
||||||
workNo: string | null
|
workNo: string | null
|
||||||
|
secondDepart: string | null
|
||||||
|
thirdDepart: string | null
|
||||||
remark: string | null
|
remark: string | null
|
||||||
relationType: string | null
|
relationType: string | null
|
||||||
sex_dictText: string
|
sex_dictText: string
|
||||||
|
|||||||
@@ -1,15 +1,43 @@
|
|||||||
|
import { calcAge } from '../../utils/idCard/index'
|
||||||
|
import type { UserInfo } from '../../api/index'
|
||||||
|
|
||||||
// pages/personalInformation/personalInformation.ts
|
// pages/personalInformation/personalInformation.ts
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
|
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: {
|
userInfo: {
|
||||||
name: '狗蛋',
|
avatar: raw.realname?.[0] ?? '',
|
||||||
idCard: '4301**********1234',
|
name: raw.realname ?? '-',
|
||||||
gender: '男',
|
idCard: raw.idCard ?? '-',
|
||||||
age: '45岁',
|
gender: raw.sex_dictText || (raw.sex === 1 ? '男' : raw.sex === 2 ? '女' : '-'),
|
||||||
company: '健康科技公司',
|
age: age ? `${age}岁` : '-',
|
||||||
department: '技术部-研发组',
|
secondDepart: raw.secondDepart || '-',
|
||||||
height: '175cm',
|
thirdDepart: raw.thirdDepart || '-',
|
||||||
weight: '72kg'
|
height: raw.height ? `${raw.height}cm` : '-',
|
||||||
}
|
weight: raw.weight ? `${raw.weight}kg` : '-',
|
||||||
}
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
<view class="row row-avatar">
|
<view class="row row-avatar">
|
||||||
<view class="label">头像</view>
|
<view class="label">头像</view>
|
||||||
<view class="value">
|
<view class="value">
|
||||||
<view class="avatar">狗</view>
|
<view class="avatar">{{ userInfo.avatar }}</view>
|
||||||
<view class="arrow"></view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -30,12 +29,12 @@
|
|||||||
|
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<view class="label">单位</view>
|
<view class="label">单位</view>
|
||||||
<view class="value">{{ userInfo.company }}</view>
|
<view class="value">{{ userInfo.secondDepart }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<view class="label">部门</view>
|
<view class="label">部门</view>
|
||||||
<view class="value">{{ userInfo.department }}</view>
|
<view class="value">{{ userInfo.thirdDepart }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="row">
|
<view class="row">
|
||||||
|
|||||||
Reference in New Issue
Block a user