feat(device): 设备连接成功后缓存关联用户信息;添加成员时携带 SN
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
87b789f5f3
commit
85402f2ec1
@@ -45,6 +45,13 @@ interface DeviceItem {
|
||||
realname: string
|
||||
/** 蓝牙连接状态,接口不返回,由业务层更新 */
|
||||
connected: boolean
|
||||
userId: string
|
||||
sex: number
|
||||
height: number
|
||||
birthday: string
|
||||
avatar: string | null
|
||||
relationType: string | null
|
||||
sex_dictText: string
|
||||
}
|
||||
|
||||
Page({
|
||||
@@ -82,6 +89,13 @@ Page({
|
||||
connectDeviceInfo: item.connectDeviceInfo ?? '',
|
||||
realname: item.realname,
|
||||
connected: false,
|
||||
userId: item.userId,
|
||||
sex: item.sex,
|
||||
height: item.height,
|
||||
birthday: item.birthday,
|
||||
avatar: item.avatar,
|
||||
relationType: item.relationType,
|
||||
sex_dictText: item.sex_dictText,
|
||||
}
|
||||
})
|
||||
this.setData({ deviceList: list }, () => {
|
||||
@@ -119,6 +133,7 @@ Page({
|
||||
|
||||
/** 点击「连接」:扫描周边设备,找到 deviceId 匹配的设备后连接 */
|
||||
onTapConnect(e: WechatMiniprogram.TouchEvent) {
|
||||
const userInfo = e.currentTarget.dataset.userInfo as DeviceItem
|
||||
const connectDeviceInfoStr = e.currentTarget.dataset.connectDeviceInfo as string
|
||||
let cachedDevice: RawDevice | null = null
|
||||
try {
|
||||
@@ -151,6 +166,19 @@ Page({
|
||||
lefuService.onDeviceConnect(() => {
|
||||
wx.hideLoading()
|
||||
wx.setStorageSync('connectDeviceInfo', matched.raw)
|
||||
// 连接成功后缓存当前设备关联的用户信息
|
||||
if (userInfo) {
|
||||
wx.setStorageSync('userInfo', {
|
||||
userId: userInfo.userId,
|
||||
realname: userInfo.realname,
|
||||
sex: userInfo.sex,
|
||||
height: userInfo.height,
|
||||
birthday: userInfo.birthday,
|
||||
avatar: userInfo.avatar,
|
||||
relationType: userInfo.relationType,
|
||||
sex_dictText: userInfo.sex_dictText,
|
||||
})
|
||||
}
|
||||
})
|
||||
lefuService.onDeviceInfo((info) => {
|
||||
this._markConnected(info.serialNumber as string)
|
||||
|
||||
Reference in New Issue
Block a user