diff --git a/page_fenbao/device/index.vue b/page_fenbao/device/index.vue index 967a7fd..74f10c2 100644 --- a/page_fenbao/device/index.vue +++ b/page_fenbao/device/index.vue @@ -40,13 +40,13 @@ <text>...</text> <button @click="btnyc">好的</button> </view> - <!-- 加载状态 --> + <view class="containers" v-show="statusflag"> <uni-section> <uni-load-more :status="status" /> </uni-section> </view> - </view> + </view> </template> <script> @@ -76,9 +76,11 @@ gps: {}, mac: '', status: false, + storeId:'' } }, - onLoad() { + onLoad(option) { + this.storeId = option.storeId xBlufi.initXBlufi(1); console.log("xBlufi", xBlufi.XMQTT_SYSTEM); xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); @@ -86,7 +88,7 @@ 'isStart': true }); - // 两秒后停止蓝牙搜索 + // 两秒后停止蓝牙搜索 setTimeout(() => { xBlufi.notifyStartDiscoverBle({ 'isStart': false @@ -94,7 +96,7 @@ // 判断是否存在浇花器设备 if (this.devicesList.length == 0) { this.tishiflag = true - this.texts = '扫描完毕,暂无发现浇花器设备' + this.texts = '扫描完毕,暂无发现设备' } else { this.texts = '扫描到以下设备,请点击连接!' } @@ -103,20 +105,23 @@ }, onShow: function() { // this.openBluetoothAdapter() + // xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': false + // }); }, onUnload: function() { xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.notifyStartDiscoverBle({ 'isStart': false }); - - }, - onHide(){ - xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }); }, + // onHide(){ + // xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); + // xBlufi.notifyStartDiscoverBle({ + // 'isStart': false + // }); + // }, onBeforeUnmount(){ xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); xBlufi.notifyStartDiscoverBle({ @@ -139,7 +144,7 @@ devicesarr.forEach(device => { const mac = device.name.substring(6); - if (device.name.substring(0, 5) === "CTPOW") { + if (device.name.substring(0, 4) == "CTKG") { // this.$u.get(`/app/device/${mac}/isBind`, data).then((res) => { // if (res.data == false) { this.devicesList.push(device); @@ -161,27 +166,49 @@ console.log("连接回调:" + JSON.stringify(options)); if (options.result) { uni.hideLoading(); - uni.showToast({ - title: '连接成功', - icon: 'none' - }); { + // uni.showToast({ + // title: '连接成功', + // icon: 'none' + // }); + { console.log("连接回调options.data.deviceId:" + options.data.deviceId, "连接回调options.data.name:" + options.data.name); - - let systemInfo = uni.getSystemInfoSync(); - if (systemInfo.platform === 'android') { - // 当前设备是 Android - uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + options - .data.deviceId + '&name=' + options.data.name + + 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 + }); + uni.removeStorageSync('mac'); + let systemInfo = uni.getSystemInfoSync(); + if (systemInfo.platform === 'android') { + // 当前设备是 Android + uni.navigateTo({ + url: '/page_components/wifilist/index?deviceId=' + options + .data.deviceId + '&name=' + options.data.name + }) + } else if (systemInfo.platform === 'ios') { + // 当前设备是 iOS + uni.navigateTo({ + url: '/page_fenbao/device/wifivideo?deviceId=' + options + .data.deviceId + '&name=' + options.data.name + }) + } + + } else { + uni.showToast({ + title: '该设备已被绑定', + icon: 'none', + duration: 2000 + }); + } }) - } else if (systemInfo.platform === 'ios') { - // 当前设备是 iOS - uni.navigateTo({ - url: '/page_components/wifilist/index?deviceId=' + options - .data.deviceId + '&name=' + options.data.name - }) - } } } @@ -250,7 +277,7 @@ xBlufi.notifyStartDiscoverBle({ 'isStart': false }); - console.log(e, '蓝牙信息') + console.log(e, '蓝牙信息101010') const deviceId = e.deviceId this.Bluetoothmac = e.localName.substring(6) //从第七位开始截取 只取后面的mac号 this.mac = e.localName.substring(6) @@ -259,72 +286,47 @@ xBlufi.notifyConnectBle({ isStart: true, deviceId: e.deviceId, - name + name:e.name }); let that = this uni.getLocation({ type: 'wgs84', success: function(lb) { console.log('位置信息', lb); - console.log('当前位置的经度:' + lb.longitude); - console.log('当前位置的纬度:' + lb.latitude); that.gps.lat = lb.latitude; that.gps.lon = lb.longitude; - that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '绑定成功', - icon: 'none', - duration: 2000 - }); - uni.removeStorageSync('mac'); - // setTimeout(()=>{ - // uni.switchTab({ - // url:'/pages/index/index' - // }) - // },) - } else { - // setTimeout(()=>{ - // uni.switchTab({ - // url:'/pages/index/index' - // }) - // },) - } - }) + }, fail: function(error) { console.error('获取位置信息失败:', error); that.gps.lat = 0; that.gps.lon = 0; - that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '绑定成功', - icon: 'none', - duration: 2000 - }); - uni.removeStorageSync('mac'); - // setTimeout(()=>{ - // uni.switchTab({ - // url:'/pages/index/index' - // }) - // },) - } else { - // setTimeout(()=>{ - // uni.switchTab({ - // url:'/pages/index/index' - // }) - // },) - } - }) + // that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => { + // if (res.code == 200) { + // uni.showToast({ + // title: '绑定成功', + // icon: 'none', + // duration: 2000 + // }); + // uni.removeStorageSync('mac'); + // // setTimeout(()=>{ + // // uni.switchTab({ + // // url:'/pages/index/index' + // // }) + // // },) + // } else { + // // setTimeout(()=>{ + // // uni.switchTab({ + // // url:'/pages/index/index' + // // }) + // // },) + // } + // }) // 在这里处理获取位置信息失败的情况 } }) - - - }, // 点击重新搜索 Search() { @@ -345,10 +347,10 @@ xBlufi.notifyStartDiscoverBle({ 'isStart': false }); - // 判断是否存在浇花器设备 + // 判断是否存在设备 if (this.devicesList.length == 0) { this.tishiflag = true - this.texts = '扫描完毕,暂无发现浇花器设备' + this.texts = '扫描完毕,暂无发现设备' } else { this.texts = '扫描到以下设备,请点击连接!' } diff --git a/page_fenbao/statulist/myshop/shopdetail/index.vue b/page_fenbao/statulist/myshop/shopdetail/index.vue index eee166b..73d8f99 100644 --- a/page_fenbao/statulist/myshop/shopdetail/index.vue +++ b/page_fenbao/statulist/myshop/shopdetail/index.vue @@ -111,7 +111,7 @@ this.scanQRCode() } else if (type == '2') { uni.navigateTo({ - url: '/page_fenbao/device/index' + url: '/page_fenbao/device/index?storeId=' + this.storeId }) } }, @@ -121,7 +121,10 @@ scanType: ['qrCode'], success: res => { console.log('扫描结果:', res); - this.qrResult = res.result; // 将扫描结果存储在数据中 + this.qrResult = res.result; + uni.navigateTo({ + url:'/page_fenbao/device/lianjie?mac=' + this.qrResult + '&storeId=' + this.storeId + }) }, fail: err => { console.error('扫描失败:', err); diff --git a/page_fenbao/statulist/nearby/index.vue b/page_fenbao/statulist/nearby/index.vue index 381d02e..32c8148 100644 --- a/page_fenbao/statulist/nearby/index.vue +++ b/page_fenbao/statulist/nearby/index.vue @@ -219,7 +219,7 @@ } .list{ display: flex; - justify-content: space-between; + // justify-content: space-between; margin-top: 44rpx; border-bottom: 1px solid #eee; padding-bottom: 16rpx; @@ -235,6 +235,7 @@ } } .cen{ + width: 488rpx; .cena{ font-weight: 500; font-size: 28rpx; diff --git a/pages.json b/pages.json index 991da24..406437b 100644 --- a/pages.json +++ b/pages.json @@ -215,6 +215,15 @@ "navigationBarTextStyle": "#FFFFFF", "navigationStyle": "custom" } + },{ + "path": "device/lianjie", + "style": { + "navigationBarTitleText": "添加设备", + "enablePullDownRefresh": false, + "navigationBarBackgroundColor": "#3996FD", + "navigationBarTextStyle": "#FFFFFF", + "navigationStyle": "custom" + } }, { "path": "device/wifiDevice", @@ -225,8 +234,18 @@ "navigationBarTextStyle": "#FFFFFF", "navigationStyle": "custom" } + },{ + "path": "device/wifivideo", + "style": { + "navigationBarTitleText": "添加设备", + "enablePullDownRefresh": false, + "navigationBarBackgroundColor": "#3996FD", + "navigationBarTextStyle": "#FFFFFF", + "navigationStyle": "custom" + } }, + { "path": "device/czDevice", "style": { diff --git a/pages/index/index.vue b/pages/index/index.vue index 14ac60b..d7dd473 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -27,9 +27,9 @@ {{titlist}} </view> <view class="right"> - <view class="fd_set" @click="show = true"> + <!-- <view class="fd_set" @click="show = true"> + - </view> + </view> --> <view class="fd_set iconfont icon-liebiao" @click="showfz = true"> </view> diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue index 60a9a61..6116687 100644 --- a/pages/shouye/index.vue +++ b/pages/shouye/index.vue @@ -10,7 +10,7 @@ <view class="ditu"> <view class="dtxs"> <map class='map' :latitude="latitude" :longitude="longitude" @markertap="handleMarkerClick" - :show-location="true" :markers="covers"/> + :show-location="true" :markers="covers" :scale="13"/> </view> <view class="fujin"> <image src="https://api.ccttiot.com/smartmeter/img/static/u7HPhEwbIJqbLRpImBON" mode="" @click="btnindex(5)"></image>