diff --git a/miniprogram/components/selectMemberDrawer/selectMemberDrawer.less b/miniprogram/components/selectMemberDrawer/selectMemberDrawer.less index a1e47b1..6fc6ca1 100644 --- a/miniprogram/components/selectMemberDrawer/selectMemberDrawer.less +++ b/miniprogram/components/selectMemberDrawer/selectMemberDrawer.less @@ -35,40 +35,44 @@ } } -/* 标题栏(标题居中,关闭按钮绝对定位右侧) */ +/* 拖拽把手 */ +.drawer-handle { + width: 72rpx; + height: 6rpx; + background-color: #77849E; + border-radius: 3rpx; + margin: 32rpx auto 40rpx; +} + +/* 标题栏 */ .drawer-header { - position: relative; width: 100%; - height: 124rpx; + height: 32rpx; + padding: 0 30rpx; box-sizing: border-box; display: flex; align-items: center; - justify-content: center; + justify-content: space-between; .drawer-title { color: #252535; - font-size: 36rpx; - font-weight: bolder; - line-height: 36rpx; + height: 32rpx; + font-size: 32rpx; + font-weight: 700; + line-height: 32rpx; } - /* 关闭按钮:圆形浅灰底 + 灰色 × */ + /* 关闭按钮 */ .drawer-close { - position: absolute; - right: 32rpx; - top: 50%; - transform: translateY(-50%); - width: 48rpx; - height: 48rpx; - border-radius: 50%; - background-color: #F1F5F9; + width: 32rpx; + height: 32rpx; display: flex; align-items: center; justify-content: center; .drawer-close-icon { - width: 26rpx; - height: 26rpx; + width: 28rpx; + height: 28rpx; position: relative; &::before, @@ -79,7 +83,7 @@ left: 50%; width: 100%; height: 3rpx; - background-color: #77849E; + background-color: #252535; border-radius: 2rpx; } @@ -96,122 +100,158 @@ /* 顶部分隔线 */ .drawer-divider { - width: 100%; + width: 690rpx; height: 2rpx; - background-color: #EAECFA; + background-color: #EAEDF1; + margin: 39rpx 30rpx 0; flex-shrink: 0; } -.scrollViewContent { +/* 用户滚动列表 */ +.drawer-list { + flex: 1; + overflow: hidden; + padding-bottom: env(safe-area-inset-bottom); +} + +/* 用户行 */ +.member-item { width: 100%; - height: 100%; + height: 90rpx; + padding: 0 30rpx; box-sizing: border-box; + display: flex; + flex-direction: row; + align-items: center; + margin-top: 24rpx; - /* 用户行 */ - .member-item { - width: 100%; - padding: 24rpx 0; - display: flex; - flex-direction: row; - align-items: center; - border-bottom: 2rpx solid #EAECF1; + /* 有图片头像 */ + .member-avatar { + width: 90rpx; + height: 90rpx; + border-radius: 24rpx; + flex-shrink: 0; - /* 有图片头像 */ - .member-avatar { - width: 88rpx; - height: 88rpx; - overflow: hidden; - margin-right: 15rpx; - border-radius: 24rpx; - - &--selected { - border: 3rpx solid #50A6FF; - } - } - - /* 纯色占位头像 */ - .member-avatar-placeholder { - width: 88rpx; - height: 88rpx; - overflow: hidden; - border-radius: 24rpx; - margin-right: 15rpx; - - /* 男:蓝色 */ - &--male { - background-color: #C6E6FF; - } - - /* 女:粉色 */ - &--female { - background-color: #FFD5E3; - } - - /* 选中男 */ - &--selected-male { - border: 3rpx solid #50A6FF; - width: 94rpx; - height: 94rpx; - margin: -3rpx 0 0 -3rpx; - } - - /* 选中女 */ - &--selected-female { - border: 3rpx solid #FF8FB5; - width: 94rpx; - height: 94rpx; - margin: -3rpx 0 0 -3rpx; - } - } - - /* 姓名 + 副标题 */ - .member-info { - flex: 1; - width: 0; - - .member-name { - color: #252535; - width: 100%; - height: 32rpx; - font-size: 32rpx; - font-weight: bolder; - line-height: 32rpx; - margin-bottom: 16rpx; - } - - .member-sub { - color: #808080; - width: 100%; - height: 26rpx; - font-size: 26rpx; - line-height: 26rpx; - } - } - - .member-type { - height: 40rpx; - flex-shrink: 0; - - .member-type-tag { - height: 40rpx; - padding: 0 10rpx; - font-size: 24rpx; - line-height: 40rpx; - border-radius: 8rpx; - color: #FFFFFF; - } - - .member-type-tag--self { - background-color: #1385FA; - } - - .member-type-tag--employee { - background-color: #10B981; - } - - .member-type-tag--family { - background-color: #F59E0B; - } + &--selected { + border: 3rpx solid #50A6FF; } } -} \ No newline at end of file + + /* 纯色占位头像 */ + .member-avatar-placeholder { + width: 90rpx; + height: 90rpx; + border-radius: 24rpx; + flex-shrink: 0; + + /* 男:蓝色 */ + &--male { + background-color: #C6E6FF; + } + + /* 女:粉色 */ + &--female { + background-color: #FFD5E3; + } + + /* 选中男 */ + &--selected-male { + border: 3rpx solid #50A6FF; + width: 96rpx; + height: 96rpx; + margin: -3rpx 0 0 -3rpx; + } + + /* 选中女 */ + &--selected-female { + border: 3rpx solid #FF8FB5; + width: 96rpx; + height: 96rpx; + margin: -3rpx 0 0 -3rpx; + } + } + + /* 姓名 + 副标题 */ + .member-info { + flex: 1; + height: 78rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + margin-left: 23rpx; + + .member-name { + color: #333333; + height: 32rpx; + font-size: 32rpx; + font-weight: 500; + line-height: 32rpx; + white-space: nowrap; + } + + .member-sub { + color: #77849E; + height: 34rpx; + font-size: 26rpx; + line-height: 34rpx; + white-space: nowrap; + } + } + + .member-type { + height: 40rpx; + flex-shrink: 0; + + .member-type-tag { + height: 40rpx; + padding: 0 14rpx; + font-size: 22rpx; + line-height: 40rpx; + border-radius: 6rpx; + } + + .member-type-tag--self { + color: #1385FA; + background-color: rgba(19, 133, 250, 0.12); + } + + .member-type-tag--employee { + color: #10B981; + background-color: rgba(16, 185, 129, 0.12); + } + + .member-type-tag--family { + color: #F59E0B; + background-color: rgba(245, 158, 11, 0.12); + } + } +} + +/* 行间水平分隔线 */ +.member-separator { + width: 690rpx; + height: 2rpx; + background-color: #EAEDF1; + margin: 24rpx 30rpx 0; +} + +/* 空态占位 */ +.drawer-empty { + display: flex; + flex-direction: column; + align-items: center; + padding-top: 80rpx; + + .drawer-empty-icon { + width: 193rpx; + height: 138rpx; + margin-bottom: 30rpx; + } + + .drawer-empty-text { + color: #808080; + height: 28rpx; + font-size: 28rpx; + line-height: 28rpx; + } +} diff --git a/miniprogram/components/selectMemberDrawer/selectMemberDrawer.ts b/miniprogram/components/selectMemberDrawer/selectMemberDrawer.ts index 77643d8..2a09b08 100644 --- a/miniprogram/components/selectMemberDrawer/selectMemberDrawer.ts +++ b/miniprogram/components/selectMemberDrawer/selectMemberDrawer.ts @@ -1,3 +1,34 @@ +import { get } from '../../utils/request/index' +import { leFuService } from '../../lefu/index' +import { calcAge } from '../../utils/idCard/index' + +/** GET /weighingScale/v5/select/addMembers/user 返回的单条结构 */ +interface AddMemberApiItem { + id: string + realname: string + sex_dictText: '男' | '女' + birthday: string + height: number + weight: number + idCard: string | null + avatar: string | null + dataType?: number + relationType?: number | string | null +} + +/** GET /weighingScale/v3/select/history/user 返回的单条结构 */ +interface HistoryApiItem { + id: string + userId: string + realname: string + sex: number + height: number + birthday: string + avatar: string | null + relationType: number | string | null + dataType?: number +} + /** 抽屉内部用户项(含回填所需全量字段) */ interface ExistingMember { id: string @@ -20,7 +51,7 @@ interface ExistingMember { /** * 选择已有用户抽屉组件 - * Properties: show(控制显示) + * Properties: show(控制显示)、source(数据来源:addMember/history)、excludeUserId(排除用户) * Events: close(关闭), select(选中用户,携带 ExistingMember) */ Component({ @@ -30,6 +61,11 @@ Component({ type: Boolean, value: false }, + /** 数据来源模式:addMember=新增用户选择 / history=历史数据切换用户 */ + source: { + type: String, + value: 'addMember' + }, /** 需要排除的用户 ID(history 模式下排除当前查看的用户) */ excludeUserId: { type: String, @@ -42,64 +78,8 @@ Component({ innerShow: false, /** 控制 --visible 类,触发 CSS transition */ animVisible: false, - /** 用户列表(静态假数据填充,后续接真实接口替换) */ - members: [ - { - id: '1', - name: '张晓敏', - gender: '男', - age: 36, - height: 170, - weight: 89.6, - idCard: '', - relationType: 1, - selected: false - }, - { - id: '2', - name: '李晓华', - gender: '女', - age: 34, - height: 162, - weight: 52, - idCard: '', - dataType: 1, - selected: false - }, - { - id: '3', - name: '王建军', - gender: '男', - age: 40, - height: 175, - weight: 68, - idCard: '', - dataType: 1, - selected: false - }, - { - id: '4', - name: '陈静', - gender: '女', - age: 28, - height: 158, - weight: 48, - idCard: '', - dataType: 0, - selected: false - }, - { - id: '5', - name: '刘洋', - gender: '男', - age: 30, - height: 180, - weight: 72, - idCard: '', - dataType: 0, - selected: false - } - ] as ExistingMember[] + /** 用户列表(组件内部拉取) */ + members: [] as ExistingMember[] }, observers: { @@ -109,20 +89,85 @@ Component({ */ show(val: boolean) { if (val) { - this.setData({innerShow: true}) + this._fetchMembers() + this.setData({ innerShow: true }) setTimeout(() => { - this.setData({animVisible: true}) + this.setData({ animVisible: true }) }, 20) } else { - this.setData({animVisible: false}) + this.setData({ animVisible: false }) setTimeout(() => { - this.setData({innerShow: false}) + this.setData({ innerShow: false }) }, 300) } } }, methods: { + /** 调接口获取可选用户列表,根据 source 调不同接口 */ + _fetchMembers() { + const userInfo = wx.getStorageSync('userInfo') as { userId?: string } | null + const userId = userInfo?.userId ?? '' + + wx.showLoading({ title: '加载中...', mask: true }) + + if (this.properties.source === 'history') { + const params: Record = { userId } + if (this.properties.excludeUserId) { + params.userIdExclude = this.properties.excludeUserId + } + get('weighingScale/v3/select/history/user', params, { loading: false }) + .then((res: any) => { + const members: ExistingMember[] = (res.result ?? []).map((item: HistoryApiItem) => ({ + id: item.id, + name: item.realname, + gender: item.sex === 1 ? '男' : '女', + age: calcAge(item.birthday), + height: item.height, + weight: 0, + idCard: '', + avatar: item.avatar ?? '', + userId: item.userId, + sex: item.sex, + birthday: item.birthday, + relationType: item.relationType, + dataType: item.dataType, + })) + this.setData({ members }) + }) + .catch(() => { + wx.showToast({ title: '加载失败', icon: 'none' }) + }) + .finally(() => { + wx.hideLoading() + }) + } else { + const sn = leFuService.deviceInfo?.serialNumber ?? '' + get('weighingScale/v5/select/addMembers/user', { userId, sn }, { loading: false }) + .then((res: any) => { + const members: ExistingMember[] = (res.result ?? []).map((item: AddMemberApiItem) => ({ + id: item.id, + name: item.realname, + gender: item.sex_dictText, + age: calcAge(item.birthday), + height: item.height, + weight: item.weight, + idCard: item.idCard ?? '', + avatar: item.avatar ?? '', + relationType: item.relationType, + dataType: item.dataType, + })) + this.setData({ members }) + }) + .catch(() => { + wx.showToast({ title: '加载失败', icon: 'none' }) + }) + .finally(() => { + wx.hideLoading() + }) + } + }, + /** 点击遮罩关闭 */ onTapMask() { this.triggerEvent('close') @@ -133,10 +178,7 @@ Component({ this.triggerEvent('close') }, - /** - * 点击用户行,触发 select 事件 - * @param e 携带 data-member 的点击事件 - */ + /** 点击用户行,触发 select 事件 */ onTapMember(e: WechatMiniprogram.TouchEvent) { const member = e.currentTarget.dataset.member as ExistingMember this.triggerEvent('select', member) diff --git a/miniprogram/components/selectMemberDrawer/selectMemberDrawer.wxml b/miniprogram/components/selectMemberDrawer/selectMemberDrawer.wxml index 2c8d595..2c939ef 100644 --- a/miniprogram/components/selectMemberDrawer/selectMemberDrawer.wxml +++ b/miniprogram/components/selectMemberDrawer/selectMemberDrawer.wxml @@ -5,9 +5,12 @@ + + + - 切换用户 + 选择已有用户 @@ -18,45 +21,49 @@ - - - - - - - - - - - + + + + + + + + + + - - - {{ item.name }} - {{ item.gender }}·{{ item.age }}岁 丨 {{ item.height }}cm - - - - - 本人 - - - 员工 - - - 家庭用户 - - + + + {{ item.name }} + {{ item.gender }}·{{ item.age }}岁 丨 {{ item.height }}cm - - + + + + 本人 + + + 员工 + + + 家庭用户 + + + + + + + - + + + 暂无可选用户 + diff --git a/miniprogram/pages/data/data.less b/miniprogram/pages/data/data.less index bb35273..6b6fe43 100644 --- a/miniprogram/pages/data/data.less +++ b/miniprogram/pages/data/data.less @@ -1,7 +1,8 @@ -.scrollViewContent { +.data { width: 100%; - padding: 24rpx 30rpx; - box-sizing: border-box; + height: 100%; + display: flex; + flex-flow: column; .data-card { width: 100%; @@ -231,74 +232,85 @@ } } - /* 历史记录列表 */ - .data-list { - width: 100%; + .data-user-list { + flex: 1; + overflow: hidden; - .list { + .scrollViewContent { width: 100%; - margin-bottom: 30rpx; - - >view:first-of-type { - color: #808080; + padding: 24rpx 30rpx; + box-sizing: border-box; + + /* 历史记录列表 */ + .data-list { 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; + + .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; } } } } - - /* ===== 空态 ===== */ - .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; - } - } -} +} \ No newline at end of file diff --git a/miniprogram/pages/data/data.ts b/miniprogram/pages/data/data.ts index c281326..ee0d380 100644 --- a/miniprogram/pages/data/data.ts +++ b/miniprogram/pages/data/data.ts @@ -1,27 +1,236 @@ -// pages/data/data.ts -Page({ +import { get } from '../../utils/request/index' +import { calcAge } from '../../utils/idCard/index' +import type { UserInfo } from '../../api/index' - /** - * 页面的初始数据 - */ +type RangeType = 1 | 2 | 3 + +interface RangeTab { + key: RangeType + label: string +} + +/** 页面展示用用户信息 */ +interface PageUserInfo { + userId: string + realname: string + sex: number + sex_dictText: string + age: number + height: number + avatar: string | null + birthday: string + relationType: number | string | null + 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 +} + +/** GET /weighingScale/v3/getMeasureHistoryPage 返回结构 */ +interface MeasureHistoryPageResult { + records: MeasureRecord[] + total: number +} + +/** 切换用户抽屉 select 事件 detail */ +interface MemberSelectDetail { + id: string + name: string + gender: '男' | '女' + age: number + height: number + userId?: string + sex?: number + birthday?: string + relationType?: number | string | null + avatar?: string +} + +/** 统计空态默认值 */ +const EMPTY_STATS: MeasureStatistics = { + maxWeight: 0, + minWeight: 0, + avgWeight: 0, + weightChange: 0, +} + +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 UserInfo | null + if (!raw?.userId) return + this.setData({ userInfo: this._buildSelfUserInfo(raw) }) + this.loadData() }, - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - + /** 由缓存用户信息构建「本人」展示信息 */ + _buildSelfUserInfo(raw: UserInfo): PageUserInfo { + return { + userId: raw.userId, + realname: raw.realname ?? '', + sex: raw.sex, + sex_dictText: raw.sex === 1 ? '男' : raw.sex === 2 ? '女' : '', + age: calcAge(raw.birthday), + height: raw.height ?? 0, + avatar: raw.avatar ?? null, + birthday: raw.birthday ?? '', + relationType: raw.relationType ?? null, + isSelf: true, + } }, + /** 重置分页,并行拉统计 + 第一页列表 */ + loadData() { + const userInfo = this.data.userInfo + if (!userInfo?.userId) return + this.setData({ pageNo: 1, records: [] }) + + const statsReq = get('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]) => { + 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) => ({ + 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, + }) + }) + .catch(() => { + this.setData({ stats: EMPTY_STATS, records: [], total: 0, hasMore: false }) + }) + .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) => { + const page = res.result ?? {} + const newRecords: MeasureRecord[] = (page.records ?? []).map((r) => ({ + 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, + }) + }) + .catch(() => { + wx.showToast({ title: '加载失败,请重试', icon: 'none' }) + }) + .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() + }, + + /** 点击记录行,跳转测量报告 */ + onTapRecord(e: WechatMiniprogram.TouchEvent) { + const recordId = e.currentTarget.dataset.recordId as string + const userId = this.data.userInfo?.userId ?? '' + wx.navigateTo({ + url: `/pages/detailedReport/detailedReport?recordId=${recordId}&userId=${userId}`, + }) + }, + + /** 打开切换用户抽屉 */ onTapSwitchMember() { this.setData({ showSelectDrawer: true }) }, @@ -30,4 +239,28 @@ Page({ onCloseDrawer() { this.setData({ showSelectDrawer: false }) }, -}) \ No newline at end of file + + /** 选中用户后更新 userInfo 并重新请求数据 */ + onSelectMember(e: WechatMiniprogram.CustomEvent) { + const m = e.detail as MemberSelectDetail + if (!m.userId) { + wx.showToast({ title: '用户信息异常', icon: 'none' }) + return + } + const storedUserId = (wx.getStorageSync('userInfo') as UserInfo | null)?.userId ?? '' + const userInfo: PageUserInfo = { + userId: m.userId, + realname: m.name, + sex: m.sex ?? (m.gender === '男' ? 1 : 2), + sex_dictText: m.gender, + age: m.age, + height: m.height, + avatar: m.avatar ?? null, + birthday: m.birthday ?? '', + relationType: m.relationType ?? null, + isSelf: m.userId === storedUserId, + } + this.setData({ showSelectDrawer: false, userInfo }) + this.loadData() + }, +}) diff --git a/miniprogram/pages/data/data.wxml b/miniprogram/pages/data/data.wxml index 83b8156..dd8af55 100644 --- a/miniprogram/pages/data/data.wxml +++ b/miniprogram/pages/data/data.wxml @@ -1,91 +1,87 @@ - - - - - - - - - - - - 张晓敏 + + + + + + {{ userInfo.realname[0] }} + + + {{ userInfo.realname }} + 本人 - - - 男·36岁 - | - 170cm - + + + + {{ userInfo.sex_dictText }} + · + {{ userInfo.age }}岁 + | + {{ userInfo.height }}cm - 切换用户 + 切换用户 + - + - - - 近7日 - 近30日 - 近90日 + + + + {{ item.label }} + + + + + + + 最高体重 + {{ stats.maxWeight }}kg - - - - - 最高体重 - 89.6kg - - - 最低体重 - 89.6kg - - - 平均体重 - 89.6kg - - - 体重变化 - - {{ stats.weightChange > 0 ? '+' : '' }}{{ stats.weightChange }}kg - + + 最低体重 + {{ stats.minWeight }}kg + + + 平均体重 + {{ stats.avgWeight }}kg + + + 体重变化 + + {{ stats.weightChange > 0 ? '+' : '' }}{{ stats.weightChange }}kg + - - - - - - {{ item.examTime }} - - 体重:{{ item.weight }}kg - BMI:{{ item.bmi }} - 体脂率:{{ item.fatRate }}% - + + + + + + + + + + {{ item.examTime }} + + 体重:{{ item.weight }}kg + BMI:{{ item.bmi }} + 体脂率:{{ item.fatRate }}% + + + + + + + + + - - - - - - + - + - + \ No newline at end of file diff --git a/miniprogram/pages/detailedReport/detailedReport.ts b/miniprogram/pages/detailedReport/detailedReport.ts index 477eb6c..2cada97 100644 --- a/miniprogram/pages/detailedReport/detailedReport.ts +++ b/miniprogram/pages/detailedReport/detailedReport.ts @@ -199,7 +199,7 @@ Page({ onLoad(options: Record) { const recordId = options.recordId || '' const userInfo = (wx.getStorageSync('userInfo') || {}) as Record - const userId = userInfo.userId || '' + const userId = options.userId || userInfo.userId || '' this.fetchHistory(userId, recordId) },