|
@@ -678,6 +678,7 @@ Page({
|
|
if (item.connectType != "1") {
|
|
if (item.connectType != "1") {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
///去蓝牙连接处理
|
|
///去蓝牙连接处理
|
|
if (e.currentTarget.dataset.index === that.data.deviceListIndex) {
|
|
if (e.currentTarget.dataset.index === that.data.deviceListIndex) {
|
|
// 蓝牙才能连接
|
|
// 蓝牙才能连接
|
|
@@ -752,24 +753,41 @@ Page({
|
|
title: '确定删除?',
|
|
title: '确定删除?',
|
|
success: function (res) {
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
- if (that.data.deviceList[index].connectType != 3) {
|
|
|
|
- that.cancelBlue(index);
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (that.data.deviceList[index].connectType == 3) {
|
|
that.cancelWifi(index);
|
|
that.cancelWifi(index);
|
|
|
|
+ } else {
|
|
|
|
+ that.cancelBlue(index);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ ///断开当前的
|
|
|
|
+ async cancelCurrent() {
|
|
|
|
+ var that = this;
|
|
|
|
+ var deviceListIndex = that.data.deviceListIndex;
|
|
|
|
+ if (deviceListIndex == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var deviceList = that.data.deviceList;
|
|
|
|
+ if (deviceList.length > deviceListIndex) {
|
|
|
|
+ if (deviceList[deviceListIndex].connectType == 3) {
|
|
|
|
+ await that.cancelWifi(deviceListIndex);
|
|
|
|
+ } else {
|
|
|
|
+ await that.cancelBlue(deviceListIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
/// 断开蓝牙连接
|
|
/// 断开蓝牙连接
|
|
- cancelBlue(index) {
|
|
|
|
|
|
+ async cancelBlue(index) {
|
|
const id = that.data.deviceList[index].deviceId;
|
|
const id = that.data.deviceList[index].deviceId;
|
|
const deviceList = that.data.deviceList.filter((item, i) => {
|
|
const deviceList = that.data.deviceList.filter((item, i) => {
|
|
return id !== item.deviceId
|
|
return id !== item.deviceId
|
|
});
|
|
});
|
|
|
|
|
|
- BtHelper.getInstance().disconnect();
|
|
|
|
|
|
+ await BtHelper.getInstance().disconnect();
|
|
wx.setStorageSync("deviceList", JSON.stringify(deviceList));
|
|
wx.setStorageSync("deviceList", JSON.stringify(deviceList));
|
|
that.setData({
|
|
that.setData({
|
|
deviceList,
|
|
deviceList,
|
|
@@ -784,7 +802,7 @@ Page({
|
|
},
|
|
},
|
|
|
|
|
|
/// 断开连接wifi
|
|
/// 断开连接wifi
|
|
- cancelWifi(index) {
|
|
|
|
|
|
+ async cancelWifi(index) {
|
|
const id = that.data.deviceList[index].deviceId;
|
|
const id = that.data.deviceList[index].deviceId;
|
|
let name = that.data.deviceListIndex !== null ? that.data.deviceList[that.data.deviceListIndex].name : null;
|
|
let name = that.data.deviceListIndex !== null ? that.data.deviceList[that.data.deviceListIndex].name : null;
|
|
|
|
|