From 31fd6cfb048a8ee3cf187dacbed4373cf060af6b Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Sat, 17 May 2025 12:09:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E9=B9=BF=E9=AA=91=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.interceptor.js | 4 +- page_shanghu/admin_index.vue | 172 +++++++++-------------- page_shanghu/guanli/admin_worke.vue | 6 +- page_shanghu/guanli/device_detail.vue | 51 ++++--- page_shanghu/guanli/order_detail.vue | 2 +- page_shanghu/guanli/yunying.vue | 4 +- pages/index/index.vue | 25 ++-- pages/myorder/returned/index.vue | 183 +++++++++++++------------ pages/nearbystores/index.vue | 188 ++++++++++++-------------- 9 files changed, 289 insertions(+), 346 deletions(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 5754c98..0c9609b 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -1,9 +1,9 @@ const install = (Vue, vm) => { uni.setStorageSync('deptId', 100); Vue.prototype.$u.http.setConfig({ - // baseUrl: 'http://192.168.2.14:4101', //键辉本地 + baseUrl: 'http://192.168.2.14:4101', //键辉本地 // baseUrl: 'http://192.168.0.102:4101', //景森本地 - baseUrl: 'https://ele.ccttiot.com/prod-api', //线上 + // baseUrl: 'https://ele.ccttiot.com/prod-api', //线上 loadingText: '努力加载中~', loadingTime: 10000, // 设置自定义头部content-type diff --git a/page_shanghu/admin_index.vue b/page_shanghu/admin_index.vue index 207ea72..343635d 100644 --- a/page_shanghu/admin_index.vue +++ b/page_shanghu/admin_index.vue @@ -89,11 +89,12 @@ {{qbobj.device.statusCount[6] == null ? '0' : qbobj.device.statusCount[6]}} - - + + + 离线 - + {{qbobj.device.onlineStatusCount[0] == null ? '0' : qbobj.device.onlineStatusCount[0]}} @@ -105,6 +106,14 @@ {{qbobj.device.onlineStatusCount[1] == null ? '0' : qbobj.device.onlineStatusCount[1]}} + + + 强制锁车 + + + {{qbobj.device.onlineStatusCount[9] == null ? '0' : qbobj.device.onlineStatusCount[9]}} + + 全部设备 @@ -179,11 +188,7 @@ status4: [], //临时锁车 status8: [], //下线 status9: [], //离线 - markdata: { - - - - }, + markdata: {}, statusidx: '7', deviceNum: {}, areaId: 0, @@ -200,36 +205,28 @@ }, onShow() { this.polyline = [] - // this.allVehicleNum() if (uni.getStorageSync('adminAreaid')) { this.areaId = uni.getStorageSync('adminAreaid') this.getArea() - console.log(this.areaId); + console.log(this.areaId) } this.getqb() this.getmarks() }, onLoad() { - - let that = this uni.getLocation({ type: 'wgs84', success: function(lb) { - - console.log(that.areaInfo, 'that.areaInfo'); - + console.log(that.areaInfo, 'that.areaInfo') }, fail: function(error) { uni.showToast({ title: '未获取到定位信息,请点击设置勾选允许位置信息,即可使用全部功能', icon: 'none', duration: 2000 - }); - // that.getmarks() - // 在这里处理获取位置信息失败的情况 + }) } - }) }, computed: { @@ -269,10 +266,8 @@ onMapRegionChange(event) { - // console.log('regionchange', event) if (event.detail.type == 'end') { this.getCenterLocation() - // this.getCenter() } // 你可以在这里执行你需要的操作 }, @@ -287,30 +282,30 @@ }) }, getCenterLocation() { - const mapContext = uni.createMapContext('map'); + const mapContext = uni.createMapContext('map') mapContext.getCenterLocation({ success: (res) => { - console.log('中心点的经纬度:', res.longitude, res.latitude); - this.getNearbyMarkers(res.latitude, res.longitude); + console.log('中心点的经纬度:', res.longitude, res.latitude) + this.getNearbyMarkers(res.latitude, res.longitude) }, fail: (err) => { - console.error('获取中心点定位失败:', err); + console.error('获取中心点定位失败:', err) } - }); + }) }, getCenter: function() { - var _that = this; + var _that = this appMap.getCurrentCenter( function(state, point) { if (0 == state) { // 反编码 var point = new plus.maps.Point(point["longitude"], point["latitude"]); plus.maps.Map.reverseGeocode(point, {}, function(event) { - var address = event.address; // 转换后的地理位置 - var coord = event.coord; // 转换后的坐标信息 - var coordType = event.coordType; // 转换后的坐标系类型 - console.log("Address:" + address); - console.log("coord", coord); + var address = event.address // 转换后的地理位置 + var coord = event.coord // 转换后的坐标信息 + var coordType = event.coordType // 转换后的坐标系类型 + console.log("Address:" + address) + console.log("coord", coord) uni.showModal({ title: "提示", content: "确定:" + address + "?", @@ -321,11 +316,10 @@ } }) }, function(e) { - // console.log("Failed:" + JSON.stringify(e)); uni.showToast({ title: '反编码失败' + JSON.stringify(e) - }); - }); + }) + }) } else { uni.showToast({ icon: "none", @@ -333,11 +327,9 @@ }) } } - ); + ) }, getNearbyMarkers(clickedLat, clickedLon) { - // console.log(clickedLat, clickedLon); - // 只有在 showdevList 为 true 的时候才显示圆形区域 if (this.showdevList) { const nearbyMarkers = this.listData.filter(item => { @@ -347,17 +339,15 @@ parseFloat(clickedLon), parseFloat(item.latitude), parseFloat(item.longitude) - ); - return distance <= 100; + ) + return distance <= 100 } - return false; - }); - + return false + }) // 根据 remainingPower 进行升序排序 nearbyMarkers.sort((a, b) => { - return a.remainingPower - b.remainingPower; - }); - + return a.remainingPower - b.remainingPower + }) // 更新 circles 数组来绘制淡灰色的圆形区域 this.circles = [{ latitude: clickedLat, @@ -367,9 +357,7 @@ radius: 100, // 圆的半径(单位:米) strokeWidth: 1 }] - - this.nearbyMarkers = nearbyMarkers; - // console.log('Nearby markers within 100 meters:', nearbyMarkers); + this.nearbyMarkers = nearbyMarkers } else { // 当 showdevList 为 false 时,清空 circles 数组 this.circles = [] @@ -380,9 +368,7 @@ const toRad = angle => angle * Math.PI / 180 const dLat = toRad(lat2 - lat1) const dLon = toRad(lon2 - lon1) - const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * - Math.sin(dLon / 2) * Math.sin(dLon / 2) + const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2) const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) return R * c }, @@ -416,7 +402,7 @@ onlyFromCamera: true, scanType: ['qrCode'], success: res => { - console.log(res); + console.log(res) function getQueryParam(url, paramName) { let regex = new RegExp(`[?&]${paramName}=([^&]*)`) let results = regex.exec(url) @@ -425,7 +411,7 @@ let sceneValue = res.result let decodedValue = decodeURIComponent(sceneValue) this.sn = getQueryParam(decodedValue, 's') - console.log(this.sn,'....'); + console.log(this.sn,'....') if (this.sn != '') { this.$u.get('/bst/device?sn=' + this.sn).then((res) => { if (res.code === 200) { @@ -439,7 +425,7 @@ title: '无效车辆', icon: 'none', duration: 2000 - }); + }) } } else { uni.showToast({ @@ -465,20 +451,6 @@ url: '/page_shanghu/gongzuotai/woke_deviceMgmt' }) }, - // allVehicleNum() { - // let data = { - // powerStart: this.rangeValue[0], - // powerEnd: this.rangeValue[1], - // areaId: this.areaId - // } - // this.$u.get('/appVerify/allVehicleNum?', data).then((res) => { //地图下面所有统计 - // if (res.code === 200) { - // this.deviceNum = res.data - // } - // }).catch(error => { - // console.error("Error fetching area data:", error); - // }); - // }, changeidx(ids) { this.statusidx = ids this.getmarks() @@ -518,7 +490,6 @@ if (res.code == 200) { this.latitude = res.data.latitude this.longitude = res.data.longitude - // this.areaInfo = res.data const polylines = this.convertBoundaryToPolyline(res.data.boundaryStr) this.polyline.push(polylines) setTimeout(() => { @@ -547,42 +518,38 @@ fillColor: "#FFD1CF40", strokeColor: "#FFC107" } - }; - - if (!colorMap[num]) { - console.error("Invalid type number:", num); - return []; } - + if (!colorMap[num]) { + console.error("Invalid type number:", num) + return [] + } return boundaries.map(boundary => { - if (!boundary) return null; - let coords; + if (!boundary) return null + let coords try { - coords = JSON.parse(boundary); + coords = JSON.parse(boundary) } catch (error) { - console.error("Error parsing boundary JSON:", error); - return null; + console.error("Error parsing boundary JSON:", error) + return null } if (!Array.isArray(coords)) { - console.error("Parsed boundary is not an array:", coords); - return null; + console.error("Parsed boundary is not an array:", coords) + return null } const points = coords.map(coord => ({ latitude: parseFloat(coord[1]), longitude: parseFloat(coord[0]) - })); + })) return { points: points, fillColor: colorMap[num].fillColor, strokeColor: colorMap[num].strokeColor, strokeWidth: 2, //描边宽度 zIndex: 1, //层级 - }; - }).filter(polyline => polyline !== null); // 过滤掉无效的折线数据 - + } + }).filter(polyline => polyline !== null) // 过滤掉无效的折线数据 }, markstause() { - // console.log(this.status9, 'aaaaaaa'); this.status0.forEach(item => { this.markers.push({ id: parseFloat(item.id), @@ -591,7 +558,6 @@ // title: item.deviceName, width: 30, height: 34, - // iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u6jBvj7S50FPgsHaHXai', iconPath: item.onlineStatus == 0 ? 'https://lxnapi.ccttiot.com/bike/img/static/uQRng4QNKA38Amk8Wgt5' : 'https://lxnapi.ccttiot.com/bike/img/static/uocjFo8Ar2BJVpzC2G2f', @@ -639,12 +605,10 @@ longitude: parseFloat(item.longitude), // title: item.deviceName, width: 30, - height: 34, iconPath: item.onlineStatus == 0 ? 'https://lxnapi.ccttiot.com/bike/img/static/uR3DQEssiK62ovhh88y8' : 'https://lxnapi.ccttiot.com/bike/img/static/u460R1NKWHEpHbt0U4H7', - // iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/um0qXpcbA32WdwqtHbxy', callout: { content: '' + parseInt(item.remainingPower) + '%', // 修改为你想要显示的文字内容 color: '#2679D1', // 修改为文字颜色 @@ -668,7 +632,6 @@ iconPath: item.onlineStatus == 0 ? 'https://lxnapi.ccttiot.com/bike/img/static/uG13E7BpUFF44wVYC9no' : 'https://lxnapi.ccttiot.com/bike/img/static/uHQIdWCTmtUztl49wBKU', - // iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/ur1ZrncDJ1WwuPJeiMG6', callout: { content: '' + parseInt(item.remainingPower) + '%', // 修改为你想要显示的文字内容 color: '#2679D1', // 修改为文字颜色 @@ -692,7 +655,6 @@ iconPath: item.onlineStatus == 0 ? 'https://lxnapi.ccttiot.com/bike/img/static/uRod2zf3t9dAOYafWoWt' : 'https://lxnapi.ccttiot.com/bike/img/static/uZpXq3TBtM5gVgJJeImY', - // iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/uN4ksL0Z2HM4C07fKEOF', callout: { content: '' + parseInt(item.remainingPower) + '%', // 修改为你想要显示的文字内容 color: '#2679D1', // 修改为文字颜色 @@ -716,7 +678,6 @@ iconPath: item.onlineStatus == 0 ? 'https://lxnapi.ccttiot.com/bike/img/static/uhZudZM3nEKj0tYKlho2' : 'https://lxnapi.ccttiot.com/bike/img/static/ujur6TezvPf4buFAqPHo', - // iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/uxbI6ZclpS3WQCfPO1zr', callout: { content: '' + parseInt(item.remainingPower) + '%', // 修改为你想要显示的文字内容 color: '#2679D1', // 修改为文字颜色 @@ -739,7 +700,6 @@ iconPath: item.onlineStatus == 0 ? 'https://lxnapi.ccttiot.com/bike/img/static/ucBKG3ebYRAToVweJihu' : 'https://lxnapi.ccttiot.com/bike/img/static/uyK7Vg4Lu8xb3oNVuG2l', - // iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/uYIFwg5IJ4Axh7TfJ7q6', callout: { content: '' + parseInt(item.remainingPower) + '%', // 修改为你想要显示的文字内容 color: '#ffffff', // 修改为文字颜色 @@ -784,8 +744,7 @@ this.status8 = [] this.status9 = [] this.status6 = [] - console.log(this.rangeValue,'020202'); - if (this.statusidx != 7 && this.statusidx != 9 && this.statusidx != 10) { + if (this.statusidx != 7 && this.statusidx != 20 && this.statusidx != 10) { this.$u.get(`/bst/device/all?areaId=${this.areaId}&status=${this.statusidx}&powerRange=${this.rangeValue[0] + ',' + this.rangeValue[1]}&refresh=true`).then((res) => { //查询所有车辆信息 if (res.code == 200) { this.showmap = true @@ -839,8 +798,8 @@ this.markstause() } }) - } else if (this.statusidx == 9 || this.statusidx == 10) { - this.$u.get(`/bst/device/all?areaId=${this.areaId}&onlineStatus=${this.statusidx == 9 ? 0 : 1}&powerRange=${this.rangeValue[0] + ',' + this.rangeValue[1]}&refresh=true`).then((res) => { + } else if (this.statusidx == 20 || this.statusidx == 10) { + this.$u.get(`/bst/device/all?areaId=${this.areaId}&onlineStatus=${this.statusidx == 20 ? 0 : 1}&powerRange=${this.rangeValue[0] + ',' + this.rangeValue[1]}&refresh=true`).then((res) => { if (res.code == 200) { this.showmap = true this.listData = res.data @@ -874,15 +833,12 @@ let added = false for (let i = 0; i < this.clusters.length; i++) { const cluster = this.clusters[i] - const distance = this.calculateDistance(cluster.latitude, cluster.longitude, marker - .latitude, marker.longitude) + const distance = this.calculateDistance(cluster.latitude, cluster.longitude, marker.latitude, marker.longitude) if (distance < this.clusterRadius) { // 合并到现有聚合 cluster.markers.push(marker) - cluster.latitude = (cluster.latitude * cluster.markers.length + marker.latitude) / ( - cluster.markers.length + 1) - cluster.longitude = (cluster.longitude * cluster.markers.length + marker.longitude) / ( - cluster.markers.length + 1) + cluster.latitude = (cluster.latitude * cluster.markers.length + marker.latitude) / (cluster.markers.length + 1) + cluster.longitude = (cluster.longitude * cluster.markers.length + marker.longitude) / (cluster.markers.length + 1) added = true break } @@ -938,11 +894,7 @@ longitude: parseFloat(row.longitude), width: 20, height: 29, - iconPath: row.type == 1 ? - 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : - row.type == 2 ? - 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : - 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', + iconPath: row.type == 1 ? 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : row.type == 2 ? 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', callout: { content: row.name, color: '#ffffff', diff --git a/page_shanghu/guanli/admin_worke.vue b/page_shanghu/guanli/admin_worke.vue index 55eda3d..b43efa7 100644 --- a/page_shanghu/guanli/admin_worke.vue +++ b/page_shanghu/guanli/admin_worke.vue @@ -231,9 +231,9 @@ export default { }, computed: { - userId() { - return this.$store.getters.userId - }, + // userId() { + // return this.$store.getters.userId + // }, // 添加过滤后的列表计算属性 filteredList() { if (!this.searchKey) return this.list diff --git a/page_shanghu/guanli/device_detail.vue b/page_shanghu/guanli/device_detail.vue index 7495aa2..10d1a91 100644 --- a/page_shanghu/guanli/device_detail.vue +++ b/page_shanghu/guanli/device_detail.vue @@ -91,14 +91,8 @@ 续航:{{deviceInfos.remainEndurance == null ? '--' : deviceInfos.remainEndurance}} km - - 轨迹 @@ -440,7 +434,7 @@ onLoad(e) { this.sn = e.id this.deviceInfo() - this.deptId = uni.getStorageSync('deptId'); + this.deptId = uni.getStorageSync('deptId') }, onShow() { this.getyunying() @@ -570,18 +564,38 @@ xBlufi.notifySendCustomData({ customData: "11open@" }) + uni.showToast({ + title: '发送成功', + icon: 'success', + duration: 2000 + }) } else if (num == 2) { xBlufi.notifySendCustomData({ customData: "11close@" }) + uni.showToast({ + title: '发送成功', + icon: 'success', + duration: 2000 + }) }else if (num == 3) { xBlufi.notifySendCustomData({ customData: "11reboot@" }) + uni.showToast({ + title: '发送成功', + icon: 'success', + duration: 2000 + }) } else { xBlufi.notifySendCustomData({ customData: "11play1@" }) + uni.showToast({ + title: '发送成功', + icon: 'success', + duration: 2000 + }) } }, getlanya() { @@ -670,8 +684,6 @@ } }, - - // 静音 btnjingyin() { this.shengyin = true @@ -858,7 +870,7 @@ uni.showLoading({ title: '加载中...' }) - console.log('点击了....1'); + console.log('点击了....1') this.$u.put('/bst/device/iot/unlock?id=' + this.sn).then((res) => { if (res.code == 200) { // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 @@ -881,7 +893,7 @@ uni.showLoading({ title: '加载中...' }) - console.log('点击了....2'); + console.log('点击了....2') this.$u.put('/bst/device/iot/lock?id=' + this.sn).then((res) => { if (res.code == 200) { // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 @@ -1088,13 +1100,6 @@ } this.deviceInfos = res.data this.mac = res.data.mac - // if (res.data.onlineStatus == 0) { - // } - // if (res.data.isSound == 0) { - // this.jytxt = '关' - // } else { - // this.jytxt = '开' - // } if (this.getnum == 0) { this.getArea() } @@ -1294,7 +1299,6 @@ console.error("Parsed boundary is not an array:", coords) return null } - console.log(coords, '1111111'); const points = coords.map(coord => ({ latitude: coord[1], longitude: coord[0] @@ -1360,8 +1364,7 @@ strokeColor: "#FFC107", //描边颜色 strokeWidth: 2, //描边宽度 zIndex: 1, //层级 - - }; + } }).filter(polyline => polyline !== null) // 过滤掉无效的折线数据 } }, @@ -1436,8 +1439,6 @@ this.polyline = this.polyline.concat(polylines1) this.polyline = this.polyline.concat(polylines) this.parkingList = res.data - // console.log(this.polyline); - } }).catch(error => { console.error("Error fetching parking data:", error) @@ -1666,7 +1667,6 @@ justify-content: space-between; padding-bottom: 13rpx; box-sizing: border-box; - .lt{ font-weight: 600; font-size: 30rpx; @@ -1692,7 +1692,6 @@ display: inline-block; width: 104rpx; height: 42rpx; - // background: #DBFDD6; border-radius: 6rpx 6rpx 6rpx 6rpx; text-align: center; line-height: 42rpx; @@ -1711,7 +1710,6 @@ left: 72rpx; top: 628rpx; width: 610rpx; - // height: 282rpx; background: #FFFFFF; border-radius: 30rpx 30rpx 30rpx 30rpx; z-index: 110; @@ -1908,7 +1906,6 @@ &.active { background: #ECF5FF; border: 2rpx solid #4C97E7; - &::after { content: ''; position: absolute; diff --git a/page_shanghu/guanli/order_detail.vue b/page_shanghu/guanli/order_detail.vue index 3af59cd..67b3f3b 100644 --- a/page_shanghu/guanli/order_detail.vue +++ b/page_shanghu/guanli/order_detail.vue @@ -1149,7 +1149,7 @@ title: res.msg, icon: 'none', duration: 2000 - }); + }) } }) } else if (num == 4) { diff --git a/page_shanghu/guanli/yunying.vue b/page_shanghu/guanli/yunying.vue index 39d7507..2c36d6d 100644 --- a/page_shanghu/guanli/yunying.vue +++ b/page_shanghu/guanli/yunying.vue @@ -23,7 +23,7 @@ ¥{{infoobj.balance == null ? '0.00' : (Number(infoobj.balance) + Number(waitDivideAmount)).toFixed(2)}} - 累积提现:{{successAmount == null ? '¥0.00' : '¥' + successAmount.toFixed(2)}} + 累积提现:{{successAmount == null ? '¥0.00' : '¥' + Number(successAmount).toFixed(2)}} @@ -401,7 +401,7 @@ this.$u.get(`/getInfo`).then(res => { if (res.code == 200) { this.infoobj = res.user - this.successAmount = res.stat.withdraw.successAmount == null ? 0 : res.stat.withdraw.successAmount + this.successAmount = res.stat.withdraw.successAmount == null ? 0 : Number(res.stat.withdraw.successAmount) this.waitDivideAmount = res.stat.bonus.waitDivideAmount == null ? 0 : res.stat.bonus.waitDivideAmount this.gettongji() this.getqb() diff --git a/pages/index/index.vue b/pages/index/index.vue index fb96bf6..6b3219c 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -191,12 +191,12 @@ type: 'gcj02', // 国内地图更兼容 isHighAccuracy: true, success: (res) => { - console.log('精确坐标:', res); + console.log('精确坐标:', res) }, fail: (err) => { - console.error('获取位置失败:', err); + console.error('获取位置失败:', err) } - }); + }) }, // 分享到好友(会话) onShareAppMessage: function() { @@ -229,9 +229,6 @@ uni.navigateTo({ url: '/' + this.tiaozhuanlist[e].url }) - // uni.navigateTo({ - // url:'/page_user/zhaoshang' - // }) } }, // 点击显示客服 @@ -337,14 +334,16 @@ this.$u.get("/app/notice/new?noticeType=1").then(res =>{ if(res.code == 200){ this.announcements = res.data - this.$u.get(`/app/notice/${res.data.noticeId}`).then(resp =>{ - if(resp.code == 200){ - this.gonggaoxq = resp.data - if(resp.data.noticeId != uni.getStorageSync('noticeId')){ - this.gonggaoflag = true + if(res.data){ + this.$u.get(`/app/notice/${res.data.noticeId}`).then(resp =>{ + if(resp.code == 200){ + this.gonggaoxq = resp.data + if(resp.data.noticeId != uni.getStorageSync('noticeId')){ + this.gonggaoflag = true + } } - } - }) + }) + } } }) }, diff --git a/pages/myorder/returned/index.vue b/pages/myorder/returned/index.vue index e9e1ca2..5c8c8c5 100644 --- a/pages/myorder/returned/index.vue +++ b/pages/myorder/returned/index.vue @@ -241,7 +241,7 @@ onShow() { setTimeout(()=>{ if(this.ver_dataflag == 3){ - console.log('11'); + console.log('11') }else{ xBlufi.initXBlufi(1) xBlufi.notifyStartDiscoverBle({ @@ -253,12 +253,12 @@ setTimeout(() => { this.getorderdevice() }, 100) - this.executeTask(); + this.executeTask() // 启动每分钟(60秒)执行一次的定时器 this.timer = setInterval(() => { - this.executeTask(); - }, 30000); + this.executeTask() + }, 30000) xBlufi.notifyConnectBle({ isStart: false, deviceId: this.deviceId, @@ -271,7 +271,7 @@ if (this.findDeviceTimer) { clearTimeout(this.findDeviceTimer) this.findDeviceTimer = null - console.log('清除定时器1'); + console.log('清除定时器1') } }, onUnload() { @@ -280,12 +280,12 @@ if (this.findDeviceTimer) { clearTimeout(this.findDeviceTimer) this.findDeviceTimer = null - console.log('清除定时器2'); + console.log('清除定时器2') } }, // 组件销毁时清除定时器 beforeDestroy() { - clearTimeout(this.uploadTimer); + clearTimeout(this.uploadTimer) }, methods: { // 点击咨询客服 @@ -330,9 +330,9 @@ if (res.data) { this.mac = res.data.deviceMac if(this.ver_dataflag != 3){ - console.log('离线离线'); + console.log('离线离线') setTimeout(()=>{ - console.log('11ly',this.ljflag); + console.log('11ly',this.ljflag) if(this.ljflag == true){ this.ljflag = false this.findDevice() @@ -428,7 +428,6 @@ dataStr.split(',').forEach(part => { const [key, value] = part.split(':').map(item => item.trim()); if (!key || value === undefined) return; - switch (key) { case 'status': dataObj.status = value; break; case 'bat': dataObj.bat = parseFloat(value); break; @@ -438,8 +437,7 @@ case 'q': dataObj.q = parseInt(value); break; case 's': dataObj.s = parseInt(value); break; } - }); - + }) // 2. 获取定位 uni.getLocation({ type: 'gcj02', @@ -449,16 +447,16 @@ ...dataObj, lon: res.longitude, lat: res.latitude - }); + }) }, fail: () => { this.submitData({ ...dataObj, lon: 0, lat: 0 - }); + }) } - }); + }) }, // 3. 单独封装数据提交 @@ -474,64 +472,46 @@ lon: Number(data.lon) || 0, lat: Number(data.lat) || 0 } - }; + } this.bluetoothData = payload - // console.log('提交数据:', payload); this.throttledUpload() - // 4. 带错误处理的上传 - // this.$u.put('/app/device/iot/bltUpload', payload) - // .then(res => { - // if (res.code !== 200) throw new Error(res.msg); - // console.log('上传成功'); - // }) - // .catch(err => { - // console.error('上传失败:', err); - // // uni.showToast({ title: err.message, icon: 'none' }); - // }); + }, + // 节流上传控制 + throttledUpload() { + const now = Date.now() + const throttleInterval = 10000 // 10秒 + // 清除之前的定时器 + clearTimeout(this.uploadTimer) + // 如果距离上次上传超过10秒且没有正在上传的请求 + if (now - this.lastUploadTime >= throttleInterval && !this.isUploading) { + this.doUpload() + } else { + // 否则设置定时器,在剩余时间后执行 + const remainingTime = throttleInterval - (now - this.lastUploadTime) + this.uploadTimer = setTimeout(() => { + this.doUpload() + }, remainingTime) + } }, - // 节流上传控制 - throttledUpload() { - const now = Date.now(); - const throttleInterval = 10000; // 10秒 - - // 清除之前的定时器 - clearTimeout(this.uploadTimer); - - // 如果距离上次上传超过10秒且没有正在上传的请求 - if (now - this.lastUploadTime >= throttleInterval && !this.isUploading) { - this.doUpload(); - } else { - // 否则设置定时器,在剩余时间后执行 - const remainingTime = throttleInterval - (now - this.lastUploadTime); - this.uploadTimer = setTimeout(() => { - this.doUpload(); - }, remainingTime); - } - }, - - // 实际执行上传 - doUpload() { - if (!this.bluetoothData || this.isUploading) return; - - this.isUploading = true; - this.lastUploadTime = Date.now(); - console.log(this.bluetoothData,'this.bluetoothDatathis.bluetoothData'); - this.$u.put(`/app/device/iot/bltUpload`, this.bluetoothData) - .then(res => { + // 实际执行上传 + doUpload() { + if (!this.bluetoothData || this.isUploading) return + this.isUploading = true + this.lastUploadTime = Date.now() + console.log(this.bluetoothData,'this.bluetoothDatathis.bluetoothData') + this.$u.put(`/app/device/iot/bltUpload`, this.bluetoothData).then(res => { if(res.code == 200) { - console.log('上传蓝牙数据成功',this.bluetoothData, new Date().toLocaleTimeString()); + console.log('上传蓝牙数据成功',this.bluetoothData, new Date().toLocaleTimeString()) } else { - console.log('上传蓝牙数据失败', res.msg); + console.log('上传蓝牙数据失败', res.msg) } - }) - .catch(err => { - console.error('上传异常:', err); - }) - .finally(() => { - this.isUploading = false; - }); - }, + }).catch(err => { + console.error('上传异常:', err) + }).finally(() => { + this.isUploading = false + }) + }, // 点击启动and关闭 btnqd() { @@ -541,12 +521,12 @@ isHighAccuracy: true, accuracy:'best', success: (res) => { - console.log('精确坐标:', res); - this.lslat = res.latitude; - this.lslon = res.longitude; + console.log('精确坐标:', res) + this.lslat = res.latitude + this.lslon = res.longitude }, fail: (err) => { - console.error('获取位置失败:', err); + console.error('获取位置失败:', err) this.lat = null this.lon = null } @@ -558,6 +538,10 @@ showCancel: true, success: function(res) { if (res.confirm) { + uni.showLoading({ + title: '加载中...', + mask: true + }) let flag = '' if(that.ver_dataflag == 3){ flag = false @@ -575,7 +559,7 @@ customData: "11open@" }) that.deivceobj.deviceLockStatus = 1 - + uni.hideLoading() let data = { mac:that.mac, reason:'解锁', @@ -586,6 +570,7 @@ } that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) } else { + uni.hideLoading() let that = this uni.showModal({ title: '提示', @@ -621,6 +606,7 @@ that.getorderdevice() } } else if(res.code == 20001){ + uni.hideLoading() uni.showModal({ title: '提示', content: '设备未连接,请靠近车辆等待连接', @@ -634,6 +620,7 @@ } }) } else { + uni.hideLoading() uni.showToast({ title: res.msg, icon: 'none', @@ -642,7 +629,7 @@ } }) } else if (res.cancel) { - console.log('取消'); // 用户点击取消 + console.log('取消') // 用户点击取消 } } }) @@ -652,14 +639,14 @@ isHighAccuracy: true, accuracy:'best', success: (res) => { - console.log('精确坐标:', res); + console.log('精确坐标:', res) this.lat = res.latitude this.lon = res.longitude }, fail: (err) => { this.lat = null this.lon = null - console.error('获取位置失败:', err); + console.error('获取位置失败:', err) } }) let that = this @@ -675,16 +662,20 @@ showCancel: true, success: function(res) { if (res.confirm) { + uni.showLoading({ + title: '加载中...', + mask: true + }) that.$u.put(`/app/order/closeDevice?orderId=${that.deivceobj.orderId}&lat=${that.lat}&lon=${that.lon}&requiredIot=${flag}`).then((res) => { if (res.code == 200 && res.data.db >= 1) { if(res.data.iot == false){ - console.log(that.ver_dataflag,'thatthat'); + console.log(that.ver_dataflag,'thatthat') if (that.ver_dataflag == 3) { xBlufi.notifySendCustomData({ customData: "11llose@", }) that.deivceobj.deviceLockStatus = 0 - + uni.hideLoading() let data = { mac:that.mac, reason:'临时锁车', @@ -694,9 +685,10 @@ result:'成功' } that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { - console.log(res,'蓝牙'); + console.log(res,'蓝牙') }) } else { + uni.hideLoading() let that = this uni.showModal({ title: '提示', @@ -719,10 +711,11 @@ result:'蓝牙未连接' } that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { - console.log(res,'蓝牙'); + console.log(res,'蓝牙') }) } }else{ + uni.hideLoading() uni.showToast({ title: '临时锁车成功', icon: 'success', @@ -732,6 +725,7 @@ that.getorderdevice() } } else if(res.code == 20001){ + uni.hideLoading() uni.showModal({ title: '提示', content: '设备未连接,请靠近车辆等待连接', @@ -745,6 +739,7 @@ } }) } else { + uni.hideLoading() uni.showToast({ title: res.msg, icon: 'none', @@ -753,7 +748,7 @@ } }) } else if (res.cancel) { - console.log('取消'); // 用户点击取消 + console.log('取消') // 用户点击取消 } } }) @@ -761,8 +756,13 @@ }, // 点击鸣笛寻车 btnfm() { + uni.showLoading({ + title: '加载中...', + mask: true + }) this.$u.put(`/app/device/iot/ring?id=${this.deivceobj.deviceId}`).then((res) => { if (res.code == 200) { + uni.hideLoading() uni.showToast({ title: '操作成功', icon: 'success', @@ -770,10 +770,12 @@ }) } else if (res.code == 20001) { if (this.ver_dataflag == 3) { + uni.hideLoading() xBlufi.notifySendCustomData({ customData: "11play1@" }) } else { + uni.hideLoading() let that = this uni.showModal({ title: '提示', @@ -789,6 +791,7 @@ }) } } else { + uni.hideLoading() uni.showToast({ title: res.msg, icon: 'none', @@ -859,13 +862,13 @@ isHighAccuracy: true, accuracy:'best', success: (res) => { - console.log('精确坐标:', res); - this.lat = res.latitude; - this.lon = res.longitude; - this.getfeiyong(); + console.log('精确坐标:', res) + this.lat = res.latitude + this.lon = res.longitude + this.getfeiyong() }, fail: (err) => { - console.error('获取位置失败:', err); + console.error('获取位置失败:', err) this.lat = null this.lon = null this.getfeiyong() // 降级处理 @@ -909,7 +912,7 @@ // 计算时间差(毫秒) const diffMs = futureDate - now // 将毫秒转换为天、小时、分钟和秒 - const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)) const diffHours = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) const diffMinutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60)) const diffSeconds = Math.floor((diffMs % (1000 * 60)) / 1000) @@ -953,6 +956,10 @@ showCancel: true, success: function(res) { if (res.confirm) { + uni.showLoading({ + title: '还车中...', + mask: true + }) let data = { orderId: that.deivceobj.orderId, picture: that.imgs, @@ -978,6 +985,7 @@ customData: "11close@" }) setTimeout(()=>{ + uni.hideLoading() xBlufi.notifyConnectBle({ isStart: false, deviceId: that.deviceId, @@ -1027,6 +1035,10 @@ showCancel: true, success: function(res) { if (res.confirm) { + uni.showLoading({ + title: '还车中...', + mask: true + }) let data = { orderId: that.deivceobj.orderId, picture: that.imgs, @@ -1057,6 +1069,7 @@ customData: "11llose@" }) setTimeout(()=>{ + uni.hideLoading() that.getorderdevice() },1000) } diff --git a/pages/nearbystores/index.vue b/pages/nearbystores/index.vue index b972cb9..cdcadbe 100644 --- a/pages/nearbystores/index.vue +++ b/pages/nearbystores/index.vue @@ -315,7 +315,6 @@ uni.getLocation({ type: 'wgs84', success: (res) => { - console.log(res,'1212121'); this.xllat = res.latitude this.xllng = res.longitude }, @@ -338,14 +337,14 @@ }, onUnload() { this.clearTimer() - this.isPageActive = false; - this.closeWebSocket(); + this.isPageActive = false + this.closeWebSocket() }, onHide() { this.clearTimer() // 页面隐藏时关闭连接 - this.isPageActive = false; - this.closeWebSocket(); + this.isPageActive = false + this.closeWebSocket() }, methods: { // 拖动查询中心点的数据 @@ -376,9 +375,9 @@ parseFloat(item.latitude), parseFloat(item.longitude) ); - return distance <= 100; + return distance <= 100 } - return false; + return false }); // 更新 circles 数组来绘制淡灰色的圆形区域 this.circles = [{ @@ -389,17 +388,14 @@ radius: 100, // 圆的半径(单位:米) strokeWidth: 1 }] - console.log(nearbyMarkers,this.listData,'000'); - this.nearbyMarkers = nearbyMarkers; + this.nearbyMarkers = nearbyMarkers }, haversineDistance(lat1, lon1, lat2, lon2) { const R = 6371e3 // Earth radius in meters const toRad = angle => angle * Math.PI / 180 const dLat = toRad(lat2 - lat1) const dLon = toRad(lon2 - lon1) - const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * - Math.sin(dLon / 2) * Math.sin(dLon / 2) + const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2) const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) return R * c }, @@ -424,19 +420,18 @@ }, startTimer() { this.timer = setInterval(() => { - this.count++; - console.log(`定时器执行,当前计数: ${this.count}`); + this.count++ // 这里替换为你的实际逻辑 this.setMapScale() - }, 5000); + }, 5000) }, // 清除定时器 clearTimer() { if (this.timer) { - clearInterval(this.timer); - this.timer = null; - console.log("定时器已清除"); + clearInterval(this.timer) + this.timer = null + console.log("定时器已清除") } }, btnjjqx(){ @@ -445,27 +440,27 @@ }, //WebSocket 自动重连实现 initWebSocket() { - if (!this.isPageActive || !this.deviceMac) return; - let token = uni.getStorageSync('token'); + if (!this.isPageActive || !this.deviceMac) return + let token = uni.getStorageSync('token') // 关闭已有连接 if (this.socketTask) { - this.socketTask.close(); - this.socketTask = null; + this.socketTask.close() + this.socketTask = null } // 创建新连接 this.socketTask = uni.connectSocket({ url: `wss://ele.ccttiot.com/prod-api/ws/device?token=${token}&mac=${this.deviceMac}`, success: () => { - console.log('WebSocket连接建立中...'); + console.log('WebSocket连接建立中...') }, fail: (err) => { - console.error('WebSocket连接失败:', err); - this.scheduleReconnect(); + console.error('WebSocket连接失败:', err) + this.scheduleReconnect() } }); // 监听连接打开 this.socketTask.onOpen(() => { - console.log('WebSocket连接已打开'); + console.log('WebSocket连接已打开') this.reconnectAttempts = 0; // 重置重连计数器 // 发送订阅消息(如果需要) this.socketTask.send({ @@ -474,61 +469,55 @@ }), success: () => console.log('订阅消息发送成功'), fail: (err) => console.error('订阅消息发送失败:', err) - }); - }); + }) + }) // 监听消息接收 this.socketTask.onMessage((res) => { - console.log('收到实时消息:', res.data); - this.messages.push(res.data); // 存储消息 + console.log('收到实时消息:', res.data) + this.messages.push(res.data) // 存储消息 try { - const data = JSON.parse(res.data); - console.log('解析后的JSON数据:', data); + const data = JSON.parse(res.data) + console.log('解析后的JSON数据:', data) // 这里可以处理具体的业务逻辑 this.sockedata = data - // this.getqingqiu() - // this.$u.get(`/app/device/listNearBy?radius=10000¢er=${this.jingweidu}`).then((res) => { - // if (res.code == 200) { - this.covers = [] - const newMarkers = [] - this.parkingList.forEach(item => { - newMarkers.push({ - id: parseFloat(item.id), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - width: 40, - height: 60, - iconPath: item.type == 1 ? - 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : - item.type == 2 ? - 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : - 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', - callout: { - content: item.name, - color: '#ffffff', - fontSize: 14, - borderRadius: 10, - bgColor: item.type == 1 ? '#3A7EDB' : item.type == 2 ? '#FF473E' : - '#FFC107', - padding: 6, - display: 'ALWAYS' - }, - isCalloutVisible: true // 添加标记 - }) - }) - this.newMarkers = newMarkers - this.$set(this, 'covers', [...this.covers, ...newMarkers]) - // this.$set(this, 'covers', [...this.covers, ...this.newMarkers]) - if(this.sockedata.latitude){ - this.covers.push({ - latitude: this.sockedata.latitude, - longitude: this.sockedata.longitude, - width: 8, - height: 8, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', - }) - } - // } - // }) + this.covers = [] + const newMarkers = [] + this.parkingList.forEach(item => { + newMarkers.push({ + id: parseFloat(item.id), + latitude: parseFloat(item.latitude), + longitude: parseFloat(item.longitude), + width: 40, + height: 60, + iconPath: item.type == 1 ? + 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : + item.type == 2 ? + 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : + 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', + callout: { + content: item.name, + color: '#ffffff', + fontSize: 14, + borderRadius: 10, + bgColor: item.type == 1 ? '#3A7EDB' : item.type == 2 ? '#FF473E' : + '#FFC107', + padding: 6, + display: 'ALWAYS' + }, + isCalloutVisible: true // 添加标记 + }) + }) + this.newMarkers = newMarkers + this.$set(this, 'covers', [...this.covers, ...newMarkers]) + if(this.sockedata.latitude){ + this.covers.push({ + latitude: this.sockedata.latitude, + longitude: this.sockedata.longitude, + width: 8, + height: 8, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', + }) + } this.covers.push({ latitude: data.latitude, longitude: data.longitude, @@ -537,52 +526,51 @@ iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', }) } catch (e) { - console.log('原始消息内容:', res.data); + console.log('原始消息内容:', res.data) } }); // 监听错误 this.socketTask.onError((err) => { - console.error('WebSocket错误:', err); - this.scheduleReconnect(); + console.error('WebSocket错误:', err) + this.scheduleReconnect() }); // 监听连接关闭 this.socketTask.onClose((res) => { - console.log('WebSocket连接已关闭', res); + console.log('WebSocket连接已关闭', res) if (this.isPageActive) { - this.scheduleReconnect(); + this.scheduleReconnect() } - }); + }) }, // 关闭WebSocket连接 closeWebSocket() { if (this.socketTask) { this.socketTask.close({ success: () => { - console.log('WebSocket已主动关闭'); - this.socketTask = null; + console.log('WebSocket已主动关闭') + this.socketTask = null }, fail: (err) => { - console.error('WebSocket关闭失败:', err); - this.socketTask = null; + console.error('WebSocket关闭失败:', err) + this.socketTask = null } - }); + }) } }, // 安排重连 scheduleReconnect() { if (!this.isPageActive || this.reconnectAttempts >= this.maxReconnectAttempts) { - console.log('已达到最大重连次数或页面已关闭,停止重连'); - return; + console.log('已达到最大重连次数或页面已关闭,停止重连') + return } this.reconnectAttempts++; - console.log(`尝试第 ${this.reconnectAttempts} 次重连,等待 ${this.reconnectInterval/1000} 秒...`); + console.log(`尝试第 ${this.reconnectAttempts} 次重连,等待 ${this.reconnectInterval/1000} 秒...`) setTimeout(() => { - this.initWebSocket(); - }, this.reconnectInterval); + this.initWebSocket() + }, this.reconnectInterval) // 指数退避策略,增加重连间隔 - this.reconnectInterval = Math.min(this.reconnectInterval * 2, 30000); // 最大不超过30秒 + this.reconnectInterval = Math.min(this.reconnectInterval * 2, 30000) // 最大不超过30秒 }, - // 点击结束订单 btnjsdd() { if (this.orderAreaReturnVerify == true) { @@ -594,7 +582,6 @@ type: 'gcj02', // 国内地图更兼容 isHighAccuracy: true, success: (res) => { - console.log(res); this.latsc = res.latitude this.lonsc = res.longitude this.getfeiyong() @@ -755,7 +742,6 @@ uni.getLocation({ type: 'wgs84', success: (res) => { - console.log(res); this.latsc = res.latitude this.lngsc = res.longitude }, @@ -841,16 +827,12 @@ if (this.orderAreaId == '') { this.covers.filter(item => { if (item.id == id) { - // item.iconPath = 'https://api.ccttiot.com/smartmeter/img/static/uCBNaRAdk9kcgQgrom2G' this.taocanflag = true this.$u.get(`/app/device/availableDetail?id=${id.slice(0, -1)}`).then((res) => { if (res.code == 200) { this.cheobj = res.data this.areaId = res.data.areaId this.getArea() - setTimeout(()=>{ - // this.getqingqiu() - },1000) } }) } @@ -938,7 +920,6 @@ btncheyc() { this.taocanflag = false this.newMarkers = '' - // this.getqingqiu() }, // 点击选择骑行套餐 @@ -1052,7 +1033,6 @@ } } this.covers.push(shopCover) - console.log('111112222'); }) } }) @@ -1313,7 +1293,9 @@ this.user = res.user this.$u.get(`/app/area/nearby?id=${res.user.areaId == null ? '' : res.user.areaId}&radius=1000¢er=${this.jingweidu}`).then((resp) => { if (resp.code == 200) { - this.yyid = resp.data.id + if(resp.data){ + this.yyid = resp.data.id + } if(resp.data && resp.data.boundaryStr) { const polylines = this.convertBoundaryToPolyline(resp.data.boundaryStr) if(polylines) {