From b0f9987eac7ed8cadeb55dcb92415dffdad98a77 Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Thu, 21 Nov 2024 17:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=80=E5=85=B3=E8=93=9D?= =?UTF-8?q?=E7=89=99=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.interceptor.js | 2 +- page_components/bindsztwo.vue | 273 ++++++++------- page_components/fuwu/index.vue | 14 +- page_components/wifilist/index.vue | 171 ++++++++-- page_fenbao/device/joinDevice.vue | 15 +- page_fenbao/statulist/nearby/index.vue | 33 +- page_fenbao/zhuce.vue | 14 +- page_user/mapditu/index.vue | 2 +- page_user/sbdetail.vue | 446 +++++++++++-------------- page_user/wifijoint/index.vue | 11 +- pages/index/index.vue | 8 +- pages/my.vue | 2 +- pages/shouye/index.vue | 3 +- pages/tj.vue | 121 +------ 14 files changed, 551 insertions(+), 564 deletions(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index b2a3037..12ca17e 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -19,7 +19,7 @@ const install = (Vue, vm) => { // }, // }); Vue.prototype.$u.http.setConfig({ - // baseUrl: 'http://192.168.2.12:10002', + // baseUrl: 'http://192.168.2.27:10002', baseUrl: 'https://kg.chuangtewl.com/prod-api', // loadingText: '加载中...', // loadingTime: 1000, diff --git a/page_components/bindsztwo.vue b/page_components/bindsztwo.vue index db352f7..cb348b2 100644 --- a/page_components/bindsztwo.vue +++ b/page_components/bindsztwo.vue @@ -142,6 +142,9 @@ this.sn = option.sn }, onShow() { + if(uni.getStorageSync('lianjie')){ + this.id = uni.getStorageSync('lianjie') + } this.wateringList = [] this.setMode == null this.taocan = '' @@ -151,6 +154,9 @@ }, onUnload: function() { console.log("unload "); + // uni.removeStorage({ + // key: 'lianjie' + // }) xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); wx.closeBLEConnection({ deviceId: this.deviceId, @@ -290,135 +296,150 @@ }, // 点击wifi进行配网 btnwifi() { - this.shibaiflag = false - this.bluetoothflag = true - // console.log(this.deviceId,'idididididdidii'); - if (this.setMode == null) { - xBlufi.initXBlufi(1) - xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) - xBlufi.notifyStartDiscoverBle({ - 'isStart': true + uni.setStorageSync('lianjie',this.id) + let systemInfo = uni.getSystemInfoSync() + if (systemInfo.platform == 'android') { + // 当前设备是 Android + uni.navigateTo({ + url: '/page_components/wifilist/index?deviceId=' + this + .qrResult + '&name=' + this.name }) - - // 停止蓝牙搜索 - setTimeout(() => { - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }) - xBlufi.notifyConnectBle({ - isStart: true, - deviceId: this.deviceId, - name: this.name - }) - xBlufi.notifyInitBleEsp32({ - deviceId: this.deviceId - }) - let name = '' - let index = this.name.indexOf('-') - if (index !== -1) { - name = this.name.slice(index + 1) - } - let data = { - storeId: this.storeId, - mac: this.mac - } - this.$u.put('/app/device/bind', data).then((res) => { - if (res.code == 200) { - uni.hideLoading(); - this.shibaiflag = false - this.bluetoothflag = false - uni.removeStorageSync('mac'); - let systemInfo = uni.getSystemInfoSync() - if (systemInfo.platform == 'android') { - // 当前设备是 Android - uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + this - .deviceId + '&name=' + this.name - }) - } else if (systemInfo.platform == 'ios') { - // 当前设备是 iOS - uni.navigateTo({ - url: '/page_fenbao/device/wifivideo?deviceId=' + this - .deviceId + '&name=' + this.name - }) - } - } else if (res.msg == '设备编号和mac不能同时为空') { - this.shibaiflag = true - this.bluetoothflag = false - // uni.showToast({ - // title: '连接失败', - // icon: 'none', - // duration: 2000 - // }); - } else { - // uni.showToast({ - // title: res.msg, - // icon: 'none', - // duration: 2000 - // }); - // uni.navigateBack() - } - }) - }, 1000) - } else { - let name = '' - let index = this.name.indexOf('-') - if (index !== -1) { - name = this.name.slice(index + 1) - } - let data = { - storeId: this.storeId, - mac: this.mac - } - this.$u.put('/app/device/bind', data).then((res) => { - if (res.code == 200) { - // uni.showToast({ - // title: '绑定成功', - // icon: 'none', - // duration: 2000 - // }) - this.shibaiflag = false - this.bluetoothflag = false - uni.hideLoading(); - uni.removeStorageSync('mac'); - let systemInfo = uni.getSystemInfoSync() - if (systemInfo.platform == 'android') { - // 当前设备是 Android - uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + this.deviceId + - '&name=' + this.name - }) - } else if (systemInfo.platform == 'ios') { - // 当前设备是 iOS - uni.navigateTo({ - url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId + - '&name=' + this.name - }) - } - } else { - if (res.msg == '设备编号和mac不能同时为空') { - this.shibaiflag = true - this.bluetoothflag = false - uni.hideLoading() - // uni.showToast({ - // title: '连接失败', - // icon: 'none', - // duration: 2000 - // }) - } else { - this.shibaiflag = true - this.bluetoothflag = false - uni.hideLoading() - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - // uni.navigateBack() - } - } + } else if (systemInfo.platform == 'ios') { + // 当前设备是 iOS + uni.navigateTo({ + url: '/page_fenbao/device/wifivideo?deviceId=' + this + .qrResult + '&name=' + this.name }) } + // this.shibaiflag = false + // this.bluetoothflag = true + // // console.log(this.deviceId,'idididididdidii'); + // if (this.setMode == null) { + // xBlufi.initXBlufi(1) + // xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': true + // }) + + // // 停止蓝牙搜索 + // setTimeout(() => { + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': false + // }) + // xBlufi.notifyConnectBle({ + // isStart: true, + // deviceId: this.deviceId, + // name: this.name + // }) + // xBlufi.notifyInitBleEsp32({ + // deviceId: this.deviceId + // }) + // let name = '' + // let index = this.name.indexOf('-') + // if (index !== -1) { + // name = this.name.slice(index + 1) + // } + // let data = { + // storeId: this.storeId, + // mac: this.mac + // } + // this.$u.put('/app/device/bind', data).then((res) => { + // if (res.code == 200) { + // uni.hideLoading(); + // this.shibaiflag = false + // this.bluetoothflag = false + // uni.removeStorageSync('mac'); + // let systemInfo = uni.getSystemInfoSync() + // if (systemInfo.platform == 'android') { + // // 当前设备是 Android + // uni.navigateTo({ + // url: '/page_components/wifilist/index?deviceId=' + this + // .deviceId + '&name=' + this.name + // }) + // } else if (systemInfo.platform == 'ios') { + // // 当前设备是 iOS + // uni.navigateTo({ + // url: '/page_fenbao/device/wifivideo?deviceId=' + this + // .deviceId + '&name=' + this.name + // }) + // } + // } else if (res.msg == '设备编号和mac不能同时为空') { + // this.shibaiflag = true + // this.bluetoothflag = false + // // uni.showToast({ + // // title: '连接失败', + // // icon: 'none', + // // duration: 2000 + // // }); + // } else { + // // uni.showToast({ + // // title: res.msg, + // // icon: 'none', + // // duration: 2000 + // // }); + // // uni.navigateBack() + // } + // }) + // }, 1000) + // } else { + // let name = '' + // let index = this.name.indexOf('-') + // if (index !== -1) { + // name = this.name.slice(index + 1) + // } + // let data = { + // storeId: this.storeId, + // mac: this.mac + // } + // this.$u.put('/app/device/bind', data).then((res) => { + // if (res.code == 200) { + // // uni.showToast({ + // // title: '绑定成功', + // // icon: 'none', + // // duration: 2000 + // // }) + // this.shibaiflag = false + // this.bluetoothflag = false + // uni.hideLoading(); + // uni.removeStorageSync('mac'); + // let systemInfo = uni.getSystemInfoSync() + // if (systemInfo.platform == 'android') { + // // 当前设备是 Android + // uni.navigateTo({ + // url: '/page_components/wifilist/index?deviceId=' + this.deviceId + + // '&name=' + this.name + // }) + // } else if (systemInfo.platform == 'ios') { + // // 当前设备是 iOS + // uni.navigateTo({ + // url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId + + // '&name=' + this.name + // }) + // } + // } else { + // if (res.msg == '设备编号和mac不能同时为空') { + // this.shibaiflag = true + // this.bluetoothflag = false + // uni.hideLoading() + // // uni.showToast({ + // // title: '连接失败', + // // icon: 'none', + // // duration: 2000 + // // }) + // } else { + // this.shibaiflag = true + // this.bluetoothflag = false + // uni.hideLoading() + // uni.showToast({ + // title: res.msg, + // icon: 'none', + // duration: 2000 + // }) + // // uni.navigateBack() + // } + // } + // }) + // } }, sremakes() { diff --git a/page_components/fuwu/index.vue b/page_components/fuwu/index.vue index b228ca4..786f1af 100644 --- a/page_components/fuwu/index.vue +++ b/page_components/fuwu/index.vue @@ -244,6 +244,7 @@ }, onShow() { // this.getuserinfo() + this.swindleflag = true this.getzfqd() setTimeout(()=>{ if (this.id != '') { @@ -292,6 +293,7 @@ uni.showModal({ title: '提示', content: '该设备暂无套餐,是否前去配置?', + showCancel: false, success: function(res) { if (res.confirm) { uni.setStorageSync('tcidlist', that.arrlists) @@ -307,7 +309,7 @@ uni.showToast({ title:'该设备暂无套餐,请联系商家添加套餐在使用', icon: 'none', - duration:2000 + duration:5000 }) } }, @@ -458,7 +460,7 @@ this.zfobj = res.data.suitList[0] let targetDateStr = this.deviceobj.expireTime this.mchShowBillMobile = res.data.mchShowBillMobile - if(this.mchShowBillMobile == true && this.phonenumber == ''){ + if(this.phonenumber == '' || this.phonenumber == null){ this.telslag = true }else{ this.telslag = false @@ -508,8 +510,9 @@ icon: 'none', duration: 1000 }) - }else if(this.mchShowBillMobile == true && this.phonenumber == ''){ - this.getPhoneNumber() + }else if(this.phonenumber == '' || this.phonenumber == null){ + // this.getPhoneNumber() + this.telslag = true }else { // this.zhifuflag = true this.getzhifu() @@ -517,9 +520,10 @@ }, // 获取手机号 getPhoneNumber(e){ + console.log(e); this.$u.put(`/app/user/bindWxMobile?mobileCode=${e.detail.code}`).then(res =>{ if(res.code == 200){ - this.zhifuflag = true + this.zhifuflag = false this.getzhifu() }else{ uni.showToast({ diff --git a/page_components/wifilist/index.vue b/page_components/wifilist/index.vue index 1b470ff..4f6ccd4 100644 --- a/page_components/wifilist/index.vue +++ b/page_components/wifilist/index.vue @@ -190,7 +190,7 @@ --> - + @@ -241,6 +241,9 @@ currentIndex: 0, // 控制当前应该显示到哪个点 dotShowInterval: null, + devicesList:[], + ver_data:'', + ljljflag:true }; }, @@ -302,13 +305,35 @@ }, onLoad: function(option) { // 传过来的蓝牙信息 + this.Binddevice() this.objlist = option - + setTimeout(() =>{ + if(this.ver_data == ''){ + uni.showModal({ + title: '温馨提示', + content: '蓝牙连接失败,请重新操作', + showCancel: false, + success: function(res) { + this.ljljflag = false + uni.reLaunch({ + url:'/pages/index/index' + }) + } + }) + }else{ + console.log('32751212'); + } + },15000) // 接受蓝牙信息 - xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); - xBlufi.notifyInitBleEsp32({ - deviceId: this.objlist.deviceId - }) + // xBlufi.initXBlufi(1) + // xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': true + // }) + // xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); + // xBlufi.notifyInitBleEsp32({ + // deviceId: this.objlist.deviceId + // }) var that = this wx.startWifi({ @@ -375,6 +400,7 @@ }, onUnload: function() { console.log("unload返回 "); + if (this.dotShowInterval) { clearInterval(this.dotShowInterval); } @@ -389,6 +415,67 @@ this.startDotShow() }, methods: { + Binddevice() { + uni.showLoading({ + title: '蓝牙连接中..' + }) + xBlufi.initXBlufi(1); + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + // 两秒后停止蓝牙搜索 + setTimeout(() => { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + setTimeout(() => { + if (this.devicesList.length == 0) { + uni.showToast({ + title: '暂无发现对应设备,请重试', + icon: 'none' + }); + } else { + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + this.devicesList = uniqueDevicesList; + // console.log(this.devicesList,'this.devicesListthis.devicesList'); + this.devicesList.forEach(device => { + let macFromName = device.name.substring(device.name.length - 12); + console.log(macFromName, 'macFromNamemacFromName'); + // 与 this.mac 进行比较 + if (macFromName == this.objlist.deviceId) { + // 如果相同,则将 this.ishave 设置为 true + console.log(device); + this.deviceInfoss = device + this.createBLEConnection(device) + console.log('对比正确1111111111'); + } else { + console.log('对比错误'); + + } + }); + } + }, 200) + }, 2000) + }, + createBLEConnection(e) { + console.log('调用了'); + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + console.log(e, '蓝牙信息') + const deviceId = e.deviceId + this.deviceId = e.deviceId + this.Bluetoothmac = e.localName.substring(5) //从第七位开始截取 只取后面的mac号 + console.log(this.Bluetoothmac, '11111'); + let name = e.name; + console.log('点击了,蓝牙准备连接的deviceId:' + e.deviceId); + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: e.deviceId, + name + }); + }, // 开始旋转图片 // 模拟异步请求 @@ -513,9 +600,6 @@ btnsd() { this.sdmaskflag = true this.ssid = '' - // uni.navigateTo({ - // url: '/page_user/wifijoint/index?objlist=' + JSON.stringify(this.objlist) + '&ssid=' + JSON.stringify(this.ssid) - // }) }, @@ -547,7 +631,7 @@ content: '配网失败,请重新操作', showCancel: false, success: function(res) { - uni.switchTab({ + uni.reLaunch({ url:'/pages/index/index' }) } @@ -580,6 +664,37 @@ // uni.hideLoading(); // } // break; + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: + if (options.result) { + let devicesarr = options.data + devicesarr.forEach(device => { + this.devicesList.push(device); + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + // 将去重后的数组重新赋值给 this.devicesList + this.devicesList = uniqueDevicesList; + }) + } + break; + case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED: + console.log("连接回调:" + JSON.stringify(options)); + if (options.result) { + uni.showToast({ + title: '连接成功', + icon: 'success', + duration:2000 + }) + setTimeout(()=>{ + this.ljljflag = false + uni.hideLoading(); + },1500) + { + xBlufi.notifyInitBleEsp32({ + deviceId: options.data.deviceId + }); + } + } + + break; case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT: uni.hideLoading(); @@ -592,18 +707,8 @@ content: '配网失败,请选择2.4GWiFi连接并确保密码正确', showCancel: false ,//是否显示取消按钮 success:function(res) { - let systemInfo = uni.getSystemInfoSync(); - if (systemInfo.platform == 'android') { - // 当前设备是 Android - uni.navigateBack() - } else if (systemInfo.platform == 'ios') { - // 当前设备是 iOS - uni.navigateBack({ - delta:2 - }) - } - wx.closeBLEConnection({ - deviceId: this.objlist.deviceId, + uni.reLaunch({ + url:'/pages/index/index' }) } }); @@ -615,23 +720,18 @@ this.textwifi = '连接' uni.showModal({ title: '温馨提示', - content: `连接成功`, + content: `配网成功`, showCancel: false, success: function(res) { - uni.hideLoading() - let systemInfo = uni.getSystemInfoSync(); - if (systemInfo.platform == 'android') { - // 当前设备是 Android - uni.navigateBack() - } else if (systemInfo.platform == 'ios') { - // 当前设备是 iOS - uni.navigateBack({ - delta:2 + if(uni.getStorageSync('lianjie')){ + uni.reLaunch({ + url:'/page_components/bindsztwo' + }) + }else{ + uni.reLaunch({ + url:'/pages/index/index' }) } - wx.closeBLEConnection({ - deviceId: this.objlist.deviceId, - }) } }) } @@ -650,7 +750,6 @@ break; case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT: - uni.hideLoading(); if (options.result) { console.log('初始化成功'); } else { diff --git a/page_fenbao/device/joinDevice.vue b/page_fenbao/device/joinDevice.vue index 7c72b73..9f41592 100644 --- a/page_fenbao/device/joinDevice.vue +++ b/page_fenbao/device/joinDevice.vue @@ -1,6 +1,6 @@