From 486da8d5ea54385d486a4dce57526262307f7368 Mon Sep 17 00:00:00 2001 From: Sliverber <2622874537@qq.com> Date: Sat, 22 Jun 2024 18:06:23 +0800 Subject: [PATCH] 111 --- common/http.interceptor.js | 31 +- manifest.json | 2 +- page_user/khfw/khfw.vue | 83 ++++ pages.json | 18 + pages/bind_mac.vue | 712 ++++++++++++++++++++++++++++ pages/bind_sn.vue | 37 +- pages/index/index.vue | 321 +++++++------ pages/my.vue | 59 ++- pages_admin/admin_worke.vue | 63 +-- pages_admin/order/search_device.vue | 2 +- 10 files changed, 1108 insertions(+), 220 deletions(-) create mode 100644 page_user/khfw/khfw.vue create mode 100644 pages/bind_mac.vue diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 1dfae6c..6617cfe 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -23,8 +23,8 @@ const install = (Vue, vm) => { // baseUrl: 'http://61.174.243.28:15861', // baseUrl: 'http://192.168.2.14:8080', // baseUrl: 'http://124.221.246.124:2289', - baseUrl: 'https://dianche.chuantewulian.cn/prod-api', - // baseUrl: 'https://dche.ccttiot.com/prod-api', + // baseUrl: 'https://dianche.chuantewulian.cn/prod-api', + baseUrl: 'https://dche.ccttiot.com/prod-api', loadingText: '努力加载中~', // loadingTime: 2000, // 设置自定义头部content-type @@ -86,32 +86,7 @@ const install = (Vue, vm) => { // // return res.result; // } if(res.code == 401) { - // res为服务端返回值,可能有code,result等字段 - // 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到 - // 如果配置了originalData为true,请留意这里的返回值 - - // return res.result; - - // uni.login({ - // success: function(ret) { - // console.log("main.js==>res", ret) - // // vm.$u.post('/user/login',{"js_code": ret.code}).then(res=>{ - // // if (res.code == 10003) { - // // // console.log("新用户登录") - // // uni.setStorageSync('token', res.data); - - // // } else if (res.code == 200) { - // // // console.log("老用户登录",res.data) - // // uni.setStorageSync('token', res.data); - - // // } - // // }); - // } - // }); - // uni.showLoading({ - // title: '登录中...', - // mask: true // Set to true if you want to prevent user interactions while loading - // }); + wx.login({ success(res) { if (res.code) { diff --git a/manifest.json b/manifest.json index 8d15cb5..cad1f86 100644 --- a/manifest.json +++ b/manifest.json @@ -51,7 +51,7 @@ /* 小程序特有相关 */ "mp-weixin" : { "libVersion" : "latest", - "appid" : "wx4d178f8c80348214", + "appid" : "wx3428c498d5061192", "setting" : { "urlCheck" : false }, diff --git a/page_user/khfw/khfw.vue b/page_user/khfw/khfw.vue new file mode 100644 index 0000000..50de600 --- /dev/null +++ b/page_user/khfw/khfw.vue @@ -0,0 +1,83 @@ + + + + + \ No newline at end of file diff --git a/pages.json b/pages.json index 9d775db..84d384b 100644 --- a/pages.json +++ b/pages.json @@ -37,6 +37,15 @@ "enablePullDownRefresh": false, "navigationStyle": "custom" } + }, + { + "path" : "pages/bind_mac", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } } @@ -337,6 +346,15 @@ "enablePullDownRefresh" : false, "navigationStyle": "custom" } + }, + { + "path" : "khfw/khfw", + "style" : + { + "navigationBarTitleText" : "", + "enablePullDownRefresh" : false, + "navigationStyle": "custom" + } } // 其他 userpages 目录下的页面... diff --git a/pages/bind_mac.vue b/pages/bind_mac.vue new file mode 100644 index 0000000..26a87b3 --- /dev/null +++ b/pages/bind_mac.vue @@ -0,0 +1,712 @@ + + + + + \ No newline at end of file diff --git a/pages/bind_sn.vue b/pages/bind_sn.vue index aa9e135..4f309b9 100644 --- a/pages/bind_sn.vue +++ b/pages/bind_sn.vue @@ -21,8 +21,11 @@ MAC:{{item.localName.substring(5)}} - + + + 选择 @@ -30,9 +33,9 @@ - + @@ -92,6 +95,9 @@ if(e.sn){ this.sn=e.sn } + this.bluthlist = [] + this.devicesList = [] + this.devicesLists=[] xBlufi.initXBlufi(1); console.log("xBlufi", xBlufi.XMQTT_SYSTEM); xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); @@ -116,6 +122,10 @@ }, onShow: function() { // this.openBluetoothAdapter() + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); }, onUnload: function() { xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); @@ -140,6 +150,13 @@ // this.videoContext = uni.createVideoContext('myVideo', this) }, methods: { + choose(e){ + console.log(e); + let Bluetoothmac = e.name.substring(5) + uni.navigateTo({ + url:'/pages/bind_mac?mac='+Bluetoothmac + }) + }, send(){ this.$u.post('/app/device/ring?sn=' + this.sn).then((res) => { if (res.code === 200) { @@ -227,7 +244,7 @@ if (options.result) { let devicesarr = options.data // this.devicesList = options.data - console.log(devicesarr, 'devicesarrdevicesarr'); + // console.log(devicesarr, 'devicesarrdevicesarr'); devicesarr.forEach(device => { const mac = device.name.substring(6); @@ -310,7 +327,7 @@ }); if (this.devicesList.length == 0) { this.tishiflag = true - this.texts = '扫描完毕,暂无发现浇花器设备' + this.texts = '扫描完毕,暂无发现电动车设备' } else { this.texts = '扫描到以下设备,请点击连接!' } @@ -337,6 +354,13 @@ // console.log(macFromName); // 与 this.mac 进行比较 list.push(device) + // this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { + // if (res.data == false) { + // list.push(device) + // } else { + + // } + // }) }); setTimeout(() => { @@ -556,6 +580,7 @@ // 重新搜索清空蓝牙数组 this.bluthlist = [] this.devicesList = [] + this.devicesLists=[] // 重新搜索 // this.startBluetoothDevicesDiscovery() this.statusflag = true @@ -573,6 +598,7 @@ xBlufi.notifyStartDiscoverBle({ 'isStart': false }); + } else { xBlufi.notifyStartDiscoverBle({ @@ -787,6 +813,7 @@ } .rt { + margin-left: auto; margin-top: 22rpx; text { diff --git a/pages/index/index.vue b/pages/index/index.vue index fc7ac80..cfba857 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,12 +3,12 @@ - - 嵛你出行 + 创享出行 + @@ -49,9 +49,12 @@ 剩余骑行 - + {{deviceInfos.remainingMileage}}公里 + + --公里 + @@ -90,18 +93,28 @@ 剩余骑行 - + + + {{deviceInfos.remainingMileage}}公里 + + + --公里 剩余电量 - + {{ deviceInfos.remainingPower}}% + + -- + + @@ -574,7 +587,7 @@ polyline: [], areas: [], gps: { - deptId: 101 + deptId: 100 }, deviceInfos: {}, OrderdeviceInfos: {}, @@ -615,6 +628,7 @@ showxy: false, countdown: 5, // 五秒倒计时 // userId:this.$store.getters.userId, + qParam: null } }, watch: { @@ -631,41 +645,8 @@ onLoad(e) { console.log(e, 'eeeeeeeeeeeeeeeeeee'); if (e.q) { - let qParam = e.q; + this.qParam = e - // 第2步: URL解码q参数 - let decodedUrl = decodeURIComponent(qParam); - - // 第3步: 使用正则表达式解析解码后的URL并提取查询参数 - let sn = null; - let queryParams = decodedUrl.split('?')[1]; - if (queryParams) { - let params = queryParams.split('&'); - params.forEach(param => { - let [key, value] = param.split('='); - if (key === 'sn') { - sn = value; - } - }); - } - this.sn = sn - if (this.sn != '') { - - - setTimeout(() => { - - if (!this.orderinfo.status) { - this.deviceInfo(1) - // this.showdevice = true - // this.deviceIndex = 1 - // this.type = 1 - } else { - // this.showtcs=true - } - }, 500) - - - } } if (e.sn) { @@ -713,6 +694,44 @@ that.longitude = Number(lb.longitude.toFixed(5)) + 0.005 console.log(that.areaInfo, 'that.areaInfo'); that.getArea() + if (that.qParam) { + let qParam = that.qParam.q; + + // 第2步: URL解码q参数 + let decodedUrl = decodeURIComponent(qParam); + + // 第3步: 使用正则表达式解析解码后的URL并提取查询参数 + let sn = null; + let queryParams = decodedUrl.split('?')[1]; + if (queryParams) { + let params = queryParams.split('&'); + params.forEach(param => { + let [key, value] = param.split('='); + if (key === 'sn') { + sn = value; + } + }); + } + that.sn = sn + if (that.sn != '') { + + + setTimeout(() => { + + if (!that.orderinfo.status) { + that.deviceInfo(1) + that.qParam = null + // this.showdevice = true + // this.deviceIndex = 1 + // this.type = 1 + } else { + // this.showtcs=true + } + }, 500) + + + } + } // that.getmarks() @@ -844,77 +863,7 @@ } }, - toggleIconAndCallout() { - this.showIconAndCallout = !this.showIconAndCallout; - if (this.showIconAndCallout) { - const newMarkers = []; - this.parkingList.forEach(item => { - if(item.type==1){ - newMarkers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#3A7EDB', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS' // 修改为气泡的显示策略 - } - }); - }else if(item.type==2){ - newMarkers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#FFC107', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS' // 修改为气泡的显示策略 - } - }); - }else if(item.type==3){ - newMarkers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#FF473E', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS' // 修改为气泡的显示策略 - } - }); - } - - }); - console.log(this.parkingList,'newMarkersnewMarkersnewMarkers'); - this.$set(this, 'markers', [...this.markers, ...newMarkers]); - } else { - const parkingIds = this.parkingList.map(item => parseFloat(item.parkingId)); - this.$set(this, 'markers', this.markers.filter(marker => !parkingIds.includes(marker.id))); - } - - }, getMyLocation() { uni.createMapContext("map", this).moveToLocation({ longitude: this.longitude, @@ -1209,9 +1158,28 @@ this.timer = null this.$u.get('/app/device/info?sn=' + this.orderinfo.sn).then((res) => { if (res.code === 200) { - this.OrderdeviceInfos = res.data + // 直接从OrderdeviceInfos对象创建一个新的标记,并标记为设备特定标记 + const newMarker = { + id: parseFloat(this.OrderdeviceInfos.sn), + latitude: parseFloat(this.OrderdeviceInfos.latitude), + longitude: parseFloat(this.OrderdeviceInfos.longitude), + width: 40, + height: 28, + isDeviceMarker: true, // 添加标识属性 + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uF9qLejuAZErNTrRuHq7', + }; + + // 保留显示气泡的标记和设备特定标记 + const preservedMarkers = this.markers.filter(marker => marker.isCalloutVisible || marker.isDeviceMarker); + // 使用单个新标记更新markers数组,如果需要保留之前的标记也可以加入 + this.markers = [newMarker, ...preservedMarkers]; + this.oldMarkers = [...this.markers]; + } else { + // 处理接口返回错误的情况 } - }) + }).catch(error => { + // 处理接口请求失败的情况 + }); // 预约中 @@ -2321,6 +2289,12 @@ icon: 'none', duration: 4000 }); + } else if (this.deviceInfos.status == 7) { + uni.showToast({ + title: '车辆未上线,请使用其他车辆', + icon: 'none', + duration: 4000 + }); } else if (this.deviceInfos.status == 1) { this.showdevice = true; this.type = 1; @@ -2357,7 +2331,7 @@ uni.setStorageSync('token', res.token); this.$u.get('/app/device/info?sn=' + this.sn).then(( - res) => { + res) => { if (res.code === 200) { this.deviceInfos = res.data; @@ -2414,6 +2388,13 @@ icon: 'none', duration: 4000 }); + } else if (this.deviceInfos.status == + 7) { + uni.showToast({ + title: '车辆未上线,请使用其他车辆', + icon: 'none', + duration: 4000 + }); } else if (this.deviceInfos.status == 1) { this.showdevice = true; @@ -2452,16 +2433,47 @@ }); } }, - + toggleIconAndCallout() { + this.showIconAndCallout = !this.showIconAndCallout; + if (this.showIconAndCallout) { + const newMarkers = []; + this.parkingList.forEach(item => { + newMarkers.push({ + id: parseFloat(item.parkingId), + latitude: parseFloat(item.latitude), + longitude: parseFloat(item.longitude), + width: 20, + height: 40, + iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', + callout: { + content: item.parkingName, + color: '#ffffff', + fontSize: 14, + borderRadius: 10, + bgColor: item.type == 1 ? '#3A7EDB' : item.type == 2 ? '#FFC107' : + '#FF473E', + padding: 6, + display: 'ALWAYS' + }, + isCalloutVisible: true // 添加标记 + }); + }); + this.$set(this, 'markers', [...this.markers, ...newMarkers]); + } else { + // 过滤掉所有气泡显示的标记 + this.$set(this, 'markers', this.markers.filter(marker => !marker.isCalloutVisible)); + } + + }, + getmarks() { let data = { areaId: this.areaInfo.areaId }; if (this.areaInfo.areaId) { this.$u.get(`/app/allVehicleByArea`, data).then((res) => { - if (res.code === 200) { + if (res.code === 200 && res.data != '') { this.listData = res.data; - const newMarkers = this.listData.map(item => ({ id: parseFloat(item.sn), latitude: parseFloat(item.latitude), @@ -2471,21 +2483,21 @@ iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uF9qLejuAZErNTrRuHq7', })); - // 检查新数据和旧数据是否有变化 - if (this.oldMarkers.length === 0 || this.isMarkersChanged(newMarkers)) { - // console.log('有变化'); - this.markers = newMarkers; - this.oldMarkers = [...newMarkers]; - } - - } else { - // 处理接口返回错误的情况 + // 保留显示气泡的标记 + const preservedMarkers = this.markers.filter(marker => marker.isCalloutVisible || marker.isDeviceMarker); + + // 假设newMarkers是从新数据生成的标记数组 + // 更新markers数组,避免删除已标识的重要标记 + this.markers = [...newMarkers.filter(newMarker => + !preservedMarkers.some(preservedMarker => preservedMarker.id === newMarker.id) + ), ...preservedMarkers]; + + this.oldMarkers = [...this.markers]; } }).catch(error => { // 处理接口请求失败的情况 }); } - }, isMarkersChanged(newMarkers) { if (this.oldMarkers.length !== newMarkers.length) { @@ -2628,7 +2640,7 @@ console.error("Error fetching area data:", error); }); }, - + getParking() { // 发送请求获取数据 // this.polyline=[] @@ -2653,21 +2665,21 @@ }); const validBoundaries = type1Data.map(row => row.boundaryStr).filter(boundary => typeof boundary === 'string' && boundary.trim() !== ''); - const polylines = this.convertBoundaryToPolylines(validBoundaries,1); - - + const polylines = this.convertBoundaryToPolylines(validBoundaries, 1); + + const validBoundaries1 = type2Data.map(row => row.boundaryStr).filter(boundary => typeof boundary === 'string' && boundary.trim() !== ''); - const polylines1 = this.convertBoundaryToPolylines(validBoundaries1,2); - + const polylines1 = this.convertBoundaryToPolylines(validBoundaries1, 2); + const validBoundaries2 = type3Data.map(row => row.boundaryStr).filter(boundary => typeof boundary === 'string' && boundary.trim() !== ''); - const polylines2 = this.convertBoundaryToPolylines(validBoundaries2,3); + const polylines2 = this.convertBoundaryToPolylines(validBoundaries2, 3); // 将处理后的数据添加到 this.polyline 中 - this.polyline = this.polyline.concat(polylines2); + this.polyline = this.polyline.concat(polylines2); this.polyline = this.polyline.concat(polylines1); this.polyline = this.polyline.concat(polylines); - this.parkingList=res.rows + this.parkingList = res.rows // console.log(this.polyline); } }).catch(error => { @@ -2692,8 +2704,8 @@ return polyline; }, - convertBoundaryToPolylines(boundaries,num) { - if(num==1){ + convertBoundaryToPolylines(boundaries, num) { + if (num == 1) { console.log('判断1'); return boundaries.map(boundary => { if (!boundary) return null; @@ -2718,10 +2730,10 @@ strokeColor: "#3A7EDB", //描边颜色 strokeWidth: 2, //描边宽度 zIndex: 1, //层级 - + }; }).filter(polyline => polyline !== null); // 过滤掉无效的折线数据 - }else if(num==2){ + } else if (num == 2) { return boundaries.map(boundary => { if (!boundary) return null; let coords; @@ -2745,10 +2757,10 @@ strokeColor: "#FFC107", //描边颜色 strokeWidth: 2, //描边宽度 zIndex: 1, //层级 - + }; }).filter(polyline => polyline !== null); // 过滤掉无效的折线数据 - }else if(num==3){ + } else if (num == 3) { return boundaries.map(boundary => { if (!boundary) return null; let coords; @@ -2772,14 +2784,14 @@ strokeColor: "#FF473E", //描边颜色 strokeWidth: 2, //描边宽度 zIndex: 1, //层级 - + }; }).filter(polyline => polyline !== null); // 过滤掉无效的折线数据 } - + }, }, - + }