From ceb9558de48d7a86e47e7c5d6104f5236dc6049b Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Tue, 21 May 2024 15:07:11 +0800 Subject: [PATCH] aaa --- page_components/blufi/crypto/lib/blelib.js | 6 ++- page_components/blufi/xBlufi-wx-impl.js | 47 ++++++++++++------- page_components/blufi/xBlufi.js | 11 +++-- page_components/fuwu/index.vue | 10 ++-- page_fenbao/device/czDevice.vue | 2 +- page_fenbao/device/index.vue | 28 +++++------ page_fenbao/device/joinDevice.vue | 2 +- page_fenbao/device/wifiDevice.vue | 2 +- .../statulist/myshop/shopdetail/index.vue | 10 ++-- page_user/mapditu/index.vue | 39 ++++++++------- page_user/sbdetail.vue | 2 +- pages/index/index.vue | 11 +++-- pages/shouye/index.vue | 40 +++++++++------- 13 files changed, 126 insertions(+), 84 deletions(-) diff --git a/page_components/blufi/crypto/lib/blelib.js b/page_components/blufi/crypto/lib/blelib.js index febb877..6f6f03f 100644 --- a/page_components/blufi/crypto/lib/blelib.js +++ b/page_components/blufi/crypto/lib/blelib.js @@ -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) + } } }) }; diff --git a/page_components/blufi/xBlufi-wx-impl.js b/page_components/blufi/xBlufi-wx-impl.js index 589f02e..15fc731 100644 --- a/page_components/blufi/xBlufi-wx-impl.js +++ b/page_components/blufi/xBlufi-wx-impl.js @@ -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, diff --git a/page_components/blufi/xBlufi.js b/page_components/blufi/xBlufi.js index 06c8105..2079f80 100644 --- a/page_components/blufi/xBlufi.js +++ b/page_components/blufi/xBlufi.js @@ -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); } /** diff --git a/page_components/fuwu/index.vue b/page_components/fuwu/index.vue index 21d9d07..0529ea8 100644 --- a/page_components/fuwu/index.vue +++ b/page_components/fuwu/index.vue @@ -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 diff --git a/page_fenbao/device/czDevice.vue b/page_fenbao/device/czDevice.vue index b431be5..d76df68 100644 --- a/page_fenbao/device/czDevice.vue +++ b/page_fenbao/device/czDevice.vue @@ -347,7 +347,7 @@ // 过滤出名称字段的前五个字母为 "CTPOW" 的项 let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === - "CTPOW"); + "CTKG"); // 将过滤后的数组重新赋值给 this.devicesList this.devicesList = filteredDevices; diff --git a/page_fenbao/device/index.vue b/page_fenbao/device/index.vue index d65c998..465e458 100644 --- a/page_fenbao/device/index.vue +++ b/page_fenbao/device/index.vue @@ -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 { diff --git a/page_fenbao/device/joinDevice.vue b/page_fenbao/device/joinDevice.vue index 30a0f9c..c814de2 100644 --- a/page_fenbao/device/joinDevice.vue +++ b/page_fenbao/device/joinDevice.vue @@ -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; diff --git a/page_fenbao/device/wifiDevice.vue b/page_fenbao/device/wifiDevice.vue index c157091..78f266a 100644 --- a/page_fenbao/device/wifiDevice.vue +++ b/page_fenbao/device/wifiDevice.vue @@ -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; diff --git a/page_fenbao/statulist/myshop/shopdetail/index.vue b/page_fenbao/statulist/myshop/shopdetail/index.vue index 73d8f99..71043e3 100644 --- a/page_fenbao/statulist/myshop/shopdetail/index.vue +++ b/page_fenbao/statulist/myshop/shopdetail/index.vue @@ -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 => { diff --git a/page_user/mapditu/index.vue b/page_user/mapditu/index.vue index 621151a..a1e5625 100644 --- a/page_user/mapditu/index.vue +++ b/page_user/mapditu/index.vue @@ -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){ diff --git a/page_user/sbdetail.vue b/page_user/sbdetail.vue index cf9dd14..0748e7c 100644 --- a/page_user/sbdetail.vue +++ b/page_user/sbdetail.vue @@ -130,7 +130,7 @@ - + 配网 diff --git a/pages/index/index.vue b/pages/index/index.vue index 377e6e4..2241ae5 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -102,9 +102,8 @@ - + @@ -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); diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue index 6116687..a0806db 100644 --- a/pages/shouye/index.vue +++ b/pages/shouye/index.vue @@ -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(){