refactor: 项目重构,仅保留 login 和 supplementPersonal 页面

删除 11 个旧页面、组件、lefu SDK、旧资源文件。
新增 request 封装(GET/POST/PUT)、api 层、utils/common 身份证工具。
重写 login(登录流程提取到 app.ts) 和 supplementPersonal(简化表单逻辑)。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-10 14:21:00 +08:00
co-authored by Claude Sonnet 4.6
parent 439f560218
commit 83d909b95b
96 changed files with 370 additions and 9040 deletions
-5
View File
@@ -1,5 +0,0 @@
{
"usingComponents": {
"select-member-drawer": "/components/selectMemberDrawer/selectMemberDrawer"
}
}
-304
View File
@@ -1,304 +0,0 @@
.scrollViewContent {
width: 100%;
padding: 24rpx 30rpx;
box-sizing: border-box;
.data-card {
width: 100%;
overflow: hidden;
zoom: 1;
position: relative;
padding: 40rpx 30rpx 30rpx;
box-sizing: border-box;
border-radius: 24rpx;
margin-bottom: 30rpx;
background-color: #FFFFFF;
&::before {
content: "";
position: absolute;
top: 2rpx;
left: 2rpx;
right: 2rpx;
height: 88rpx;
background: linear-gradient(180deg, #D3E9FF 0%, #FCFBFD 100%);
}
/* 用户信息行 */
.userInfo {
position: relative;
z-index: 2;
width: 100%;
display: flex;
align-items: center;
margin-bottom: 30rpx;
/* 头像色块(展示姓名首字) */
.avatar {
width: 90rpx;
height: 90rpx;
margin-right: 24rpx;
border-radius: 18rpx;
color: #FFFFFF;
font-size: 36rpx;
font-weight: bold;
line-height: 90rpx;
text-align: center;
background-color: #1385FA;
}
/* 姓名 + meta */
.info {
flex: 1;
.info-name-row {
height: 40rpx;
display: flex;
align-items: center;
margin-bottom: 10rpx;
.info-name {
color: #252535;
height: 40rpx;
font-size: 30rpx;
font-weight: bold;
line-height: 40rpx;
margin-right: 20rpx;
}
/* 本人 badge */
.badge-self {
color: #1385FA;
height: 40rpx;
padding: 0 18rpx;
font-size: 24rpx;
line-height: 40rpx;
border-radius: 8rpx;
background-color: rgba(19, 133, 250, 0.2);
}
}
.info-meta {
height: 26rpx;
display: flex;
align-items: center;
.meta-text {
color: #808080;
height: 26rpx;
font-size: 24rpx;
line-height: 26rpx;
}
.meta-divider {
color: #CCCCCC;
font-size: 24rpx;
line-height: 26rpx;
margin: 0 12rpx;
}
}
}
/* 切换用户按钮 */
.btn {
color: #1385FA;
width: 120rpx;
height: 48rpx;
font-size: 24rpx;
font-weight: 500;
line-height: 48rpx;
border-radius: 8rpx;
text-align: center;
border: 2rpx solid #1385FA;
}
}
.card-divider {
position: relative;
z-index: 2;
width: calc(100% + 60rpx);
left: -30rpx;
height: 1rpx;
margin-bottom: 30rpx;
border-bottom: 2rpx dashed #EAECF1;
&::before {
content: "";
position: absolute;
left: -15rpx;
top: 0;
bottom: 0;
margin: auto;
width: 30rpx;
height: 30rpx;
background-color: #F5F7FB;
border-radius: 50%;
}
&::after {
content: "";
position: absolute;
right: -15rpx;
top: 0;
bottom: 0;
margin: auto;
width: 30rpx;
height: 30rpx;
background-color: #F5F7FB;
border-radius: 50%;
}
}
/* 时间范围 Tab */
.nav {
width: 100%;
height: 72rpx;
padding: 4rpx;
box-sizing: border-box;
display: flex;
flex-wrap: nowrap;
background-color: #E8EBF2;
border-radius: 16rpx;
margin-bottom: 24rpx;
>view {
flex: 1;
height: 64rpx;
border-radius: 16rpx;
font-size: 28rpx;
color: #808080;
line-height: 64rpx;
text-align: center;
&.active {
color: #FFFFFF;
font-weight: bold;
background-color: #1385FA;
}
}
}
/* 统计摘要 4 格 */
.summary {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
padding: 24rpx 0;
background-color: #F3F4F6;
border-radius: 16rpx;
.summary-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
.summary-label {
color: #808080;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
margin-bottom: 20rpx;
}
.summary-value {
color: #252535;
height: 32rpx;
font-size: 32rpx;
font-weight: bold;
line-height: 32rpx;
text {
color: #808080;
font-size: 24rpx;
font-weight: normal;
margin-left: 4rpx;
}
}
/* 体重下降(利好) */
.value-down {
color: #2AC79F;
}
/* 体重上升(警示) */
.value-up {
color: #FF4D4F;
}
}
}
}
/* 历史记录列表 */
.data-list {
width: 100%;
.list {
width: 100%;
margin-bottom: 30rpx;
>view:first-of-type {
color: #808080;
width: 100%;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
margin-bottom: 20rpx;
}
>view:last-of-type {
width: 100%;
height: 96rpx;
display: flex;
justify-content: space-between;
padding-left: 30rpx;
padding-right: 50rpx;
box-sizing: border-box;
flex-wrap: nowrap;
border-radius: 16rpx;
background-color: #FFFFFF;
>view {
color: #808080;
font-size: 26rpx;
height: 96rpx;
line-height: 96rpx;
text {
color: #252535;
font-weight: bold;
}
}
}
}
}
/* ===== 空态 ===== */
.empty-state {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 160rpx;
.empty-icon {
width: 193rpx;
height: 138rpx;
margin-bottom: 40rpx;
image {
width: 100%;
height: 100%;
}
}
.empty-text {
color: #808080;
height: 30rpx;
font-size: 30rpx;
line-height: 30rpx;
}
}
}
-252
View File
@@ -1,252 +0,0 @@
import { get } from '../../utils/request/index'
/** 接口 type 参数:0=全部 1=近7天 2=近30天 3=近3月 */
type RangeType = 0 | 1 | 2 | 3
/** 时间范围 Tab 项 */
interface RangeTab {
key: RangeType
label: string
}
/** 缓存中的用户信息 */
interface StorageUserInfo {
userId: string
realname: string
sex: number
height: number
birthday: string
avatar: string | null
relationType: number | string | null
[key: string]: any
}
/** 页面展示用用户信息 */
interface PageUserInfo extends StorageUserInfo {
sex_dictText: '男' | '女' | ''
age: number
isSelf: boolean
}
/** GET /weighingScale/v3/getMeasureStatistics 返回结构 */
interface MeasureStatistics {
maxWeight: number
minWeight: number
avgWeight: number
weightChange: number
}
/** GET /weighingScale/v3/getMeasureHistoryPage records 单条 */
interface MeasureRecord {
recordId: string
examTime: string
weight: number
bmi: number
fatRate: number
}
/** 统计空态默认值 */
const EMPTY_STATS: MeasureStatistics = {
maxWeight: 0,
minWeight: 0,
avgWeight: 0,
weightChange: 0,
}
/** 从生日字符串(YYYY-MM-DD)计算周岁 */
const calcAge = (birthday: string): number => {
if (!birthday) return 0
const [year, month, day] = birthday.split('-').map(Number)
if (!year || !month || !day) return 0
const now = new Date()
let age = now.getFullYear() - year
if (now.getMonth() + 1 < month || (now.getMonth() + 1 === month && now.getDate() < day)) age -= 1
return Math.max(0, age)
}
Page({
data: {
activeType: 1 as RangeType,
rangeTabs: [
{ key: 1, label: '近7天' },
{ key: 2, label: '近30天' },
{ key: 3, label: '近3月' },
] as RangeTab[],
userInfo: null as PageUserInfo | null,
stats: EMPTY_STATS as MeasureStatistics,
records: [] as MeasureRecord[],
pageNo: 1,
total: 0,
hasMore: false,
refresherTriggered: false,
showSelectDrawer: false,
},
onLoad() {
const raw = wx.getStorageSync('userInfo') as StorageUserInfo | null
if (!raw?.userId) return
const userInfo: PageUserInfo = {
...raw,
sex_dictText: raw.sex === 1 ? '男' : raw.sex === 2 ? '女' : '',
age: calcAge(raw.birthday),
isSelf: true,
}
this.setData({ userInfo })
this.loadData()
},
/** 重置分页,并行拉统计 + 第一页列表 */
loadData() {
const userInfo = this.data.userInfo
if (!userInfo?.userId) return
this.setData({ status: 'loading', pageNo: 1, records: [] })
const statsReq = get<MeasureStatistics>('weighingScale/v3/getMeasureStatistics', {
userId: userInfo.userId,
type: this.data.activeType,
}, { loading: false })
const pageReq = get('weighingScale/v3/getMeasureHistoryPage', {
userId: userInfo.userId,
type: this.data.activeType,
pageNo: 1,
pageSize: 10,
}, { loading: false })
wx.showLoading({ title: '加载中...', mask: true })
Promise.all([statsReq, pageReq])
.then(([statsRes, pageRes]: any[]) => {
const rawStats = statsRes.result
const stats: MeasureStatistics = rawStats ? {
maxWeight: rawStats.maxWeight ?? 0,
minWeight: rawStats.minWeight ?? 0,
avgWeight: rawStats.avgWeight ?? 0,
weightChange: rawStats.weightChange ?? 0,
} : EMPTY_STATS
const page = pageRes.result ?? {}
const records: MeasureRecord[] = (page.records ?? []).map((r: any) => ({
recordId: r.recordId ?? '',
examTime: r.examTime ?? '',
weight: r.weight ?? 0,
bmi: r.bmi ?? 0,
fatRate: r.fatRate ?? 0,
}))
const total = page.total ?? 0
this.setData({
stats,
records,
total,
hasMore: records.length < total,
})
})
.finally(() => {
wx.hideLoading()
this.setData({ refresherTriggered: false })
})
},
/** scroll-view 触底,加载下一页 */
onScrollToLower() {
if (!this.data.hasMore) return
const userInfo = this.data.userInfo
if (!userInfo?.userId) return
const nextPage = this.data.pageNo + 1
wx.showLoading({ title: '加载中...', mask: true })
get('weighingScale/v3/getMeasureHistoryPage', {
userId: userInfo.userId,
type: this.data.activeType,
pageNo: nextPage,
pageSize: 10,
}, { loading: false })
.then((res: any) => {
const page = res.result ?? {}
const newRecords: MeasureRecord[] = (page.records ?? []).map((r: any) => ({
recordId: r.recordId ?? '',
examTime: r.examTime ?? '',
weight: r.weight ?? 0,
bmi: r.bmi ?? 0,
fatRate: r.fatRate ?? 0,
}))
const allRecords = [...this.data.records, ...newRecords]
this.setData({
records: allRecords,
pageNo: nextPage,
hasMore: allRecords.length < this.data.total,
})
})
.finally(() => {
wx.hideLoading()
})
},
/** scroll-view 下拉刷新 */
onRefresh() {
this.setData({ refresherTriggered: true })
this.loadData()
},
/** 切换时间范围 Tab */
onTapRange(e: WechatMiniprogram.TouchEvent) {
const key = Number(e.currentTarget.dataset.key) as RangeType
if (key === this.data.activeType) return
this.setData({ activeType: key })
this.loadData()
},
/** 点击记录行,携带 recordId + userId 跳转测量报告 */
onTapRecord(e: WechatMiniprogram.TouchEvent) {
const recordId = e.currentTarget.dataset.recordId as string
const userId = this.data.userInfo?.userId ?? ''
wx.navigateTo({
url: `/pages/measurementReport/measurementReport?recordId=${recordId}&userId=${userId}`,
})
},
/** 打开切换用户抽屉 */
onTapSwitchMember() {
this.setData({ showSelectDrawer: true })
},
/** 抽屉关闭 */
onCloseDrawer() {
this.setData({ showSelectDrawer: false })
},
/** 选中用户后更新 userInfo 并重新请求数据 */
onSelectMember(e: WechatMiniprogram.CustomEvent) {
const m = e.detail as {
userId?: string
id: string
name: string
gender: '男' | '女'
age: number
height: number
sex?: number
birthday?: string
relationType?: number | string | null
avatar?: string
}
const storedUserId = (wx.getStorageSync('userInfo') as StorageUserInfo | null)?.userId ?? ''
const userInfo: PageUserInfo = {
id: m.id,
userId: m.userId ?? '',
realname: m.name,
sex: m.sex ?? (m.gender === '男' ? 1 : 2),
height: m.height,
birthday: m.birthday ?? '',
avatar: m.avatar ?? null,
relationType: m.relationType ?? null,
sex_dictText: m.gender,
age: m.age,
isSelf: m.userId === storedUserId,
}
this.setData({ showSelectDrawer: false, userInfo })
this.loadData()
},
})
-106
View File
@@ -1,106 +0,0 @@
<scroll-view
class="scrollView"
scroll-y
refresher-enabled
refresher-triggered="{{ refresherTriggered }}"
bind:refresherrefresh="onRefresh"
bind:scrolltolower="onScrollToLower"
>
<view class="scrollViewContent">
<!-- 数据卡(用户信息 + 时间 Tab + 统计) -->
<view class="data-card">
<!-- 用户信息 -->
<view class="userInfo">
<view class="avatar">{{ userInfo.realname[0] }}</view>
<view class="info">
<view class="info-name-row">
<view class="info-name">{{ userInfo.realname }}</view>
<block wx:if="{{ userInfo.isSelf }}">
<view class="badge-self">本人</view>
</block>
</view>
<view class="info-meta">
<view class="meta-text">{{ userInfo.sex_dictText }}</view>
<view class="meta-divider">·</view>
<view class="meta-text">{{ userInfo.age }}岁</view>
<view class="meta-divider">|</view>
<view class="meta-text">{{ userInfo.height }}cm</view>
</view>
</view>
<view class="btn" bind:tap="onTapSwitchMember">切换用户</view>
</view>
<view class="card-divider"></view>
<!-- 时间范围 Tab -->
<view class="nav">
<block wx:for="{{ rangeTabs }}" wx:key="key">
<view
class="{{ activeType === item.key ? 'active' : '' }}"
data-key="{{ item.key }}"
bind:tap="onTapRange"
>{{ item.label }}</view>
</block>
</view>
<!-- 统计摘要(4格) -->
<view class="summary">
<view class="summary-item">
<view class="summary-label">最高体重</view>
<view class="summary-value">{{ stats.maxWeight }}<text>kg</text></view>
</view>
<view class="summary-item">
<view class="summary-label">最低体重</view>
<view class="summary-value">{{ stats.minWeight }}<text>kg</text></view>
</view>
<view class="summary-item">
<view class="summary-label">平均体重</view>
<view class="summary-value">{{ stats.avgWeight }}<text>kg</text></view>
</view>
<view class="summary-item">
<view class="summary-label">体重变化</view>
<view class="summary-value {{ stats.weightChange < 0 ? 'value-down' : 'value-up' }}">
{{ stats.weightChange > 0 ? '+' : '' }}{{ stats.weightChange }}<text>kg</text>
</view>
</view>
</view>
</view>
<!-- 有数据:记录列表 -->
<block wx:if="{{ records.length }}">
<view class="data-list">
<block wx:for="{{ records }}" wx:key="recordId">
<view class="list" bind:tap="onTapRecord" data-record-id="{{ item.recordId }}">
<view>{{ item.examTime }}</view>
<view class="arrow">
<view>体重:<text>{{ item.weight }}kg</text></view>
<view>BMI<text>{{ item.bmi }}</text></view>
<view>体脂率:<text>{{ item.fatRate }}%</text></view>
</view>
</view>
</block>
</view>
</block>
<!-- 无数据:占位 -->
<block wx:else>
<view class="empty-state">
<view class="empty-icon">
<image src="/images/data/noData.png" mode="aspectFit"/>
</view>
<view class="empty-text">暂无称重数据</view>
</view>
</block>
</view>
</scroll-view>
<select-member-drawer
show="{{ showSelectDrawer }}"
source="history"
exclude-user-id="{{ userInfo.userId }}"
bind:select="onSelectMember"
bind:close="onCloseDrawer"
/>