From fbb956aecff6ddafce7f2f53d32739d6d09dbfd3 Mon Sep 17 00:00:00 2001 From: Sliverber <2622874537@qq.com> Date: Fri, 21 Jun 2024 18:03:21 +0800 Subject: [PATCH] 11 --- common/http.interceptor.js | 6 +- components/tab-bar/tab-bar.vue | 14 +- manifest.json | 2 +- page_fix/fix_index.vue | 75 +++- page_fix/repair/repair_detail.vue | 408 ++++++++++++++++++++ page_user/good_list.vue | 3 +- page_user/xcjs.vue | 73 +++- pages/index/index.vue | 114 +++--- pages/my.vue | 17 +- pages_admin/admin_index.vue | 143 ++++--- pages_admin/admin_order.vue | 205 +++++----- pages_admin/order/device_detail.vue | 527 +++++++++++++++++++++++++- pages_admin/order/order_detail.vue | 207 ++++++++-- pages_admin/worke/woke_deviceMgmt.vue | 16 +- 14 files changed, 1523 insertions(+), 287 deletions(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index ef3583b..1dfae6c 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -21,10 +21,10 @@ const install = (Vue, vm) => { // }); Vue.prototype.$u.http.setConfig({ // baseUrl: 'http://61.174.243.28:15861', - // baseUrl: 'http://192.168.2.6:8080', + // 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 diff --git a/components/tab-bar/tab-bar.vue b/components/tab-bar/tab-bar.vue index 2ae89bc..bfffae2 100644 --- a/components/tab-bar/tab-bar.vue +++ b/components/tab-bar/tab-bar.vue @@ -48,6 +48,7 @@ }, methods:{ changeTabbar(index) { + let that =this if (this.currentTabbarIndex === index) return // this._switchTabbarPage(index) @@ -57,7 +58,7 @@ url:'/pages_admin/admin_worke', routeType: 'wx://modal', success() { - this.currentTabbarIndex = index + that.currentTabbarIndex = index } }) console.log('点击了',index); @@ -66,7 +67,7 @@ url:'/pages_admin/admin_index', routeType: 'wx://modal', success() { - this.currentTabbarIndex = index + that.currentTabbarIndex = index } }) }else if(index==2){ @@ -74,7 +75,7 @@ url:'/pages_admin/admin_order', routeType: 'wx://modal', success() { - this.currentTabbarIndex = index + that.currentTabbarIndex = index } }) } @@ -96,16 +97,17 @@ } .cont { + padding: 15rpx 0 30rpx; position: fixed; // left: 60rpx; bottom: 0rpx; width: 750rpx; - height: 150rpx; + height: 130rpx; background: #FFFFFF; box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(53, 140, 255, 0.1); // border-radius: 60rpx; display: flex; - align-items: center; + // align-items: center; justify-content: space-around; border-top: 2rpx solid #95989D; .tab{ @@ -120,7 +122,7 @@ .txt{ text-align: center; width: 100%; - margin-top: 10rpx; + margin-top: 4rpx; font-size: 20rpx; font-family: HarmonyOS Sans SC, HarmonyOS Sans SC; font-weight: 400; diff --git a/manifest.json b/manifest.json index cad1f86..8d15cb5 100644 --- a/manifest.json +++ b/manifest.json @@ -51,7 +51,7 @@ /* 小程序特有相关 */ "mp-weixin" : { "libVersion" : "latest", - "appid" : "wx3428c498d5061192", + "appid" : "wx4d178f8c80348214", "setting" : { "urlCheck" : false }, diff --git a/page_fix/fix_index.vue b/page_fix/fix_index.vue index b39991c..384a6a4 100644 --- a/page_fix/fix_index.vue +++ b/page_fix/fix_index.vue @@ -87,7 +87,7 @@ }); }, getmarks() { - this.$u.get(`/appVerify/adminOrder/list?adminId=` + 2).then((res) => { + this.$u.get(`/appVerify/adminOrder/list?adminId=` + this.userId).then((res) => { if (res.code == 200) { console.log('调用了'); this.listData = res.rows; @@ -287,24 +287,61 @@ // console.log(this.polyline); res.rows.forEach(item => { - this.markers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - // title: item.deviceName, - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#000000', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS', // 修改为气泡的显示策略 - } - }) + if(item.type==1){ + this.markers.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){ + this.markers.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){ + this.markers.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' // 修改为气泡的显示策略 + } + }); + } }) setTimeout(()=>{ diff --git a/page_fix/repair/repair_detail.vue b/page_fix/repair/repair_detail.vue index 1a475db..32fcf82 100644 --- a/page_fix/repair/repair_detail.vue +++ b/page_fix/repair/repair_detail.vue @@ -241,6 +241,18 @@ <view class="btn" @click="btn(4)"> 响铃寻车 </view> + <view class="btn" @click="Binddevice()"> + 蓝牙链接 + </view> + <view class="btn" @click="open()" v-if="carstause"> + 蓝牙开锁 + </view> + <view class="btn" @click="close()" v-if="carstause"> + 蓝牙关锁 + </view> + <view class="btn" @click="reboot()" v-if="carstause"> + 设备重启 + </view> <view class="btn" @click="tipshow=true" v-if="info.type==1"> 维修处理 </view> @@ -290,9 +302,39 @@ </template> <script> + const app = getApp(); + var xBlufi = require("@/utils/blufi/xBlufi.js"); + let _this = null; export default { data() { return { + devicesList: [ + // {name:'110000', + // mac:'11111'} + ], + searching: false, + texts: '正在扫描蓝牙设备...', + btnflag: true, + tishiflag: false, + option: '', + bluthlist: [], //蓝牙数组 + // status: 'loading', + statusflag: false, + Bluetoothmac: '', + mac: '', + ishave: false, + ver_data: null, + deviceInfoss: {}, + gps: {}, + isband: false, + // status: false, + deviceIds: '', + name: '', + orderinfo: {}, + dl: 0, + czmoney:true, + iscz:true, + bgc: { backgroundColor: "#fff", }, @@ -334,6 +376,371 @@ } }, methods: { + Binddevice(){ + uni.showLoading({ + title:'连接中..' + }) + xBlufi.initXBlufi(1); + console.log("xBlufi", xBlufi.XMQTT_SYSTEM); + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + + + // 两秒后停止蓝牙搜索 + setTimeout(() => { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + setTimeout(()=>{ + uni.hideLoading() + if (this.devicesList.length == 0) { + uni.showToast({ + title: '暂无发现对应设备,请靠近设备', + icon: 'none' + }); + } else { + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 将去重后的数组重新赋值给 this.devicesList + this.devicesList = uniqueDevicesList; + console.log(this.devicesList,'this.devicesListthis.devicesList'); + this.devicesList.forEach(device => { + // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) + let macFromName = device.name.substring(device.name.length - 12); + console.log(macFromName,'macFromNamemacFromName'); + // 与 this.mac 进行比较 + if (macFromName == this.mac) { + // 如果相同,则将 this.ishave 设置为 true + console.log(device); + this.deviceInfoss = device + // this.ishave = true; + this.createBLEConnection(device) + + console.log('对比正确1111111111'); + } else { + console.log('对比错误'); + + } + }); + } + },200) + // 判断是否存在浇花器设备 + + // this.status = true + }, 2000) + + }, + reboot(){ + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11reboot" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + open(){ + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11open" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + close(){ + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11close" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + + btnyc() { + this.titleflag = false + }, + + // 解析自定义数据 + + funListenDeviceMsgEvent: function(options) { + switch (options.type) { + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: + if (options.result) { + let devicesarr = options.data + // this.devicesList = options.data + + devicesarr.forEach(device => { + + + // this.$u.get(`/app/device/${mac}/isBind`, data).then((res) => { + // if (res.data == false) { + 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.hideLoading(); + uni.showToast({ + title: '连接成功', + icon: 'none' + }); { + + xBlufi.notifyInitBleEsp32({ + deviceId: options.data.deviceId + }); + + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents); + + this.deviceIds = options.data.deviceId + this.name = options.data.name + // 连接成功绑定设备 + // let params = { + // mac: this.Bluetoothmac, + // userId: this.$store.state.user.userId + // } + let systemInfo = uni.getSystemInfoSync(); + if (systemInfo.platform === 'android') { + // 当前设备是 Android + + } else if (systemInfo.platform === 'ios') { + // 当前设备是 iOS + // uni.navigateTo({ + // url: '/pages/wifilist/index?deviceId=' + options + // .data.deviceId + '&name=' + options.data.name + // }) + } + } + } + + break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: + + // this.ver_data = this.parseCustomData(options.data) + if(options.data){ + this.carstause=true + } + // console.log("1收到设备发来的自定义数据结果:", this.ver_data); + break; + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: + if (options.result) { + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 过滤出名称字段的前五个字母为 "CTPOW" 的项 + let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) === + "BBLE"); + + // 将过滤后的数组重新赋值给 this.devicesList + this.devicesList = filteredDevices; + + // console.log('蓝牙停止搜索ok',this.devicesList); + } else { + //蓝牙停止搜索失败 + // console.log('蓝牙停止搜索失败'); + } + this.searching = false + // _this.setData({ + // searching: false + // }); + + break; + } + }, + + + //4、建立连接 + createBLEConnection(e) { + console.log('调用了'); + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + console.log(e, '蓝牙信息') + const 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 + }); + // for (var i = 0; i < this.devicesList.length; i++) { + // if (e.deviceId === this.devicesList[i].deviceId) { + + // uni.showLoading({ + // title: '连接蓝牙设备中...' + // }); + // } + // } + }, + // 点击重新搜索 + Search() { + if (this.status) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + // 重新搜索清空蓝牙数组 + this.bluthlist = [] + this.devicesList = [] + // 重新搜索 + // this.startBluetoothDevicesDiscovery() + this.statusflag = true + this.status = false + this.texts = '正在扫描蓝牙设备...' + setTimeout(() => { + this.statusflag = false + this.status = true + if (this.searching) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + // 判断是否存在浇花器设备 + if (this.devicesList.length == 0) { + uni.showToast({ + title: '暂无发现对应设备,请靠近设备', + icon: 'none' + }); + } else { + this.texts = '扫描到以下设备,请点击连接!' + } + } else { + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + } + }, 2000) + } + + + }, + funListenDeviceMsgEvents: function(options) { + let that = this; + switch (options.type) { + case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: { + console.log('状态', options.result) + if( options.result==false){ + this.carstause=false + uni.showToast({ + title: '设备断开链接,请重新点击蓝牙链接', + icon: 'none' + }); + // uni.showModal({ + // title: '很抱歉提醒你!', + // content: '小程序与设备异常断开', + // showCancel: false, + // success: function(res) { + // // uni.navigateBack({ + // // url: '../search/search' + // // }); + // } + // }); + // this.statusflag = false + uni.hideLoading(); + } + } + break; + + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA: + this.loadPercent = options.data; + this.loadText = '文件读取中' + console.log("文件读取中", options.data); + break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: + // this.isband = true + // this.ver_data = this.parseCustomData(options.data) + console.log("1收到设备发来的自定义数据结果:", options.data); + if(options.data){ + this.carstause=true + } + break; + + case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT: + uni.hideLoading(); + if (options.result) { + console.log('初始化成功'); + } else { + console.log('初始化失败'); + + + } + break; + } + }, + // 点击隐藏没有设备提示 + btnhd() { + this.tishiflag = false + }, + + + + + + + btn(num){ if(num==0){ this.$u.post('/appVerify/admin/unlocking?sn='+this.info.sn).then((res) => { @@ -394,6 +801,7 @@ this.$u.get(`/appVerify/adminOrder/` + this.id).then((res) => { if (res.code == 200) { this.info=res.data + this.mac=res.data.mac this.latitude=parseFloat(this.info.device.latitude) this.longitude=parseFloat(this.info.device.longitude) this.historyList() diff --git a/page_user/good_list.vue b/page_user/good_list.vue index df25036..94ad931 100644 --- a/page_user/good_list.vue +++ b/page_user/good_list.vue @@ -30,6 +30,7 @@ {{item.totalFee}}元 </view> </view> + </view> </template> @@ -47,7 +48,7 @@ computedList() { return this.list.map(item => { const createTime = new Date(item.createTime); - const payTime = new Date(item.payTime); + const payTime = new Date(item.returnTime); const timeDifference = Math.abs(createTime - payTime); const hours = Math.floor(timeDifference / (1000 * 60 * 60)); diff --git a/page_user/xcjs.vue b/page_user/xcjs.vue index 0a54937..06de7cd 100644 --- a/page_user/xcjs.vue +++ b/page_user/xcjs.vue @@ -292,24 +292,61 @@ // console.log(this.polyline); res.rows.forEach(item => { - this.markers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - // title: item.deviceName, - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#000000', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS', // 修改为气泡的显示策略 - } - }) + if(item.type==1){ + this.markers.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){ + this.markers.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){ + this.markers.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' // 修改为气泡的显示策略 + } + }); + } }) } }).catch(error => { diff --git a/pages/index/index.vue b/pages/index/index.vue index f01d94e..fc7ac80 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,12 +3,12 @@ <view class="tab_top"> <image src="https://lxnapi.ccttiot.com/bike/img/static/uVcMTydm81zCMhHomXl1" mode="" @click="topage(6)"> </image> - <view class="txts"> - 创享出行 - </view> <!-- <view class="txts"> - 嵛你出行 + 创享出行 </view> --> + <view class="txts"> + 嵛你出行 + </view> </view> <!-- <u-navbar :is-back="false" title="共享电动车" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36' height='36'></u-navbar> --> @@ -574,7 +574,7 @@ polyline: [], areas: [], gps: { - deptId: 100 + deptId: 101 }, deviceInfos: {}, OrderdeviceInfos: {}, @@ -700,10 +700,6 @@ let abb = uni.getStorageSync('role') } - - - - let that = this uni.getLocation({ type: 'wgs84', @@ -853,24 +849,64 @@ 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: '#000000', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS' // 修改为气泡的显示策略 - } - }); + 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)); @@ -2416,10 +2452,7 @@ }); } }, - // onMapTap(e) { - // console.log('点击了地图非标记区域:', e); - // // 这里可以根据需要处理点击地图非标记区域的逻辑 - // }, + getmarks() { let data = { areaId: this.areaInfo.areaId @@ -2595,24 +2628,7 @@ console.error("Error fetching area data:", error); }); }, - // getArea() { - // // 发送请求获取数据 - // this.$u.get('/app/area/list',this.gps).then((res) => { - // if (res.code === 200) { - // // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 - // const polylines = res.rows - // .filter(area => area.boundaryStr) // 过滤掉boundary为空的数据 - // .map(area => this.convertBoundaryToPolyline(area.boundaryStr)); - // // 更新折线数据 - // this.polyline = polylines; - // this.getlist() - // // console.log(this.polyline); - // } - // }).catch(error => { - // console.error("Error fetching area data:", error); - // }); - // }, - + getParking() { // 发送请求获取数据 // this.polyline=[] @@ -2651,7 +2667,7 @@ this.polyline = this.polyline.concat(polylines2); this.polyline = this.polyline.concat(polylines1); this.polyline = this.polyline.concat(polylines); - + this.parkingList=res.rows // console.log(this.polyline); } }).catch(error => { diff --git a/pages/my.vue b/pages/my.vue index 1880518..31d4044 100644 --- a/pages/my.vue +++ b/pages/my.vue @@ -237,11 +237,20 @@ // } } else { + let areaId=uni.getStorageSync('areaId'); + if(areaId){ + setTimeout(()=>{ + this.getuserInfo() + // if() + },500) + }else{ + uni.showToast({ + title: '请授权位置信息后再尝试', + icon: 'none', + duration: 4000 + }); + } - setTimeout(()=>{ - this.getuserInfo() - // if() - },500) } }); } diff --git a/pages_admin/admin_index.vue b/pages_admin/admin_index.vue index ba9b803..8468bad 100644 --- a/pages_admin/admin_index.vue +++ b/pages_admin/admin_index.vue @@ -146,7 +146,7 @@ }, statusidx: 7, deviceNum: {}, - + areaId:0, } @@ -159,13 +159,12 @@ // 执行其他操作... }); - - - this.getArea() - - this.getordernum() - this.allVehicleNum() + + this.getareaid() + + + let that = this uni.getLocation({ type: 'wgs84', @@ -204,6 +203,26 @@ }, }, methods: { + getareaid(){ + this.$u.post('/appVerify/getAreaId').then((res) => { + if (res.code == 200) { + // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 + // this.areaId=res.data + this.areaId=14 + this.getArea() + + this.allVehicleNum() + // console.log(this.polyline); + }else{ + this.areaId=14 + this.getArea() + + this.allVehicleNum() + } + }).catch(error => { + + }); + }, async setMapScale(e, val) { let mapContext = uni.createMapContext('map', this); let setScale = () => { @@ -267,7 +286,8 @@ allVehicleNum() { let data = { powerStart: this.rangeValue[0], - powerEnd: this.rangeValue[1] + powerEnd: this.rangeValue[1], + areaId: this.areaId } this.$u.get('/appVerify/allVehicleNum?', data).then((res) => { if (res.code === 200) { @@ -410,7 +430,7 @@ this.status9.forEach(item => { this.markers.push({ - id: parseFloat(item.mac), + id: parseFloat(item.sn), latitude: parseFloat(item.latitude), longitude: parseFloat(item.longitude), // title: item.deviceName, @@ -604,26 +624,14 @@ }, - // topage() { - // uni.navigateTo({ - // url: '/page_fix/repair/repair_index' - // }) - // }, - getordernum() { - // 发送请求获取数据 - this.$u.get('/appVerify/adminOrder/num?adminId=' + 2).then((res) => { - if (res.code === 200) { - // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 - this.infonum = res.data - // console.log(this.polyline); - } - }).catch(error => { - console.error("Error fetching area data:", error); - }); - }, + + getArea() { // 发送请求获取数据 - this.$u.get('/app/area/list').then((res) => { + let data = { + areaId: this.areaId + } + this.$u.get('/app/area/list?',data).then((res) => { if (res.code === 200) { // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 const polylines = res.rows @@ -762,26 +770,63 @@ console.log(this.polyline, 'this.polyline'); // console.log(this.polyline); res.rows.forEach(item => { - this.markers.push({ - id: item.parkingId, - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - // title: item.deviceName, - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#000000', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS', // 修改为气泡的显示策略 - } - }) + if(item.type==1){ + this.markers.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){ + this.markers.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){ + this.markers.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' // 修改为气泡的显示策略 + } + }); + } }) - + } }).catch(error => { console.error("Error fetching parking data:", error); @@ -821,14 +866,14 @@ display: flex; flex-wrap: wrap; align-items: center; - padding: 22rpx 28rpx; + padding: 10rpx 28rpx; .cont:nth-child(5n) { margin-right: 0; } .cont { - margin-top: 18rpx; + margin-top: 8rpx; margin-right: 9rpx; // display: flex; width: 130rpx; @@ -899,7 +944,7 @@ .map { width: 750rpx; - height: 850rpx; + height: 50vh; } diff --git a/pages_admin/admin_order.vue b/pages_admin/admin_order.vue index b6eecca..1f2446b 100644 --- a/pages_admin/admin_order.vue +++ b/pages_admin/admin_order.vue @@ -80,8 +80,11 @@ <view class="half_info_li"> 车辆编号:{{item.sn}} </view> - <view class="half_info_li"> - 租赁时长:{{item.duration/60}}分钟 + <view class="half_info_li" v-if="item.returnTime"> + 租赁时长:{{computedList(item)}} + </view> + <view class="half_info_li" v-else> + 租赁时长:-- </view> </view> <view class="info_li"> @@ -147,8 +150,11 @@ <view class="half_info_li"> 车辆编号:{{item.sn}} </view> - <view class="half_info_li"> - 租赁时长:{{item.duration/60}}分钟 + <view class="half_info_li" v-if="item.returnTime"> + 租赁时长:{{computedList(item)}} + </view> + <view class="half_info_li" v-else> + 租赁时长:-- </view> </view> <view class="info_li"> @@ -212,8 +218,11 @@ <view class="half_info_li"> 车辆编号:{{item.sn}} </view> - <view class="half_info_li"> - 租赁时长:{{item.duration/60}}分钟 + <view class="half_info_li" v-if="item.returnTime"> + 租赁时长:{{computedList(item)}} + </view> + <view class="half_info_li" v-else> + 租赁时长:-- </view> </view> <view class="info_li"> @@ -278,8 +287,11 @@ <view class="half_info_li"> 车辆编号:{{item.sn}} </view> - <view class="half_info_li"> - 租赁时长:{{item.duration/60}}分钟 + <view class="half_info_li" v-if="item.returnTime"> + 租赁时长:{{computedList(item)}} + </view> + <view class="half_info_li" v-else> + 租赁时长:-- </view> </view> <view class="info_li"> @@ -386,61 +398,61 @@ </view> </view> <view class="tip_box" v-if="showtk"> - <view class="top"> - <view class="tip"> - 退款 - </view> - - <view class="ipt_box"> - <view class="text"> - 调度费 - </view> - <view class="ipt"> - <input type="text" v-model="orderInfo.dispatchFee" placeholder="0.00" class="input" - placeholder-style="color:#C7CDD3" @input="checkAndUpdate('dispatchFee')"> - 元 - </view> - </view> - <view class="ipt_box"> - <view class="text"> - 管理费 - </view> - <view class="ipt"> - <input type="text" v-model="orderInfo.manageFee" placeholder="0.00" class="input" - placeholder-style="color:#C7CDD3" @input="checkAndUpdate('manageFee')"> - 元 - </view> - </view> - <view class="ipt_box"> - <view class="text"> - 骑行费 - </view> - <view class="ipt"> - <input type="text" v-model="orderInfo.ridingFee" placeholder="0.00" class="input" - placeholder-style="color:#C7CDD3" @input="checkAndUpdate('ridingFee')"> - 元 - </view> - </view> - <view class="ipt_box"> - <view class="text"> - 预约费 - </view> - <view class="ipt"> - <input type="text" v-model="orderInfo.appointmentFee" placeholder="0.00" class="input" - placeholder-style="color:#C7CDD3" @input="checkAndUpdate('appointmentFee')"> - 元 - </view> - </view> - <view class="ipt_box"> - <view class="text"> - 原因 - </view> - <view class="ipt"> - <input type="text" v-model="orderInfo.reason" placeholder="选填" class="input" - placeholder-style="color:#C7CDD3" @input="checkAndUpdate('reason')"> - </view> - </view> - </view> + <view class="top" v-if="showtk"> + <view class="tip"> + 退款 + </view> + + <view class="ipt_box"> + <view class="text"> + 调度费 + </view> + <view class="ipt"> + <input type="text" v-model="orderInfo.dispatchFee" placeholder="0.00" class="input" + placeholder-style="color:#C7CDD3" @input="checkAndUpdate('dispatchFee')"> + 元 + </view> + </view> + <view class="ipt_box"> + <view class="text"> + 管理费 + </view> + <view class="ipt"> + <input type="text" v-model="orderInfo.manageFee" placeholder="0.00" class="input" + placeholder-style="color:#C7CDD3" @input="checkAndUpdate('manageFee')"> + 元 + </view> + </view> + <view class="ipt_box"> + <view class="text"> + 骑行费 + </view> + <view class="ipt"> + <input type="text" v-model="orderInfo.ridingFee" placeholder="0.00" class="input" + placeholder-style="color:#C7CDD3" @input="checkAndUpdate('ridingFee')"> + 元 + </view> + </view> + <view class="ipt_box"> + <view class="text"> + 预约费 + </view> + <view class="ipt"> + <input type="text" v-model="orderInfo.appointmentFee" placeholder="0.00" class="input" + placeholder-style="color:#C7CDD3" @input="checkAndUpdate('appointmentFee')"> + 元 + </view> + </view> + <view class="ipt_box"> + <view class="text"> + 原因 + </view> + <view class="ipt"> + <input type="text" v-model="orderInfo.reason" placeholder="选填" class="input" + placeholder-style="color:#C7CDD3" @input="checkAndUpdate('reason')"> + </view> + </view> + </view> <view class="bot"> <view class="bot_left" @click="closetk()"> 取消 @@ -524,27 +536,41 @@ userId() { return this.$store.getters.userId; }, + }, + computed: { + }, methods: { - toOrderDetail(id){ + computedList(item) { + const createTime = new Date(item.createTime); + const payTime = new Date(item.returnTime); + const timeDifference = Math.abs(createTime - payTime); + + const hours = Math.floor(timeDifference / (1000 * 60 * 60)); + const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); + const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000); + + return `${minutes}分钟${seconds}秒` + }, + toOrderDetail(id) { uni.navigateTo({ - url:'/pages_admin/order/order_detail?id='+id + url: '/pages_admin/order/order_detail?id=' + id }) }, - checkAndUpdate(key) { - clearTimeout(timerId); - timerId = setTimeout(() => { - let inputValue = parseFloat(this.orderInfo[key]); - // Get the initial value corresponding to the key - let initialValue = parseFloat(this.initialValues[key]); - // If input value exceeds the initial value, revert back to initial value - if (inputValue > initialValue) { - this.orderInfo[key] = initialValue; - } - }, 500); - // Convert input value to number - - }, + checkAndUpdate(key) { + clearTimeout(timerId); + timerId = setTimeout(() => { + let inputValue = parseFloat(this.orderInfo[key]); + // Get the initial value corresponding to the key + let initialValue = parseFloat(this.initialValues[key]); + // If input value exceeds the initial value, revert back to initial value + if (inputValue > initialValue) { + this.orderInfo[key] = initialValue; + } + }, 500); + // Convert input value to number + + }, // 退款 backMoney() { let data = { @@ -561,6 +587,7 @@ // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 this.show = false this.showgj = false + this.showtk = false this.orderInfo = {} if (this.curtitidx == 0) { this.orderList() @@ -582,10 +609,10 @@ this.orderInfo = item this.show = true this.showtk = true - this.initialValues.dispatchFee=this.orderInfo .dispatchFee - this.initialValues.manageFee=this.orderInfo .manageFee - this.initialValues.ridingFee=this.orderInfo .ridingFee - this.initialValues.appointmentFee=this.orderInfo .appointmentFee + this.initialValues.dispatchFee = this.orderInfo.dispatchFee + this.initialValues.manageFee = this.orderInfo.manageFee + this.initialValues.ridingFee = this.orderInfo.ridingFee + this.initialValues.appointmentFee = this.orderInfo.appointmentFee }, closetk() { this.show = false @@ -637,7 +664,7 @@ // 还车 backDevice() { this.$u.post('/appVerify/device/return?orderNo=' + this.orderInfo.orderNo + '&returnType=2').then(( - res) => { + res) => { if (res.code === 200) { // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 this.show = false @@ -676,7 +703,7 @@ status: '', startTime: this.firsTime, endTime: this.lasTime, - + } @@ -723,7 +750,7 @@ statusList: '1,3', startTime: this.firsTime, endTime: this.lasTime, - + } this.loading = false @@ -746,7 +773,7 @@ status: '4', startTime: this.firsTime, endTime: this.lasTime, - + @@ -819,10 +846,10 @@ } else if (this.curtitidx == 3) { this.orderList3() } - + }, 500); // 根据关键字过滤 this.classlist - + }, } } diff --git a/pages_admin/order/device_detail.vue b/pages_admin/order/device_detail.vue index 33de973..1aedfb9 100644 --- a/pages_admin/order/device_detail.vue +++ b/pages_admin/order/device_detail.vue @@ -137,6 +137,18 @@ <view class="btn" @click="btn(4)"> 响铃寻车 </view> + <view class="btn" @click="Binddevice()"> + 蓝牙链接 + </view> + <view class="btn" @click="open()" v-if="carstause"> + 蓝牙开锁 + </view> + <view class="btn" @click="close()" v-if="carstause"> + 蓝牙关锁 + </view> + <view class="btn" @click="reboot()" v-if="carstause"> + 设备重启 + </view> <view class="btn" @click="tipshow=true" v-if="info.type==1"> 维修处理 </view> @@ -185,9 +197,41 @@ </template> <script> + const app = getApp(); + var xBlufi = require("@/utils/blufi/xBlufi.js"); + let _this = null; export default { data() { return { + devicesList: [ + // {name:'110000', + // mac:'11111'} + ], + searching: false, + texts: '正在扫描蓝牙设备...', + btnflag: true, + tishiflag: false, + option: '', + bluthlist: [], //蓝牙数组 + // status: 'loading', + statusflag: false, + Bluetoothmac: '', + mac: '', + ishave: false, + ver_data: null, + deviceInfoss: {}, + gps: {}, + isband: false, + // status: false, + deviceIds: '', + name: '', + orderinfo: {}, + dl: 0, + czmoney:true, + iscz:true, + + + bgc: { backgroundColor: "#F7FAFE", }, @@ -203,7 +247,11 @@ polygons: [], cardId: '001区域', sn:'', - deviceInfos:{} + deviceInfos:{}, + carstause:false + + + } }, @@ -212,8 +260,408 @@ this.deviceInfo() this.getArea() + }, + onUnload: function() { + 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({ + 'isStart': false + }); + }, + watch: { + + + }, methods: { + Binddevice(){ + uni.showLoading({ + title:'连接中..' + }) + xBlufi.initXBlufi(1); + console.log("xBlufi", xBlufi.XMQTT_SYSTEM); + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + + + // 两秒后停止蓝牙搜索 + setTimeout(() => { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + setTimeout(()=>{ + uni.hideLoading() + if (this.devicesList.length == 0) { + uni.showToast({ + title: '暂无发现对应设备,请靠近设备', + icon: 'none' + }); + } else { + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 将去重后的数组重新赋值给 this.devicesList + this.devicesList = uniqueDevicesList; + console.log(this.devicesList,'this.devicesListthis.devicesList'); + this.devicesList.forEach(device => { + // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) + let macFromName = device.name.substring(device.name.length - 12); + console.log(macFromName,'macFromNamemacFromName'); + // 与 this.mac 进行比较 + if (macFromName == this.mac) { + // 如果相同,则将 this.ishave 设置为 true + console.log(device); + this.deviceInfoss = device + // this.ishave = true; + this.createBLEConnection(device) + + console.log('对比正确1111111111'); + } else { + console.log('对比错误'); + + } + }); + } + },200) + // 判断是否存在浇花器设备 + + // this.status = true + }, 2000) + + }, + reboot(){ + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11reboot" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + open(){ + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11open" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + close(){ + let vm = this; // 将外部的 this 绑定到 vm 上 + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + console.log('已连接的蓝牙设备信息:', res); + // vm.dl = (vm.orderinfo.deviceAmount / vm.orderinfo.unitPrice).toFixed(2); // 使用 vm 访问 Vue 实例的属性 + xBlufi.notifySendCustomData({ + customData: "11close" + }); + // uni.hideLoading() + // vm.remakr() + }, + fail(err) { + uni.hideLoading() + console.error('获取已连接蓝牙设备信息失败:', err); + } + }); + } else { + console.log('手机未连接网络'); + } + } + }); + }, + + btnyc() { + this.titleflag = false + }, + + // 解析自定义数据 + + funListenDeviceMsgEvent: function(options) { + switch (options.type) { + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: + if (options.result) { + let devicesarr = options.data + // this.devicesList = options.data + + devicesarr.forEach(device => { + + + // this.$u.get(`/app/device/${mac}/isBind`, data).then((res) => { + // if (res.data == false) { + 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.hideLoading(); + uni.showToast({ + title: '连接成功', + icon: 'none' + }); { + + xBlufi.notifyInitBleEsp32({ + deviceId: options.data.deviceId + }); + + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents); + + this.deviceIds = options.data.deviceId + this.name = options.data.name + // 连接成功绑定设备 + // let params = { + // mac: this.Bluetoothmac, + // userId: this.$store.state.user.userId + // } + let systemInfo = uni.getSystemInfoSync(); + if (systemInfo.platform === 'android') { + // 当前设备是 Android + + } else if (systemInfo.platform === 'ios') { + // 当前设备是 iOS + // uni.navigateTo({ + // url: '/pages/wifilist/index?deviceId=' + options + // .data.deviceId + '&name=' + options.data.name + // }) + } + } + } + + break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: + + // this.ver_data = this.parseCustomData(options.data) + if(options.data){ + this.carstause=true + } + // console.log("1收到设备发来的自定义数据结果:", this.ver_data); + break; + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: + if (options.result) { + let uniqueDevicesList = Array.from(new Set(this.devicesList)); + + // 过滤出名称字段的前五个字母为 "CTPOW" 的项 + let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) === + "BBLE"); + + // 将过滤后的数组重新赋值给 this.devicesList + this.devicesList = filteredDevices; + + // console.log('蓝牙停止搜索ok',this.devicesList); + } else { + //蓝牙停止搜索失败 + // console.log('蓝牙停止搜索失败'); + } + this.searching = false + // _this.setData({ + // searching: false + // }); + + break; + } + }, + + + //4、建立连接 + createBLEConnection(e) { + console.log('调用了'); + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + console.log(e, '蓝牙信息') + const 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 + }); + // for (var i = 0; i < this.devicesList.length; i++) { + // if (e.deviceId === this.devicesList[i].deviceId) { + + // uni.showLoading({ + // title: '连接蓝牙设备中...' + // }); + // } + // } + }, + // 点击重新搜索 + Search() { + if (this.status) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + // 重新搜索清空蓝牙数组 + this.bluthlist = [] + this.devicesList = [] + // 重新搜索 + // this.startBluetoothDevicesDiscovery() + this.statusflag = true + this.status = false + this.texts = '正在扫描蓝牙设备...' + setTimeout(() => { + this.statusflag = false + this.status = true + if (this.searching) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }); + // 判断是否存在浇花器设备 + if (this.devicesList.length == 0) { + uni.showToast({ + title: '暂无发现对应设备,请靠近设备', + icon: 'none' + }); + } else { + this.texts = '扫描到以下设备,请点击连接!' + } + } else { + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }); + } + }, 2000) + } + + + }, + funListenDeviceMsgEvents: function(options) { + let that = this; + switch (options.type) { + case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: { + console.log('状态', options.result) + if( options.result==false){ + this.carstause=false + uni.showToast({ + title: '设备断开链接,请重新点击蓝牙链接', + icon: 'none' + }); + // uni.showModal({ + // title: '很抱歉提醒你!', + // content: '小程序与设备异常断开', + // showCancel: false, + // success: function(res) { + // // uni.navigateBack({ + // // url: '../search/search' + // // }); + // } + // }); + // this.statusflag = false + uni.hideLoading(); + } + } + break; + + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA: + this.loadPercent = options.data; + this.loadText = '文件读取中' + console.log("文件读取中", options.data); + break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: + // this.isband = true + // this.ver_data = this.parseCustomData(options.data) + console.log("1收到设备发来的自定义数据结果:", options.data); + if(options.data){ + this.carstause=true + } + break; + + case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT: + uni.hideLoading(); + if (options.result) { + console.log('初始化成功'); + } else { + console.log('初始化失败'); + + + } + break; + } + }, + // 点击隐藏没有设备提示 + btnhd() { + this.tishiflag = false + }, + + + + + + + + + + + + + + + + + + + btn(num){ if(num==0){ this.$u.post('/appVerify/admin/unlocking?sn='+this.sn).then((res) => { @@ -283,6 +731,7 @@ this.$u.get('/app/device/info?sn=' + this.sn).then((res) => { if (res.code === 200) { this.deviceInfos = res.data + this.mac=res.data.mac this.latitude= parseFloat(this.deviceInfos.latitude) this.longitude= parseFloat(this.deviceInfos.longitude ) if (this.deviceInfos.status == 0) { @@ -565,24 +1014,61 @@ // console.log(this.polyline); res.rows.forEach(item => { - this.markers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - // title: item.deviceName, - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#000000', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS', // 修改为气泡的显示策略 - } - }) + if(item.type==1){ + this.markers.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){ + this.markers.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){ + this.markers.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' // 修改为气泡的显示策略 + } + }); + } }) } }).catch(error => { @@ -726,7 +1212,7 @@ flex-wrap: wrap; padding: 40rpx 18rpx; width: 750rpx; - height: 230rpx; + // height: 230rpx; background: #fff; // background: linear-gradient( 180deg, #FFFFFF 0%, rgba(255,255,255,0) 100%); box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0,0,0,0.08); @@ -735,6 +1221,7 @@ margin-right: 0; } .btn{ + margin-top: 10rpx; margin-right: 18rpx; display: flex; align-items: center; diff --git a/pages_admin/order/order_detail.vue b/pages_admin/order/order_detail.vue index 570aa5b..8454387 100644 --- a/pages_admin/order/order_detail.vue +++ b/pages_admin/order/order_detail.vue @@ -18,7 +18,7 @@ </view> <view class="info_li"> <view class="half_infoli"> - 租赁时长:<span>{{orderInfo.duration/60}}分钟</span> + 租赁时长:<span>{{ computedList(orderInfo)}}</span> </view> <view class="half_infoli"> 行驶距离:<span>{{orderInfo.distance/1000}}Km</span> @@ -38,10 +38,14 @@ <view class="info_li"> <view class="half_infoli"> - 车牌号:<span>{{orderInfo.device.vehicleNum}}</span> + 车牌号: + <span v-if="orderInfo.device.vehicleNum">{{orderInfo.device.vehicleNum}}</span> + <span v-else>--</span> </view> <view class="half_infoli"> - SN:<span>{{orderInfo.device.sn}}</span> + SN: + <span v-if="orderInfo.device.sn">{{orderInfo.device.sn}}</span> + <span v-else>--</span> </view> </view> <view class="info_li"> @@ -49,7 +53,9 @@ 车辆编号:<span>{{orderInfo.device.areaName}}</span> </view> --> <view class="half_infoli"> - 运营区域:<span>{{orderInfo.area}}</span> + 运营区域 + <span v-if="orderInfo.area">{{orderInfo.area}}</span> + <span v-else>--</span> </view> </view> </view> @@ -168,7 +174,7 @@ </view> </view> - <view class="bot"> + <view class="bot" v-if='orderInfo.paid==1'> <view class="btn"> 退款 </view> @@ -203,6 +209,7 @@ orderId: '', orderInfo: {}, loading: false, + showtk: false, } @@ -217,6 +224,17 @@ }, methods: { + computedList(item) { + const createTime = new Date(item.createTime); + const payTime = new Date(item.returnTime); + const timeDifference = Math.abs(createTime - payTime); + + const hours = Math.floor(timeDifference / (1000 * 60 * 60)); + const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); + const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000); + + return `${minutes}分钟${seconds}秒` + }, convertBoundaryToPolyline(boundary) { if (!boundary) return null; @@ -359,24 +377,61 @@ // console.log(this.polyline); res.rows.forEach(item => { - this.markers.push({ - id: parseFloat(item.parkingId), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - // title: item.deviceName, - width: 20, - height: 40, - iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u9yz0bKCWKyev0JYpTne', - callout: { - content: item.parkingName, // 修改为你想要显示的文字内容 - color: '#ffffff', // 修改为文字颜色 - fontSize: 14, // 修改为文字大小 - borderRadius: 10, // 修改为气泡圆角大小 - bgColor: '#000000', // 修改为气泡背景颜色 - padding: 6, // 修改为气泡内边距 - display: 'ALWAYS', // 修改为气泡的显示策略 - } - }) + if(item.type==1){ + this.markers.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){ + this.markers.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){ + this.markers.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' // 修改为气泡的显示策略 + } + }); + } }) } }).catch(error => { @@ -481,7 +536,111 @@ .page { padding-bottom: 200rpx; width: 750rpx; - + .tip_box { + position: fixed; + left: 72rpx; + top: 628rpx; + width: 610rpx; + // height: 282rpx; + background: #FFFFFF; + border-radius: 30rpx 30rpx 30rpx 30rpx; + z-index: 110; + padding-bottom: 100rpx; + + .top { + padding: 52rpx 38rpx 42rpx 36rpx; + + .ipt_box { + margin-top: 22rpx; + display: flex; + flex-wrap: nowrap; + align-items: center; + + .text { + width: 96rpx; + font-weight: 400; + font-size: 32rpx; + color: #3D3D3D; + } + + .ipt { + padding: 10rpx 18rpx; + display: flex; + align-items: center; + justify-content: space-between; + margin-left: 26rpx; + width: 420rpx; + height: 64rpx; + border-radius: 0rpx 0rpx 0rpx 0rpx; + border: 2rpx solid #979797; + + .input { + width: 80%; + } + } + } + + .tip { + width: 100%; + text-align: center; + font-weight: 700; + font-size: 32rpx; + color: #3D3D3D; + } + + .txt { + margin-top: 32rpx; + width: 100%; + text-align: center; + font-weight: 500; + font-size: 32rpx; + color: #3D3D3D; + } + } + + .bot { + position: absolute; + + width: 610rpx; + // border-top: 2rpx solid #D8D8D8; + display: flex; + flex-wrap: nowrap; + // height: 100%; + bottom: -20rpx; + + .bot_left { + border-radius: 0rpx 0rpx 0rpx 30rpx; + width: 50%; + height: 86rpx; + display: flex; + align-items: center; + justify-content: center; + font-weight: 500; + font-size: 32rpx; + color: #3D3D3D; + background: #EEEEEE; + } + + .bot_right { + border-radius: 0rpx 0rpx 30rpx 0rpx; + width: 50%; + height: 86rpx; + background: #4C97E7; + display: flex; + align-items: center; + justify-content: center; + color: #FFFFFF; + // border-left: 2rpx solid #D8D8D8; + font-weight: 500; + font-size: 32rpx; + // color: #4C97E7; + + } + + } + } + + .map { width: 750rpx; height: 752rpx; diff --git a/pages_admin/worke/woke_deviceMgmt.vue b/pages_admin/worke/woke_deviceMgmt.vue index e8899c0..34ec65d 100644 --- a/pages_admin/worke/woke_deviceMgmt.vue +++ b/pages_admin/worke/woke_deviceMgmt.vue @@ -62,18 +62,26 @@ <view class="info_li"> <view class="half_infoli"> - MAC:<span>{{item.mac}}</span> + MAC: + <span v-if="item.mac"> {{item.mac}}</span> + <span v-if="!item.mac"> --</span> </view> <view class="half_infoli"> - 电量:<span>{{item.remainingPower}}%</span> + 电量: + <span v-if="item.remainingPower"> {{item.remainingPower}}%</span> + <span v-else> --</span> </view> </view> <view class="info_li"> <view class="half_infoli"> - SN:<span>{{item.sn}}</span> + SN: + <span v-if="item.sn"> {{item.sn}}</span> + <span v-else> --</span> </view> <view class="half_infoli"> - 型号:<span>{{item.model}}</span> + 型号: + <span v-if="item.model"> {{item.model}}</span> + <span v-else> --</span> </view> </view> </view>