[AI Generated]: feat(device): 配网/绑定后下发主用户到设备并兜底超时

- configWifi 加 20s 超时与 settled 互锁,避免回调不触发导致 loading 死转
- supplementPersonal 提交后、connectedWifi 二次配网确认后均下发主用户
- 设备成员唯一标识从 idCard 切换为 userId,清理 MemberDisplay.idCard

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-05-21 15:56:44 +08:00
co-authored by Claude Opus 4.7
parent e4404a6b0c
commit ea52c495f6
5 changed files with 81 additions and 11 deletions
@@ -1,5 +1,6 @@
import { get, put } from '../../utils/request/index'
import { lefuService } from '../../lefu/index'
import type { DeviceMember } from '../../lefu/index'
/** 表单数据模型 */
interface PersonalForm {
@@ -243,9 +244,7 @@ Page({
// connectDeviceInfo 存储时已 JSON.parse 为对象,提交时还原为 JSON 字符串
const connectDeviceInfoRaw = wx.getStorageSync('connectDeviceInfo')
const connectDeviceInfo: string = connectDeviceInfoRaw
? JSON.stringify(connectDeviceInfoRaw)
: ''
const connectDeviceInfo: string = connectDeviceInfoRaw ? JSON.stringify(connectDeviceInfoRaw) : ''
const serverResult = this.data.serverResult as UserInfoFromServer
const payload: UpdateUserPayload = {
@@ -263,7 +262,26 @@ Page({
.then(res => {
const { connectDeviceInfo: _, ...userInfo } = res.result
wx.setStorageSync('userInfo', userInfo)
wx.switchTab({ url: '/pages/home/home' })
const mainUser: DeviceMember = {
id: payload.userId,
name: payload.realname,
gender: payload.sex === 1 ? 1 : 0,
age: parseInt(parsed.age, 10) || 0,
height: payload.height,
isSelf: true,
}
wx.showLoading({ title: '正在下发主用户...', mask: true })
lefuService.syncMembersToDevice([mainUser])
.then(() => {
wx.hideLoading()
wx.switchTab({ url: '/pages/home/home' })
})
.catch((err: Error) => {
wx.hideLoading()
wx.showToast({ title: err.message || '主用户下发失败', icon: 'none' })
})
})
}
})