This commit is contained in:
17792275749
2025-04-01 09:54:08 +08:00
parent 802cb8ae80
commit f6301affba
2 changed files with 37 additions and 29 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ Page({
})
setTimeout(() => {
wx.navigateBack({
delta: 1
delta: 2
})
}, 1500);
});
+36 -28
View File
@@ -164,37 +164,45 @@ Page({
this.setData({
devicesList: res
});
this.selectDevice();
});
},
selectDevice() {
setTimeout(() => {
this.setData({
getDeviceSetting: false,
initText: "设备搜索完成"
});
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
app.globalData.ppScale.device.list = this.data.devicesList;
if(this.data.devicesList.length === 1) {
app.globalData.ppScale.device.connection = this.data.devicesList[0];
wx.navigateTo({
url: "/pages/connectedDevice/connectedDevice"
})
if(this.data.devicesList && this.data.devicesList.length) {
this.setData({
getDeviceSetting: false,
initText: "设备搜索完成"
});
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
app.globalData.ppScale.device.list = this.data.devicesList;
if(this.data.devicesList.length === 1) {
app.globalData.ppScale.device.connection = this.data.devicesList[0];
wx.navigateTo({
url: "/pages/connectedDevice/connectedDevice"
})
} else {
let itemLists = this.data.devicesList.map(item => item.name);
wx.showActionSheet({
itemList: itemLists,
alertText: "请选择你要使用的设备",
success: (res) => {
app.globalData.ppScale.device.connection = this.data.devicesList[res.tapIndex];
wx.navigateTo({
url: "/pages/connectedDevice/connectedDevice"
})
},
fail: () => {
wx.navigateBack({
delta: 1
})
}
})
}
} else {
let itemLists = this.data.devicesList.map(item => item.name);
wx.showActionSheet({
itemList: itemLists,
alertText: "请选择你要使用的设备",
success: (res) => {
app.globalData.ppScale.device.connection = this.data.devicesList[res.tapIndex];
wx.navigateTo({
url: "/pages/connectedDevice/connectedDevice"
})
},
fail: () => {
wx.navigateBack({
delta: 1
})
}
})
this.selectDevice();
}
}, 3000)
}, 3000);
}
})