|
@@ -149,8 +149,9 @@ Page({
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
// 开启蓝牙
|
|
// 开启蓝牙
|
|
|
- bindViewBlue: function () {
|
|
|
|
|
|
|
+ bindViewBlue: function () {
|
|
|
const that = this;
|
|
const that = this;
|
|
|
|
|
+ wx.offBluetoothDeviceFound();
|
|
|
wx.closeBluetoothAdapter();
|
|
wx.closeBluetoothAdapter();
|
|
|
wx.openBluetoothAdapter({
|
|
wx.openBluetoothAdapter({
|
|
|
success(res) {
|
|
success(res) {
|
|
@@ -214,39 +215,40 @@ Page({
|
|
|
if (flag) {
|
|
if (flag) {
|
|
|
var arrD = item['name'].split(' ');
|
|
var arrD = item['name'].split(' ');
|
|
|
item['sn'] = arrD[1];
|
|
item['sn'] = arrD[1];
|
|
|
- wx.request({
|
|
|
|
|
- url: 'https://aipush.aidsleep.cn/checkbeds',
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- header: {
|
|
|
|
|
- 'content-type': 'application/json' // 设置请求的 header
|
|
|
|
|
- },
|
|
|
|
|
- data: {
|
|
|
|
|
- "snlists": arrD[1], // 需要发送的数据
|
|
|
|
|
- "token": "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3"
|
|
|
|
|
- },
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- //console.log(res);
|
|
|
|
|
- if (res.data.data[arrD[1]].trim() == 'yes') {
|
|
|
|
|
- item['beOnline'] = 'icon-deng-ok';
|
|
|
|
|
- } else {
|
|
|
|
|
- item['beOnline'] = '';
|
|
|
|
|
- // if (doDevices.indexOf(item['deviceId']) >= 0) {
|
|
|
|
|
- // item['beOnline'] = 'icon-deng-ok';
|
|
|
|
|
- // }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // wx.request({
|
|
|
|
|
+ // url: 'https://aipush.aidsleep.cn/checkbeds',
|
|
|
|
|
+ // method: 'POST',
|
|
|
|
|
+ // header: {
|
|
|
|
|
+ // 'content-type': 'application/json' // 设置请求的 header
|
|
|
|
|
+ // },
|
|
|
|
|
+ // data: {
|
|
|
|
|
+ // "snlists": arrD[1], // 需要发送的数据
|
|
|
|
|
+ // "token": "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3"
|
|
|
|
|
+ // },
|
|
|
|
|
+ // success: function (res) {
|
|
|
|
|
+ // //console.log(res);
|
|
|
|
|
+ // if (res.data.data[arrD[1]].trim() == 'yes') {
|
|
|
|
|
+ // item['beOnline'] = 'icon-deng-ok';
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // item['beOnline'] = '';
|
|
|
|
|
+ // // if (doDevices.indexOf(item['deviceId']) >= 0) {
|
|
|
|
|
+ // // item['beOnline'] = 'icon-deng-ok';
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // }
|
|
|
deviceList.push(item);
|
|
deviceList.push(item);
|
|
|
- self.setData({
|
|
|
|
|
- deviceList: deviceList,
|
|
|
|
|
- showBluetoothList: true
|
|
|
|
|
- });
|
|
|
|
|
- wx.setStorageSync('deviceList', deviceList);
|
|
|
|
|
- },
|
|
|
|
|
- fail: function (error) {
|
|
|
|
|
- console.error(error);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // },
|
|
|
|
|
+ // fail: function (error) {
|
|
|
|
|
+ // console.error(error);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ self.setData({
|
|
|
|
|
+ deviceList: deviceList,
|
|
|
|
|
+ showBluetoothList: true
|
|
|
|
|
+ });
|
|
|
|
|
+ wx.setStorageSync('deviceList', deviceList);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -270,6 +272,11 @@ Page({
|
|
|
},
|
|
},
|
|
|
commitBluetooth() {
|
|
commitBluetooth() {
|
|
|
this.onClose();
|
|
this.onClose();
|
|
|
|
|
+ if (this.data.bluetoothSelectIndex < 0) {
|
|
|
|
|
+ util.showToast("请选择一个床垫");
|
|
|
|
|
+ wx.offBluetoothDeviceFound()
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
var deviceId = this.data.deviceList[this.data.bluetoothSelectIndex].deviceId;
|
|
var deviceId = this.data.deviceList[this.data.bluetoothSelectIndex].deviceId;
|
|
|
var name = this.data.deviceList[this.data.bluetoothSelectIndex].name;
|
|
var name = this.data.deviceList[this.data.bluetoothSelectIndex].name;
|
|
|
var nameList = this.data.deviceList[this.data.bluetoothSelectIndex].name.split(' ');
|
|
var nameList = this.data.deviceList[this.data.bluetoothSelectIndex].name.split(' ');
|
|
@@ -277,7 +284,7 @@ Page({
|
|
|
deviceId: deviceId,
|
|
deviceId: deviceId,
|
|
|
sn: nameList[1]
|
|
sn: nameList[1]
|
|
|
})
|
|
})
|
|
|
- wx.offBluetoothDeviceFound()
|
|
|
|
|
|
|
+ wx.offBluetoothDeviceFound()
|
|
|
},
|
|
},
|
|
|
// 开始配网
|
|
// 开始配网
|
|
|
bindViewConnect() {
|
|
bindViewConnect() {
|
|
@@ -389,6 +396,7 @@ Page({
|
|
|
showBluetoothConnected: true
|
|
showBluetoothConnected: true
|
|
|
});
|
|
});
|
|
|
self.setProcess(0, util.descSucList[0], 1);
|
|
self.setProcess(0, util.descSucList[0], 1);
|
|
|
|
|
+ wx.offBluetoothAdapterStateChange();
|
|
|
//第一步检查蓝牙适配器是否可用
|
|
//第一步检查蓝牙适配器是否可用
|
|
|
wx.onBluetoothAdapterStateChange(function (res) {
|
|
wx.onBluetoothAdapterStateChange(function (res) {
|
|
|
if (!res.available) {
|
|
if (!res.available) {
|