|
|
@@ -182,9 +182,6 @@
|
|
|
if (!(value == true)) {
|
|
|
this.flag = true
|
|
|
}
|
|
|
-
|
|
|
- // 获取蓝牙设备,并列表
|
|
|
- this.openBluetoothAdapter();
|
|
|
},
|
|
|
onShow() {
|
|
|
// 充值后更新金额
|
|
|
@@ -200,27 +197,41 @@
|
|
|
* 单击连接热水表
|
|
|
*/
|
|
|
clickRoom(e) {
|
|
|
- if (this.judgeBalance('clickRoom') == false) {
|
|
|
+ if (this.judgeBalance('clickRoom') === false) {
|
|
|
return
|
|
|
- }
|
|
|
-
|
|
|
- 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
|
|
|
- break
|
|
|
+ } else {
|
|
|
+ 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
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
+ // 开始连接匹配的蓝牙设备
|
|
|
+ this.createBLEConnection();
|
|
|
}
|
|
|
-
|
|
|
- // 开始连接匹配的蓝牙设备
|
|
|
- this.openBluetoothAdapter();
|
|
|
},
|
|
|
/**
|
|
|
* 空中连接热水表
|
|
|
*/
|
|
|
open() {
|
|
|
- this.showRoom = !this.showRoom
|
|
|
+ if (this.judgeBalance('clickRoom') === false) {
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ this.setInit()
|
|
|
+
|
|
|
+ uni.showLoading({
|
|
|
+ title: '水表搜索中…',
|
|
|
+ mask: true,
|
|
|
+ success: (res) => {
|
|
|
+ // 获取蓝牙设备,并列表
|
|
|
+ this.openBluetoothAdapter();
|
|
|
+
|
|
|
+ this.showRoom = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 跳转到广告ad页
|
|
|
@@ -588,6 +599,7 @@
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+ // console.log(this.deviceId);
|
|
|
// 设备已连接
|
|
|
if (this.deviceId) {
|
|
|
uni.showModal({
|
|
|
@@ -595,15 +607,13 @@
|
|
|
content: '设备已经连接,需要重新连接吗?',
|
|
|
success: res => {
|
|
|
if (res.confirm) {
|
|
|
+ // 关闭连接
|
|
|
this.closeBLEConnection()
|
|
|
if (param == 'scan') {
|
|
|
+ // 扫描
|
|
|
this.scan_qr()
|
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '请选择宿舍号重新连接',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
+ // cancel
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -626,10 +636,10 @@
|
|
|
* 启动摄像头,扫描二维码
|
|
|
*/
|
|
|
scan_qr() {
|
|
|
+ this.get_Bluetooth_Bevice = true
|
|
|
uni.scanCode({
|
|
|
onlyFromCamera: true,
|
|
|
success: (res) => {
|
|
|
-
|
|
|
this.isScan = true
|
|
|
// console.log(res)
|
|
|
// charSet: "utf-8"
|
|
|
@@ -724,8 +734,9 @@
|
|
|
confirmText: '我已开启',
|
|
|
cancelText: '取消',
|
|
|
success: (res) => {
|
|
|
+ // console.log(res);
|
|
|
if (res.confirm) {
|
|
|
- // console.log(res)
|
|
|
+
|
|
|
} else if (res.cancel) {
|
|
|
switch (uni.getSystemInfoSync().platform) {
|
|
|
case 'android':
|
|
|
@@ -742,7 +753,7 @@
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- }, 5000)
|
|
|
+ }, 6000)
|
|
|
},
|
|
|
fail: err => {
|
|
|
// console.log(err, '错误信息');
|
|
|
@@ -768,8 +779,10 @@
|
|
|
if (this.get_Bluetooth_Bevice == true) {
|
|
|
this.createBLEConnection()
|
|
|
} else {
|
|
|
- this.get_Bluetooth_Bevice = true
|
|
|
this.get_room()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.get_Bluetooth_Bevice = true
|
|
|
+ }, 2000)
|
|
|
}
|
|
|
},
|
|
|
fail: err => {
|
|
|
@@ -795,7 +808,6 @@
|
|
|
if (!device.name && !device.localName) {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
// 把搜索到的设备存储起来,如有需要可以在页面上展示
|
|
|
dname = device.name.substr(1)
|
|
|
let d = {
|
|
|
@@ -834,7 +846,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',
|
|
|
@@ -847,8 +859,11 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.hideLoading();
|
|
|
+ }, 300);
|
|
|
+
|
|
|
if (res.data.msg == '获取成功') {
|
|
|
- this.rooms = []
|
|
|
// 消费记录
|
|
|
let items = res.data.data
|
|
|
if (items == 'undefined') {
|
|
|
@@ -900,14 +915,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: '未知错误,请重新进入。',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 3000,
|
|
|
+ success: (res1) => {
|
|
|
+ this.setInit()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -997,13 +1012,13 @@
|
|
|
characteristicId: this.characteristicIdForNotity,
|
|
|
success: (res) => {
|
|
|
this.process_control(2)
|
|
|
-
|
|
|
+
|
|
|
uni.showToast({
|
|
|
- icon:'none',
|
|
|
- title:'需要启动请点【开启设备】开关',
|
|
|
+ icon: 'none',
|
|
|
+ title: '需要启动请点【开启设备】开关',
|
|
|
duration: 3000
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.isScan = false
|
|
|
// console.log('通知启用(notifyBLECharacteristicValueChange)',res);
|
|
|
this.onBLECharacteristicValueChange()
|
|
|
@@ -1173,9 +1188,9 @@
|
|
|
this.isConnected = false
|
|
|
this.isScan = false
|
|
|
this.active = -1
|
|
|
- this.devices = [] // 保存设备
|
|
|
this.device_code = '' // 设备编号
|
|
|
- this.deviceId = ''
|
|
|
+ this.devices = [] // 保存设备, 加了【空中连接】,不需要置为空。
|
|
|
+ this.deviceId = '' // 加了【空中连接】,不需要置为空。
|
|
|
this.serviceId = ''
|
|
|
this.characteristicIdForWrite = ''
|
|
|
this.characteristicIdForNotity = ''
|
|
|
@@ -1183,6 +1198,9 @@
|
|
|
this.deviceIsWrite = false
|
|
|
this.byte35 = '' // 70 个字符
|
|
|
this.byte35_tmp = '' // 70 个字符 临时变量
|
|
|
+
|
|
|
+ this.get_Bluetooth_Bevice = false
|
|
|
+ this.rooms = [] // 宿舍号,蓝牙连接具有时效性,断开连接后清空
|
|
|
// this.start_code = ''
|
|
|
})
|
|
|
},
|
|
|
@@ -1259,7 +1277,7 @@
|
|
|
}
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
- // console.log(err)
|
|
|
+ console.log(err)
|
|
|
if (err.errCode == 10006) {
|
|
|
setTimeout(() => {
|
|
|
this.setInit()
|