Ver código fonte

【修复】空中连接修复,楼栋号显示修复。

程志平 4 anos atrás
pai
commit
122fc1dfc6
2 arquivos alterados com 22 adições e 28 exclusões
  1. 21 27
      pages/reshui/reshui.vue
  2. 1 1
      pages/select/select.vue

+ 21 - 27
pages/reshui/reshui.vue

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

+ 1 - 1
pages/select/select.vue

@@ -166,7 +166,7 @@
 					if (arr[2] != null && len > 0) {
 					if (arr[2] != null && len > 0) {
 						let a = arr[2].split('-')
 						let a = arr[2].split('-')
 						this.arr2 = [a[0] + '栋']
 						this.arr2 = [a[0] + '栋']
-						this.arr3 = [a[1].substring(0, len - 2) + '层']
+						this.arr3 = [a[1].substring(0, a[1].length - 2) + '层']
 						this.arr4 = [arr[2]]
 						this.arr4 = [arr[2]]
 					}
 					}