|
|
@@ -184,7 +184,7 @@
|
|
|
}
|
|
|
|
|
|
// 获取蓝牙设备,并列表
|
|
|
- this.openBluetoothAdapter("get_room");
|
|
|
+ this.openBluetoothAdapter();
|
|
|
},
|
|
|
onShow() {
|
|
|
// 充值后更新金额
|
|
|
@@ -203,12 +203,12 @@
|
|
|
if (this.judgeBalance('clickRoom') == false) {
|
|
|
return
|
|
|
}
|
|
|
- // console.log(e);
|
|
|
+
|
|
|
this.device_code = 'K' + e
|
|
|
+
|
|
|
for (var i = 0, len = this.devices.length; i < len; i++) {
|
|
|
if (this.devices[i].dname == e) {
|
|
|
this.deviceId = this.devices[i].did
|
|
|
- // console.log(this.deviceId)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
@@ -660,7 +660,7 @@
|
|
|
* 22222222222222222222222222222
|
|
|
* 初始化蓝牙
|
|
|
*/
|
|
|
- openBluetoothAdapter(param) {
|
|
|
+ openBluetoothAdapter() {
|
|
|
uni.openBluetoothAdapter({
|
|
|
success: (res) => { // 已打开
|
|
|
uni.getBluetoothAdapterState({ // 蓝牙的匹配状态
|
|
|
@@ -669,7 +669,7 @@
|
|
|
// 本机设备的蓝牙已打开
|
|
|
// 开始搜索蓝牙设备
|
|
|
if (this.deviceId == '' && this.serviceId == '')
|
|
|
- this.startBluetoothDeviceDiscovery(param)
|
|
|
+ this.startBluetoothDeviceDiscovery()
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
// console.log(error)
|
|
|
@@ -706,7 +706,7 @@
|
|
|
* 333333333333333333333333333
|
|
|
* 开始搜索蓝牙设备
|
|
|
*/
|
|
|
- startBluetoothDeviceDiscovery(param) {
|
|
|
+ startBluetoothDeviceDiscovery() {
|
|
|
uni.startBluetoothDevicesDiscovery({ // 开始搜寻附近的蓝牙外围设备
|
|
|
// services: ['FEE7'], // 要搜索但蓝牙设备主 service 的 uuid 列表
|
|
|
allowDuplicatesKey: true,
|
|
|
@@ -714,7 +714,7 @@
|
|
|
if (this.get_Bluetooth_Bevice == true)
|
|
|
this.process_control(0)
|
|
|
|
|
|
- this.onBluetoothDeviceFound(param) // 监听搜索到新设备 同时进行
|
|
|
+ this.onBluetoothDeviceFound() // 监听搜索到新设备 同时进行
|
|
|
|
|
|
setTimeout(() => {
|
|
|
if (this.isScan) {
|
|
|
@@ -757,7 +757,7 @@
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- stopBluetoothDevicesDiscovery(param) { //停止搜索
|
|
|
+ stopBluetoothDevicesDiscovery() { //停止搜索
|
|
|
uni.stopBluetoothDevicesDiscovery({
|
|
|
success: (res) => {
|
|
|
// console.log(res, '停止蓝牙搜索')
|
|
|
@@ -766,10 +766,7 @@
|
|
|
// duration: 2000
|
|
|
// })
|
|
|
if (this.get_Bluetooth_Bevice == true) {
|
|
|
- if (param != 'get_room') {
|
|
|
- // 开始连接匹配的蓝牙设备
|
|
|
- this.createBLEConnection()
|
|
|
- }
|
|
|
+ this.createBLEConnection()
|
|
|
} else {
|
|
|
this.get_Bluetooth_Bevice = true
|
|
|
this.get_room()
|
|
|
@@ -790,10 +787,9 @@
|
|
|
* 444444444444444444444444444444444
|
|
|
* 发现外围设备
|
|
|
*/
|
|
|
- onBluetoothDeviceFound(param) {
|
|
|
+ onBluetoothDeviceFound() {
|
|
|
uni.onBluetoothDeviceFound((res) => {
|
|
|
let dname = ''
|
|
|
- let i = 0
|
|
|
res.devices.forEach(device => { // 筛选找到的蓝牙中对名称匹配
|
|
|
// 过滤掉没有名字的设备
|
|
|
if (!device.name && !device.localName) {
|
|
|
@@ -809,7 +805,6 @@
|
|
|
if (dname.length == 10 && JSON.stringify(this.devices).indexOf(JSON.stringify(
|
|
|
d)) === -1) {
|
|
|
this.devices.push(d)
|
|
|
- i++
|
|
|
}
|
|
|
|
|
|
if (device.name == this.device_code) {
|
|
|
@@ -820,13 +815,13 @@
|
|
|
this.deviceId = device.deviceId
|
|
|
|
|
|
// 放此位置,苹果手机兼容
|
|
|
- this.stopBluetoothDevicesDiscovery(param)
|
|
|
+ this.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- this.stopBluetoothDevicesDiscovery(param)
|
|
|
+ this.stopBluetoothDevicesDiscovery()
|
|
|
}, 2000)
|
|
|
})
|
|
|
});
|
|
|
@@ -839,7 +834,7 @@
|
|
|
for (var i = 0, len = this.devices.length; i < len; i++) {
|
|
|
devices_str.push(this.devices[i].dname)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
|
url: '/HotWaters/waterqueryDom.action',
|
|
|
@@ -852,7 +847,6 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // console.log(res);
|
|
|
if (res.data.msg == '获取成功') {
|
|
|
this.rooms = []
|
|
|
// 消费记录
|
|
|
@@ -906,14 +900,14 @@
|
|
|
if (err.errMsg.indexOf('already connect') != -1) {
|
|
|
this.connect_BLE()
|
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
- title: '未知错误,请重连1次。',
|
|
|
- icon: 'none',
|
|
|
- duration: 3000,
|
|
|
- success: (res1) => {
|
|
|
- this.setInit()
|
|
|
- }
|
|
|
- })
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '未知错误,请重连1次。',
|
|
|
+ // icon: 'none',
|
|
|
+ // duration: 3000,
|
|
|
+ // success: (res1) => {
|
|
|
+ // this.setInit()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
}
|
|
|
}
|
|
|
})
|