|
|
@@ -9,7 +9,8 @@
|
|
|
</view>
|
|
|
<view class="qinshihao">
|
|
|
<!-- <text class="iconfont icon-zhuye"></text> -->
|
|
|
- <image :src="require('./images/icon-zhuye.png')" style="width: 28rpx; margin-right: 8rpx;" mode="aspectFit"></image>
|
|
|
+ <image :src="require('./images/icon-zhuye.png')" style="width: 28rpx; margin-right: 8rpx;"
|
|
|
+ mode="aspectFit"></image>
|
|
|
<text class="dormtxt">{{dorm_number || '宿舍未知'}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -66,8 +67,8 @@
|
|
|
<view class="uni-input">
|
|
|
<text>{{date}}</text>
|
|
|
<!-- <text class="iconfont icon-arrow-down"></text> -->
|
|
|
- <image :src="require('./images/icon-arrow-down.png')"
|
|
|
- style="width: 26rpx;" mode="aspectFit">
|
|
|
+ <image :src="require('./images/icon-arrow-down.png')" style="width: 26rpx;"
|
|
|
+ mode="aspectFit">
|
|
|
</image>
|
|
|
</view>
|
|
|
</picker>
|
|
|
@@ -243,7 +244,7 @@
|
|
|
});
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- _this.setInit();
|
|
|
+ _this.myInit();
|
|
|
}, 100);
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
@@ -1029,7 +1030,7 @@
|
|
|
this.connect_BLE()
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: '错误:' + err.errMsg,
|
|
|
+ title: '水表蓝牙连接被占用!',
|
|
|
icon: 'none',
|
|
|
duration: 3000,
|
|
|
success: (res1) => {
|
|
|
@@ -1075,8 +1076,11 @@
|
|
|
title: '获取服务失败',
|
|
|
icon: 'none',
|
|
|
duration: 3000
|
|
|
- })
|
|
|
- return
|
|
|
+ });
|
|
|
+
|
|
|
+ this.setInit();
|
|
|
+
|
|
|
+ return;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -1246,31 +1250,36 @@
|
|
|
* 关闭连接
|
|
|
*/
|
|
|
closeBLEConnection() {
|
|
|
- uni.closeBLEConnection({
|
|
|
- deviceId: this.deviceId,
|
|
|
- success: () => {
|
|
|
- // 关闭蓝牙模块
|
|
|
- this.closeBluetoothAdapter()
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- this.setInit()
|
|
|
- // uni.showToast({
|
|
|
- // icon: 'none',
|
|
|
- // title: '蓝牙连接断开失败',
|
|
|
- // duration: 3000,
|
|
|
- // success: (res1) => {
|
|
|
- // this.setInit()
|
|
|
- // }
|
|
|
- // })
|
|
|
- }
|
|
|
- })
|
|
|
+ if (this.deviceId) {
|
|
|
+ uni.closeBLEConnection({
|
|
|
+ deviceId: this.deviceId,
|
|
|
+ success: () => {
|
|
|
+ // 关闭蓝牙模块
|
|
|
+ this.closeBluetoothAdapter()
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ // this.setInit()
|
|
|
+ // uni.showToast({
|
|
|
+ // icon: 'none',
|
|
|
+ // title: err.errMsg,
|
|
|
+ // duration: 3000,
|
|
|
+ // success: (res1) => {
|
|
|
+ // this.setInit()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 关闭蓝牙模块
|
|
|
+ this.closeBluetoothAdapter()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
closeBluetoothAdapter() {
|
|
|
// 关闭蓝牙模块
|
|
|
uni.closeBluetoothAdapter({
|
|
|
success: () => {
|
|
|
- this.setInit()
|
|
|
+ this.myInit();
|
|
|
|
|
|
if (this.isUserClose == false) { // 设备端结束用水
|
|
|
if (this.isChecked) {
|
|
|
@@ -1279,14 +1288,14 @@
|
|
|
icon: 'none',
|
|
|
title: '设备端已结束用水,蓝牙断开成功',
|
|
|
duration: 3000
|
|
|
- })
|
|
|
+ });
|
|
|
} else {
|
|
|
// console.log('用户重启扫描,蓝牙断开成功')
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: '用户重启扫描,蓝牙断开成功',
|
|
|
duration: 3000
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
} else { // 手机移动端结束用水
|
|
|
// console.log('APP端已结束用水,蓝牙断开成功')
|
|
|
@@ -1294,34 +1303,40 @@
|
|
|
icon: 'none',
|
|
|
title: 'APP端已结束用水,蓝牙断开成功',
|
|
|
duration: 3000
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setInit() {
|
|
|
+ this.closeBLEConnection();
|
|
|
+
|
|
|
+ this.myInit();
|
|
|
+ },
|
|
|
+
|
|
|
+ myInit() {
|
|
|
setTimeout(() => {
|
|
|
- this.isUserClose = false
|
|
|
- this.isChecked = false
|
|
|
- this.isConnected = false
|
|
|
- this.isScan = false
|
|
|
- this.active = -1
|
|
|
- this.device_code = '' // 设备编号
|
|
|
- this.devices = [] // 保存设备, 加了【空中连接】,不需要置为空。
|
|
|
- this.deviceId = '' // 加了【空中连接】,不需要置为空。
|
|
|
- this.serviceId = ''
|
|
|
- this.characteristicIdForWrite = ''
|
|
|
- this.characteristicIdForNotity = ''
|
|
|
- this.deviceIsNotify = false
|
|
|
- this.deviceIsWrite = false
|
|
|
- this.byte35 = '' // 70 个字符
|
|
|
- this.byte35_tmp = '' // 70 个字符 临时变量
|
|
|
-
|
|
|
- this.get_Bluetooth_Bevice = false
|
|
|
- this.rooms = [] // 宿舍号,蓝牙连接具有时效性,断开连接后清空
|
|
|
- this.start_code = ''
|
|
|
- }, 200)
|
|
|
+ this.isUserClose = false;
|
|
|
+ this.isChecked = false;
|
|
|
+ this.isConnected = false;
|
|
|
+ this.isScan = false;
|
|
|
+ this.active = -1;
|
|
|
+ this.device_code = ''; // 设备编号
|
|
|
+ this.devices = []; // 保存设备, 加了【空中连接】,不需要置为空。
|
|
|
+ this.deviceId = ''; // 加了【空中连接】,不需要置为空。
|
|
|
+ this.serviceId = '';
|
|
|
+ this.characteristicIdForWrite = '';
|
|
|
+ this.characteristicIdForNotity = '';
|
|
|
+ this.deviceIsNotify = false;
|
|
|
+ this.deviceIsWrite = false;
|
|
|
+ this.byte35 = ''; // 70 个字符
|
|
|
+ this.byte35_tmp = ''; // 70 个字符 临时变量
|
|
|
+
|
|
|
+ this.get_Bluetooth_Bevice = false;
|
|
|
+ this.rooms = []; // 宿舍号,蓝牙连接具有时效性,断开连接后清空
|
|
|
+ this.start_code = '';
|
|
|
+ }, 300);
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -1457,7 +1472,7 @@
|
|
|
if (typeof this.byte35 == 'undefined' || this.byte35 == '') {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '字节码为空!'
|
|
|
+ title: '获取字节码空!'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -1512,7 +1527,7 @@
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
icon: 'success',
|
|
|
- title: '字节码为空!'
|
|
|
+ title: '结算字节码空!'
|
|
|
});
|
|
|
// 初始化
|
|
|
this.setInit()
|