feat: 详细报告接入 v3 测量历史接口,设备列表接入设备接口
- 详细报告按 scaleType 区分 4/8 电极渲染,节段卡片 8 电极专属 - 设备列表改为接口驱动并新增空态 - 登录后统一跳首页,请求层兼容 code 0 返回风格 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
fce9701254
commit
d6e59df4e9
@@ -1,29 +1,74 @@
|
||||
// pages/equipment/equipment.ts
|
||||
import { get } from '../../utils/request/index'
|
||||
|
||||
/** 体重设备(对应 /weighingScale/list/device 返回的 result 元素) */
|
||||
interface ScaleDevice {
|
||||
/** 设备ID */
|
||||
id: string
|
||||
/** 设备名称 */
|
||||
equipmentName: string
|
||||
/** 设备SN */
|
||||
equipmentCode: string
|
||||
/** 状态 */
|
||||
status: number
|
||||
canteenId: string | null
|
||||
/** MAC 地址 */
|
||||
macAddress: string
|
||||
/** WiFi 名称 */
|
||||
wifiName: string
|
||||
isSync: number
|
||||
/** 成员人数 */
|
||||
subUserNum: number
|
||||
}
|
||||
|
||||
/** 获取体重设备列表 */
|
||||
const getDeviceList = () =>
|
||||
get<ScaleDevice[]>('weighingScale/list/device')
|
||||
|
||||
/** 展示用设备项 */
|
||||
interface DeviceItem {
|
||||
id: string
|
||||
name: string
|
||||
status: string
|
||||
connected: boolean
|
||||
model: string
|
||||
serial: string
|
||||
subUserNum: number
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
devices: [
|
||||
{
|
||||
id: 1,
|
||||
name: '家庭蓝牙体脂秤 S1',
|
||||
status: '已连接',
|
||||
connected: true,
|
||||
model: 'BS-A100',
|
||||
serial: 'BL2024A00158',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '家庭蓝牙体脂秤 S1',
|
||||
status: '未连接',
|
||||
connected: false,
|
||||
model: 'BW-B200',
|
||||
serial: 'BL2024B00321',
|
||||
}
|
||||
],
|
||||
loadingShow: true,
|
||||
devices: [] as DeviceItem[],
|
||||
loadingShow: false,
|
||||
loadingTitle: '正在连接设备',
|
||||
loadingContent: '请确保设备处于开启状态\n请勿离开...'
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadDevices()
|
||||
},
|
||||
|
||||
/** 拉取体重设备列表 */
|
||||
async loadDevices() {
|
||||
try {
|
||||
const res = await getDeviceList()
|
||||
this.setData({
|
||||
devices: res.result.map(item => ({
|
||||
id: item.id,
|
||||
name: item.equipmentName,
|
||||
// status 具体枚举待确认,先按 1 = 已连接处理
|
||||
status: item.status === 1 ? '已连接' : '未连接',
|
||||
connected: item.status === 1,
|
||||
// 接口无独立「型号」字段,先用设备名称占位
|
||||
model: item.equipmentName,
|
||||
serial: item.equipmentCode,
|
||||
subUserNum: item.subUserNum,
|
||||
})),
|
||||
})
|
||||
} catch {
|
||||
// 请求失败已由 request 层统一 toast
|
||||
}
|
||||
},
|
||||
|
||||
/** 取消配对:使用小程序自带 showModal */
|
||||
onTapUnpair() {
|
||||
wx.showModal({
|
||||
@@ -63,7 +108,7 @@ Page({
|
||||
},
|
||||
|
||||
onTapAdd() {
|
||||
// 添加设备(待接入)
|
||||
wx.navigateTo({ url: '/pages/connectedDevice/connectedDevice' })
|
||||
},
|
||||
|
||||
/** 关闭运维模式 */
|
||||
|
||||
Reference in New Issue
Block a user