[AI Generated]: refactor(*): 重构用户初始化流程,接口化用户管理并支持增量下发设备
- 重构 configureDevice 步骤0:新增双条件控制(deviceInfo + codeSyncTime),确保连接完成且 mac 就绪后才进入下一步 - 重构 configureDevice_2:移除 userInfo 缓存读取,改为接口获取用户列表,支持动态渲染、删除用户 - 新增 configureDevice_2_addUser 组件:支持工号查询用户信息并添加到设备 - 优化用户下发逻辑:先通过 dataFetchUserID 获取设备端已有用户,仅下发新增用户 - 删除废弃页面 deviceInfo、userInfo Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
1e3f1934b1
commit
e20638030b
+3
-30
@@ -3,22 +3,14 @@ import $ from "../../utils/request";
|
||||
Page({
|
||||
data: {
|
||||
token: null,
|
||||
userInfo: null,
|
||||
|
||||
deviceList: []
|
||||
},
|
||||
|
||||
onShow() {
|
||||
let userInfo = wx.getStorageSync("userInfo") || null;
|
||||
let token = wx.getStorageSync("token") || null;
|
||||
this.setData({
|
||||
token: token,
|
||||
userInfo: userInfo,
|
||||
deviceList: []
|
||||
// deviceList: []
|
||||
})
|
||||
if(token) {
|
||||
this.getDevice();
|
||||
}
|
||||
},
|
||||
|
||||
// 点击登录或注册
|
||||
@@ -43,12 +35,10 @@ Page({
|
||||
let params = {
|
||||
code: code
|
||||
};
|
||||
$.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "加载中...").then((res) => {
|
||||
wx.setStorageSync("userInfo", res.result.user);
|
||||
$.ajax("weighingScale/v2/checkOpenIdLogin", params, "POST", true, "加载中...").then((res) => {
|
||||
wx.setStorageSync("token", res.result.token);
|
||||
this.setData({
|
||||
token: res.result.token,
|
||||
userInfo: res.result.user
|
||||
token: res.result.token
|
||||
})
|
||||
|
||||
if(bol) {
|
||||
@@ -57,27 +47,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 获取已经绑定的设备列表
|
||||
getDevice() {
|
||||
let params = {};
|
||||
$.ajax("weighingScale/list/device", params, "GET", true, "获取设备列表").then((res) => {
|
||||
this.setData({
|
||||
deviceList: res.result
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 添加设备
|
||||
openSearchDevice() {
|
||||
wx.navigateTo({
|
||||
url: "/pages/searchDevice/searchDevice"
|
||||
})
|
||||
},
|
||||
|
||||
// 打开设备详情
|
||||
openDeviceInfo() {
|
||||
wx.navigateTo({
|
||||
url: "/pages/deviceInfo/deviceInfo"
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user