aaa
This commit is contained in:
		
							parent
							
								
									23197daaca
								
							
						
					
					
						commit
						ceb9558de4
					
				|  | @ -63,8 +63,10 @@ BLEDevice.prototype.getBluetoothAdapterState = function () { | |||
|       if (res.discovering) { | ||||
|         this.onBluetoothDeviceFound() | ||||
|       } else if (res.available) { | ||||
|         this.startBluetoothDevicesDiscovery(state.servicesId, state.key); | ||||
|       } | ||||
| 		setTimeout(()=>{ | ||||
| 			this.startBluetoothDevicesDiscovery(state.servicesId, state.key); | ||||
| 		},500) | ||||
|       }  | ||||
|     } | ||||
|   }) | ||||
| }; | ||||
|  |  | |||
|  | @ -971,6 +971,7 @@ function writeCutomsData(deviceId, serviceId, characteristicId, data) { | |||
| 				console.log("送数据成功") | ||||
| 			}, | ||||
| 			fail: function (res) { //console.log(257);
 | ||||
| 			console.log("送数据成功",res) | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
|  | @ -1108,12 +1109,12 @@ function init() { | |||
| 			uni.closeBluetoothAdapter({ | ||||
| 				complete: function (res)  | ||||
| 				{ | ||||
| 					console.log("这里蓝牙数据") | ||||
| 					// console.log("这里蓝牙数据")
 | ||||
| 					uni.openBluetoothAdapter({ | ||||
| 						success: function (res) { | ||||
| 							uni.getBluetoothAdapterState({ | ||||
| 								success: function (res) { | ||||
| 									console.log("这里蓝牙数据222") | ||||
| 									// console.log("这里蓝牙数据222")
 | ||||
| 									{ | ||||
| 										let devicesList = []; | ||||
| 										let countsTimes = 0; | ||||
|  | @ -1140,13 +1141,20 @@ function init() { | |||
| 												} | ||||
| 											} else if (devices.devices) { | ||||
| 												// console.log(devices.devices[0])
 | ||||
| 												if (devices.devices[0].name != '开发板' | ||||
| 													&& devices.devices[0].name != 'SMART_R2XS' | ||||
| 												) { | ||||
| 													// console.log("跳过")
 | ||||
| 												// if (devices.devices[0].name != '开发板'
 | ||||
| 												// 	&& devices.devices[0].name != 'SMART_R2XS'
 | ||||
| 												// 	&& devices.devices[0].name != 'SMART_R2XS'
 | ||||
| 												// ) 
 | ||||
| 												if (devices.devices[0].name.indexOf("CTKG") != -1){ | ||||
| 													// console.log("跳过",devices.devices[0].name)
 | ||||
| 													// isnotexist = false;
 | ||||
| 													isnotexist = true; | ||||
| 												} | ||||
| 												else | ||||
| 												{ | ||||
| 													isnotexist = false; | ||||
| 												} | ||||
| 												isnotexist = true; | ||||
| 												// isnotexist = true;
 | ||||
| 													 | ||||
| 												if (devices.devices[0].advertisData) { | ||||
| 													devices.devices[0].advertisData = buf2hex(devices.devices[0].advertisData); | ||||
|  | @ -1188,9 +1196,11 @@ function init() { | |||
| 											}; | ||||
| 											mDeviceEvent.notifyDeviceMsgEvent(obj); | ||||
| 										}); | ||||
| 										 | ||||
| 										uni.startBluetoothDevicesDiscovery({ | ||||
| 											allowDuplicatesKey: true, | ||||
| 											success: function (res) { | ||||
| 												console.log(res,'true'); | ||||
| 												let obj = { | ||||
| 													'type': mDeviceEvent.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START, | ||||
| 													'result': true, | ||||
|  | @ -1199,8 +1209,9 @@ function init() { | |||
| 												mDeviceEvent.notifyDeviceMsgEvent(obj); //开始扫码,清空列表
 | ||||
| 									 | ||||
| 												devicesList.length = 0; | ||||
| 											}, | ||||
| 											},  | ||||
| 											fail: function (res) { | ||||
| 												console.log(res,'false'); | ||||
| 												let obj = { | ||||
| 													'type': mDeviceEvent.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START, | ||||
| 													'result': false, | ||||
|  | @ -1209,6 +1220,7 @@ function init() { | |||
| 												mDeviceEvent.notifyDeviceMsgEvent(obj); | ||||
| 											} | ||||
| 										}); | ||||
| 										 | ||||
| 									} | ||||
| 									// uni.stopBluetoothDevicesDiscovery({
 | ||||
| 									// 	success: function (res)
 | ||||
|  | @ -1266,10 +1278,12 @@ function init() { | |||
| 		} | ||||
| 	}); | ||||
| 	mDeviceEvent.listenConnectBle(true, function (options) { | ||||
| 		console.log("我要连接?", options.isStart); | ||||
| 		if (options.isStart) uni.createBLEConnection({ | ||||
| 			deviceId: options.deviceId, | ||||
| 			success: function (res) { | ||||
| 		console.log("我要连接?", options.isStart,options); | ||||
| 		if (options.isStart){ | ||||
| 			uni.createBLEConnection({  | ||||
| 			deviceId: options.deviceId,  | ||||
| 			success: (res) =>{ | ||||
| 				// console.log(res,'100');
 | ||||
| 				self.data.deviceId = options.deviceId; | ||||
| 				mDeviceEvent.notifyDeviceMsgEvent({ | ||||
| 					'type': mDeviceEvent.XBLUFI_TYPE.TYPE_CONNECTED, | ||||
|  | @ -1277,10 +1291,11 @@ function init() { | |||
| 					'data': { | ||||
| 						deviceId: options.deviceId, | ||||
| 						name: options.name | ||||
| 					} | ||||
| 					}, | ||||
| 				}); | ||||
| 			}, | ||||
| 			fail: function (res) { | ||||
| 			fail: (res) =>{ | ||||
| 				// console.log(res,'1112');
 | ||||
| 				self.data.deviceId = null; | ||||
| 				mDeviceEvent.notifyDeviceMsgEvent({ | ||||
| 					'type': mDeviceEvent.XBLUFI_TYPE.TYPE_CONNECTED, | ||||
|  | @ -1289,6 +1304,7 @@ function init() { | |||
| 				}); | ||||
| 			} | ||||
| 		}); | ||||
| 		}  | ||||
| 		else uni.closeBLEConnection({ | ||||
| 			deviceId: options.deviceId, | ||||
| 			success: function (res) { | ||||
|  | @ -1351,19 +1367,18 @@ function init() { | |||
| 		mac_id = options.deviceId; | ||||
| 		 | ||||
| setTimeout(() => { | ||||
| 	console.log(deviceId,'deviceIddeviceId'); | ||||
| 		uni.getBLEDeviceServices({ | ||||
| 			// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
 | ||||
| 			deviceId: deviceId, | ||||
| 			success: function(res) { | ||||
| 				console.log("服务发现456", res) | ||||
| 				var services = res.services; | ||||
| 
 | ||||
| 				if (services.length > 0) { | ||||
| 					for (var i = 0; i < services.length; i++) { | ||||
| 						if (services[i].uuid === self.data.service_uuid) { | ||||
| 							var serviceId = services[i].uuid; | ||||
| 							uni.getBLEDeviceCharacteristics({ | ||||
| 
 | ||||
| 								// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
 | ||||
| 								deviceId: deviceId, | ||||
| 								serviceId: serviceId, | ||||
|  |  | |||
|  | @ -43,14 +43,19 @@ let OnFireEvent = { | |||
|  * 初始化 | ||||
|  * @param type 参考 XMQTT_SYSTEM | ||||
|  */ | ||||
| 
 | ||||
| let once = 0 | ||||
| function initXBlufi(type) { | ||||
|   switch (type) { | ||||
|     case XMQTT_SYSTEM.Alis: | ||||
|       break; | ||||
| 
 | ||||
|     case XMQTT_SYSTEM.WeChat: | ||||
|       if(once==0) | ||||
|       { | ||||
|         once = 1; | ||||
|       $wxBlufiImpl.init(); | ||||
| 
 | ||||
|       } | ||||
|       break; | ||||
|   } | ||||
| } | ||||
|  | @ -103,7 +108,7 @@ function listenStartDiscoverBle(isSetListener, funtion) { | |||
| 
 | ||||
| 
 | ||||
| function notifyConnectBle(options) { | ||||
|   console.log('notifyConnectBle 蓝牙准备连接的deviceId --------------'); | ||||
|   // console.log('notifyConnectBle 蓝牙准备连接的deviceId --------------');
 | ||||
|   mOnFire.fire(OnFireEvent.EVENT_CONNECT_DISCONNECT, options); | ||||
| } | ||||
| /** | ||||
|  | @ -170,7 +175,7 @@ function listenSendRouterSsidAndPassword(isSetListener, funtion) { | |||
| 
 | ||||
| 
 | ||||
| function notifySendCustomData(options) { | ||||
| 	console.log("设备数据",options) | ||||
| 	// console.log("设备数据",options)
 | ||||
|   mOnFire.fire(OnFireEvent.EVENT_NOFITY_SEND_CUSTON_DATA, options); | ||||
| } | ||||
| /** | ||||
|  |  | |||
|  | @ -68,10 +68,12 @@ | |||
| 				timer: null, | ||||
| 				expireTimeStr: '', | ||||
| 				zfobj: {}, | ||||
| 				orderno: '' | ||||
| 				orderno: '', | ||||
| 				id:'' | ||||
| 			} | ||||
| 		}, | ||||
| 		onLoad() { | ||||
| 		onLoad(option) { | ||||
| 			this.id = option.id | ||||
| 			this.startTimer() | ||||
| 			this.gettaoc() | ||||
| 		}, | ||||
|  | @ -85,7 +87,7 @@ | |||
| 				}, 30000); // 30秒   | ||||
| 			}, | ||||
| 			gettaoc() { | ||||
| 				this.$u.get(`/app/device/${this.deviceid}/withSuitList`).then((res) => { | ||||
| 				this.$u.get(`/app/device/${this.id}/withSuitList`).then((res) => { | ||||
| 					if (res.code == 200) { | ||||
| 						this.deviceobj = res.data; | ||||
| 						this.indexactive = res.data.suitList[0].suitId; | ||||
|  | @ -110,7 +112,7 @@ | |||
| 					}); | ||||
| 				} else { | ||||
| 					let data = { | ||||
| 						deviceNo: 'DS-000002', | ||||
| 						deviceNo: this.id, | ||||
| 						suitId: this.zfobj.suitId, | ||||
| 						money: this.zfobj.price, | ||||
| 						suitTime: this.zfobj.value | ||||
|  |  | |||
|  | @ -347,7 +347,7 @@ | |||
| 
 | ||||
| 							// 过滤出名称字段的前五个字母为 "CTPOW" 的项 | ||||
| 							let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === | ||||
| 								"CTPOW"); | ||||
| 								"CTKG"); | ||||
| 
 | ||||
| 							// 将过滤后的数组重新赋值给 this.devicesList | ||||
| 							this.devicesList = filteredDevices; | ||||
|  |  | |||
|  | @ -140,7 +140,7 @@ | |||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: | ||||
| 						if (options.result) { | ||||
| 							let devicesarr = options.data | ||||
| 							 | ||||
| 							console.log(devicesarr,100100); | ||||
| 							devicesarr.forEach(device => { | ||||
| 								const mac = device.name.substring(6); | ||||
| 
 | ||||
|  | @ -235,27 +235,27 @@ | |||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: | ||||
| 						if (options.result) { | ||||
| 							let uniqueDevicesList = Array.from(new Set(this.devicesList)); | ||||
| 
 | ||||
|                             console.log(uniqueDevicesList,'uniqueDevicesListuniqueDevicesList'); | ||||
| 							// 将去重后的数组重新赋值给 this.devicesList | ||||
| 							this.devicesList = uniqueDevicesList; | ||||
| 							let list = [] | ||||
| 							filteredDevices.forEach(device => { | ||||
| 							// this.devicesList.forEach(device => { | ||||
| 								// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) | ||||
| 								let macFromName = device.name.substring(device.name.length - 12); | ||||
| 								// let macFromName = device.name.substring(device.name.length - 12); | ||||
| 								// console.log(macFromName); | ||||
| 								// 与 this.mac 进行比较 | ||||
| 								this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { | ||||
| 									if (res.data == false) { | ||||
| 										list.push(device) | ||||
| 									} else { | ||||
| 								// this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { | ||||
| 								// 	if (res.data == false) { | ||||
| 								// 		list.push(device) | ||||
| 								// 	} else { | ||||
| 
 | ||||
| 									} | ||||
| 								}) | ||||
| 								// 	} | ||||
| 								// }) | ||||
| 
 | ||||
| 							}); | ||||
| 							setTimeout(() => { | ||||
| 								this.devicesList = list | ||||
| 							}, 200) | ||||
| 							// }); | ||||
| 							// setTimeout(() => { | ||||
| 							// 	this.devicesList = list | ||||
| 							// }, 200) | ||||
| 
 | ||||
| 							console.log('蓝牙停止搜索ok'); | ||||
| 						} else { | ||||
|  |  | |||
|  | @ -303,7 +303,7 @@ | |||
| 						let uniqueDevicesList = Array.from(new Set(this.devicesList)); | ||||
| 						 | ||||
| 						// 过滤出名称字段的前五个字母为 "CTPOW" 的项 | ||||
| 						let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "CTPOW"); | ||||
| 						let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "CTKG"); | ||||
| 						 | ||||
| 						// 将过滤后的数组重新赋值给 this.devicesList | ||||
| 						this.devicesList = filteredDevices; | ||||
|  |  | |||
|  | @ -292,7 +292,7 @@ | |||
| 						let uniqueDevicesList = Array.from(new Set(this.devicesList)); | ||||
| 						 | ||||
| 						// 过滤出名称字段的前五个字母为 "CTPOW" 的项 | ||||
| 						let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "CTPOW"); | ||||
| 						let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "CTKG"); | ||||
| 						 | ||||
| 						// 将过滤后的数组重新赋值给 this.devicesList | ||||
| 						this.devicesList = filteredDevices; | ||||
|  |  | |||
|  | @ -121,9 +121,13 @@ | |||
| 			 		scanType: ['qrCode'], | ||||
| 			 		success: res => { | ||||
| 			 			console.log('扫描结果:', res); | ||||
| 			 			this.qrResult = res.result;  | ||||
| 						uni.navigateTo({ | ||||
| 							url:'/page_fenbao/device/lianjie?mac=' + this.qrResult + '&storeId=' + this.storeId | ||||
| 						this.$u.get(`/app/device/${res.result}/bySn`).then((res) =>{ | ||||
| 							if(res.code == 200){ | ||||
| 								this.qrResult = res.data.mac | ||||
| 								uni.navigateTo({ | ||||
| 									url:'/page_fenbao/device/lianjie?mac=' + this.qrResult + '&storeId=' + this.storeId | ||||
| 								}) | ||||
| 							} | ||||
| 						}) | ||||
| 			 		}, | ||||
| 			 		fail: err => { | ||||
|  |  | |||
|  | @ -81,23 +81,28 @@ | |||
| 		}, | ||||
| 		methods: { | ||||
| 			scanQRCode() { | ||||
| 				uni.navigateTo({ | ||||
| 					url: '/page_components/fuwu/index' | ||||
| 				}) | ||||
| 				// uni.scanCode({ | ||||
| 				// 	onlyFromCamera: true, | ||||
| 				// 	scanType: ['qrCode'], | ||||
| 				// 	success: res => { | ||||
| 				// 		console.log('扫描结果:', res); | ||||
| 				// 	}, | ||||
| 				// 	fail: err => { | ||||
| 				// 		console.error('扫描失败:', err); | ||||
| 				// 		uni.showToast({ | ||||
| 				// 			title: '扫描失败', | ||||
| 				// 			icon: 'none' | ||||
| 				// 		}); | ||||
| 				// 	} | ||||
| 				// }); | ||||
| 				uni.scanCode({ | ||||
| 					onlyFromCamera: true, | ||||
| 					scanType: ['qrCode'], | ||||
| 					success: res => { | ||||
| 						console.log('扫描结果:', res); | ||||
| 						let id = res.result | ||||
| 						this.$u.get(`/app/device/${res.result}/withSuitList`).then((res) =>{ | ||||
| 							if(res.code == 200){ | ||||
| 								uni.navigateTo({ | ||||
| 									url: '/page_components/fuwu/index?id=' + id | ||||
| 								}) | ||||
| 							} | ||||
| 						}) | ||||
| 					}, | ||||
| 					fail: err => { | ||||
| 						console.error('扫描失败:', err); | ||||
| 						uni.showToast({ | ||||
| 							title: '扫描失败', | ||||
| 							icon: 'none' | ||||
| 						}); | ||||
| 					} | ||||
| 				}); | ||||
| 			}, | ||||
| 			 | ||||
| 			btnchak(id){ | ||||
|  |  | |||
|  | @ -130,7 +130,7 @@ | |||
| 						</view> | ||||
| 						<view class="cont" style="width: 60rpx;" @click="topage(5)"> | ||||
| 							<view class="top"> | ||||
| 								<image src="https://api.ccttiot.com/smartmeter/img/static/ubxoYVnbIK1rk0cfoL3j" mode=""> | ||||
| 								<image src="https://api.ccttiot.com/smartmeter/img/static/uWaQjL7vph474LWTyGfs" mode=""> | ||||
| 								</image> | ||||
| 							</view> | ||||
| 							<view class="bot">配网</view> | ||||
|  |  | |||
|  | @ -102,9 +102,8 @@ | |||
| 					</view> | ||||
| 
 | ||||
| 				</view> | ||||
| 				<!-- <view  | ||||
| 					style="margin-left:200rpx; color: #ccc;font-size: 36rpx;margin-top: 200rpx;width: 750rpx;"> | ||||
| 					该店铺暂无设备...</view> --> | ||||
| 				<!-- <view style="margin-left:200rpx; color: #ccc;font-size: 36rpx;margin-top: 200rpx;width: 750rpx;"> | ||||
| 					   该店铺暂无设备...</view> --> | ||||
| 			</view> | ||||
| 
 | ||||
| 		</view> | ||||
|  | @ -181,7 +180,6 @@ | |||
| 				showtip: false, | ||||
| 				orderinfo: [], | ||||
| 				storeId: '', | ||||
| 
 | ||||
| 				pagenum: 1, | ||||
| 				wateringList: [], | ||||
| 				pagesize: 10, | ||||
|  | @ -468,6 +466,11 @@ | |||
| 					success: res => { | ||||
| 						console.log('扫描结果:', res); | ||||
| 						this.qrResult = res.result; | ||||
| 						// this.$u.get(`/app/device/${this.qrResult}/withSuitList`).then((res) =>{ | ||||
| 						// 	if(res.code == 200){ | ||||
| 						// 		console.log(res); | ||||
| 						// 	} | ||||
| 						// }) | ||||
| 					}, | ||||
| 					fail: err => { | ||||
| 						console.error('扫描失败:', err); | ||||
|  |  | |||
|  | @ -87,23 +87,29 @@ | |||
| 
 | ||||
| 
 | ||||
| 			scanQRCode() { | ||||
| 				uni.navigateTo({ | ||||
| 					url: '/page_components/fuwu/index' | ||||
| 				}) | ||||
| 				// uni.scanCode({ | ||||
| 				// 	onlyFromCamera: true, | ||||
| 				// 	scanType: ['qrCode'], | ||||
| 				// 	success: res => { | ||||
| 				// 		console.log('扫描结果:', res); | ||||
| 				// 	}, | ||||
| 				// 	fail: err => { | ||||
| 				// 		console.error('扫描失败:', err); | ||||
| 				// 		uni.showToast({ | ||||
| 				// 			title: '扫描失败', | ||||
| 				// 			icon: 'none' | ||||
| 				// 		}); | ||||
| 				// 	} | ||||
| 				// }); | ||||
| 				 | ||||
| 				uni.scanCode({ | ||||
| 					onlyFromCamera: true, | ||||
| 					scanType: ['qrCode'], | ||||
| 					success: res => { | ||||
| 						// console.log('扫描结果:', res); | ||||
| 						let id = res.result | ||||
| 						this.$u.get(`/app/device/${res.result}/withSuitList`).then((res) =>{ | ||||
| 							if(res.code == 200){ | ||||
| 								uni.navigateTo({ | ||||
| 									url: '/page_components/fuwu/index?id=' + id | ||||
| 								}) | ||||
| 							} | ||||
| 						}) | ||||
| 					}, | ||||
| 					fail: err => { | ||||
| 						console.error('扫描失败:', err); | ||||
| 						uni.showToast({ | ||||
| 							title: '扫描失败', | ||||
| 							icon: 'none' | ||||
| 						}); | ||||
| 					} | ||||
| 				}); | ||||
| 			}, | ||||
| 
 | ||||
|             getad(){ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user