[AI Generated]: feat(*): 完善数据页切换成员、首页接口对接及我的页缓存信息展示
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { get } from '../../utils/request/index'
|
||||
import { lefuService } from '../../lefu/index'
|
||||
|
||||
/** 设备信息 */
|
||||
interface DeviceInfo {
|
||||
@@ -49,7 +50,7 @@ interface StorageUserInfo {
|
||||
}
|
||||
|
||||
/** 将体重数字拆成整数 + 小数字符串 */
|
||||
function splitWeight(weight: number): { int: number; decimal: string } {
|
||||
const splitWeight = (weight: number): { int: number; decimal: string } => {
|
||||
const str = weight.toFixed(2)
|
||||
const [intPart, decPart] = str.split('.')
|
||||
return { int: Number(intPart), decimal: `.${decPart}` }
|
||||
@@ -66,9 +67,28 @@ Page({
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.setData({
|
||||
'device.connected': lefuService.isConnected,
|
||||
'device.name': lefuService.deviceInfo?.name ?? '智能体重秤',
|
||||
})
|
||||
lefuService.onDeviceInfo((info) => {
|
||||
this.setData({ 'device.name': info.name ?? '智能体重秤' })
|
||||
})
|
||||
lefuService.onDeviceConnect(() => {
|
||||
this.setData({ 'device.connected': true })
|
||||
})
|
||||
lefuService.onDisconnected(() => {
|
||||
this.setData({ 'device.connected': false })
|
||||
})
|
||||
this.loadData()
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
lefuService.onDeviceConnect(() => {})
|
||||
lefuService.onDisconnected(() => {})
|
||||
lefuService.onDeviceInfo(() => {})
|
||||
},
|
||||
|
||||
onShareAppMessage(): WechatMiniprogram.Page.ICustomShareContent {
|
||||
return {
|
||||
title: '智能蓝牙秤',
|
||||
@@ -118,8 +138,8 @@ Page({
|
||||
wx.switchTab({ url: '/pages/data/data' })
|
||||
},
|
||||
|
||||
/** 切换设备 */
|
||||
/** 跳转设备列表页 */
|
||||
onTapSwitchDevice() {
|
||||
wx.showToast({ title: '切换设备', icon: 'none' })
|
||||
wx.switchTab({ url: '/pages/equipment/equipment' })
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user