CarRental_back/pages_admin/order/device_detail.vue

1294 lines
36 KiB
Vue
Raw Normal View History

2024-05-09 18:00:26 +08:00
<template>
2024-05-09 20:58:53 +08:00
<view class="page">
<u-navbar title="设备详情" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36'
2024-06-07 18:08:55 +08:00
height='45'></u-navbar>
2024-06-24 17:59:49 +08:00
<!-- <view class="map">
</view> -->
2024-05-09 20:58:53 +08:00
<map class="map" id="map" ref="map" :scale="zoomSize" :latitude="latitude" :longitude="longitude"
2024-06-24 17:59:49 +08:00
:show-location="true" :markers="markers" :polygons="polyline" >
<cover-view class="park" @click="toggleIconAndCallout">
<cover-image class="img" src="https://lxnapi.ccttiot.com/bike/img/static/uRiYQZQEb3l2LsltEsyW" mode=""></cover-image>
</cover-view>
</map>
2024-05-09 20:58:53 +08:00
<view class="info_card">
<view class="info_tit">
设备信息
</view>
<view class="lines"></view>
<view class="cont">
<view class="info_li">
<view class="half_infoli">
2024-06-20 18:08:54 +08:00
车牌号<span v-if="deviceInfos.vehicleNum">{{deviceInfos.vehicleNum}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="half_infoli">
2024-05-13 18:03:20 +08:00
MAC<span>{{deviceInfos.mac}}</span>
2024-05-09 20:58:53 +08:00
</view>
</view>
<view class="info_li">
<view class="half_infoli">
2024-05-13 18:03:20 +08:00
SN<span>{{deviceInfos.sn}}</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="half_infoli">
2024-06-20 18:08:54 +08:00
车辆型号
<span v-if="deviceInfos.model">{{deviceInfos.model}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
</view>
<view class="info_li">
2024-06-20 18:08:54 +08:00
运营区域
<span v-if="deviceInfos.areaName">{{deviceInfos.areaName}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
</view>
<view class="lines"></view>
<view class="cont">
<view class="info_li">
<view class="half_infoli">
2024-05-13 18:03:20 +08:00
车辆状态<span>{{status()}}</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="half_infoli">
2024-06-20 18:08:54 +08:00
续航里程
<span v-if="deviceInfos.remainingMileage">{{deviceInfos.remainingMileage}} KM</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
</view>
<view class="info_li">
2024-05-13 18:03:20 +08:00
<view class="half_infoli">
2024-06-20 18:08:54 +08:00
电池电量
<span v-if="deviceInfos.remainingPower">{{deviceInfos.remainingPower}}%</span>
<span v-else>--</span>
2024-05-13 18:03:20 +08:00
</view>
2024-05-09 20:58:53 +08:00
</view>
2024-05-13 18:03:20 +08:00
<!-- <view class="info_li">
异常原因<span>已完成</span>
</view> -->
2024-05-09 20:58:53 +08:00
</view>
2024-05-13 18:03:20 +08:00
<!-- <view class="lines"></view>
2024-05-09 20:58:53 +08:00
<view class="cont">
<view class="info_li">
2024-05-13 18:03:20 +08:00
2024-05-09 20:58:53 +08:00
<view class="half_infoli">
GPRS信号<span>1Km</span>
</view>
</view>
2024-05-13 18:03:20 +08:00
</view> -->
2024-05-09 20:58:53 +08:00
<view class="lines"></view>
<view class="cont">
<view class="info_li">
2024-06-20 18:08:54 +08:00
最后定位坐标
<span v-if="deviceInfos.latitude">{{deviceInfos.latitude}},{{deviceInfos.longitude}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="info_li" style="flex-wrap: wrap;display: inline-block;">
2024-06-20 18:08:54 +08:00
最后定位地址
<span v-if="deviceInfos.location">{{deviceInfos.location}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="info_li">
2024-06-20 18:08:54 +08:00
最后定位时间
<span v-if="deviceInfos.lastTime">{{deviceInfos.lastTime}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
</view>
</view>
2024-05-13 23:34:28 +08:00
<view class="info_card" style="margin-top: 20rpx;" v-if="deviceInfos.etOrders!=''">
2024-05-09 20:58:53 +08:00
<view class="info_tit">
订单信息
</view>
<view class="lines"></view>
<view class="cont">
<view class="info_li">
2024-06-20 18:08:54 +08:00
当前用户
<span v-if="deviceInfos.etOrders[0].phonenumber">{{deviceInfos.etOrders[0].phonenumber}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="info_li" style="flex-wrap: wrap;display: inline-block;">
2024-06-20 18:08:54 +08:00
当前订单编号
<span v-if="deviceInfos.etOrders[0].orderNo">{{deviceInfos.etOrders[0].orderNo}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
<view class="info_li">
2024-06-20 18:08:54 +08:00
订单开始时间
<span v-if="deviceInfos.etOrders[0].createTime">{{deviceInfos.etOrders[0].createTime}}</span>
<span v-else>--</span>
2024-05-09 20:58:53 +08:00
</view>
</view>
</view>
<view class="bot_btn">
2024-05-13 18:03:20 +08:00
<view class="btn" @click="btn(0)">
2024-05-09 20:58:53 +08:00
开锁
</view>
2024-05-13 18:03:20 +08:00
<view class="btn" @click="btn(1)">
2024-05-09 20:58:53 +08:00
关锁
</view>
2024-05-13 18:03:20 +08:00
<view class="btn" @click="btn(2)">
2024-05-09 20:58:53 +08:00
车辆禁用
</view>
2024-05-13 18:03:20 +08:00
<view class="btn" @click="btn(3)">
2024-05-09 20:58:53 +08:00
车辆解禁
</view>
2024-05-13 18:03:20 +08:00
<view class="btn" @click="btn(4)">
2024-05-09 20:58:53 +08:00
响铃寻车
</view>
2024-06-21 18:03:21 +08:00
<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>
2024-05-09 20:58:53 +08:00
<view class="btn" @click="tipshow=true" v-if="info.type==1">
维修处理
</view>
<view class="btn" @click="tipshow=true" v-if="info.type==2">
换电处理
</view>
</view>
2024-05-13 18:03:20 +08:00
<u-mask :show="false" @click="show = false" :z-index='100' />
<view class="tip_box" v-if="false">
2024-05-09 20:58:53 +08:00
<view class="top">
<view class="tip">
修改车牌号
</view>
<view class="ipt_box">
<view class="text">
车牌号
</view>
<view class="ipt">
<input type="text"
v-model="searchKeyword"
placeholder="0.00"
class="input"
placeholder-style="color:#C7CDD3"
>
</view>
</view>
</view>
<view class="bot">
<view class="bot_left" @click="show=false">
取消
</view>
<view class="bot_right">
确定
</view>
</view>
</view>
<!-- <view class="bot">
<view class="btn">
退款
</view>
</view> -->
2024-05-09 18:00:26 +08:00
</view>
</template>
<script>
2024-06-21 18:03:21 +08:00
const app = getApp();
var xBlufi = require("@/utils/blufi/xBlufi.js");
let _this = null;
2024-05-09 18:00:26 +08:00
export default {
data() {
return {
2024-06-21 18:03:21 +08:00
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,
2024-05-09 20:58:53 +08:00
bgc: {
backgroundColor: "#F7FAFE",
},
show:true,
showgj:true,
searchKeyword: '11',
latitude: 39.916527,
longitude: 116.397128,
isMap: false,
zoomSize: 15,
2024-05-13 18:03:20 +08:00
markers: [],
polyline: [],
polygons: [],
cardId: '001区域',
sn:'',
2024-06-21 18:03:21 +08:00
deviceInfos:{},
carstause:false
2024-05-09 20:58:53 +08:00
2024-05-09 18:00:26 +08:00
}
},
2024-05-13 18:03:20 +08:00
onLoad(e) {
this.sn=e.id
this.deviceInfo()
this.getArea()
2024-06-20 18:08:54 +08:00
2024-06-21 18:03:21 +08:00
},
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: {
2024-05-13 18:03:20 +08:00
},
2024-05-09 18:00:26 +08:00
methods: {
2024-06-21 18:03:21 +08:00
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
},
2024-06-24 17:59:49 +08:00
2024-05-13 18:03:20 +08:00
btn(num){
if(num==0){
this.$u.post('/appVerify/admin/unlocking?sn='+this.sn).then((res) => {
if (res.code === 200) {
// 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构
this.deviceInfo()
}
}).catch(error => {
console.error("Error fetching area data:", error);
});
}else if(num==1){
this.$u.post('/appVerify/admin/lock?sn='+this.sn).then((res) => {
if (res.code === 200) {
// 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构
this.deviceInfo()
}
}).catch(error => {
console.error("Error fetching area data:", error);
});
}else if(num==2){
this.$u.post('/appVerify/device/offline?sn='+this.sn).then((res) => {
if (res.code === 200) {
// 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构
this.deviceInfo()
}
}).catch(error => {
console.error("Error fetching area data:", error);
});
}else if(num==3){
this.$u.post('/appVerify/device/online?sn='+this.sn).then((res) => {
if (res.code === 200) {
// 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构
this.deviceInfo()
}
}).catch(error => {
console.error("Error fetching area data:", error);
});
}else if(num==4){
2024-06-03 21:04:26 +08:00
this.$u.post('/app/device/ring?sn=' + this.sn).then((res) => {
2024-05-13 18:03:20 +08:00
if (res.code === 200) {
2024-06-03 21:04:26 +08:00
2024-05-13 18:03:20 +08:00
}
2024-06-03 21:04:26 +08:00
})
2024-05-13 18:03:20 +08:00
}
},
status(){
if(this.deviceInfos.onlineStatus==0){
return '离线'
}else{
if(this.deviceInfos.status==0){
return '未上架'
}else if(this.deviceInfos.status==1){
return '待租'
}else if(this.deviceInfos.status==2){
return '预约中'
}else if(this.deviceInfos.status==3){
return '骑行中'
}else if(this.deviceInfos.status==4){
return '临时锁车中'
}else if(this.deviceInfos.status==8){
return '下线'
}
}
},
deviceInfo() {
this.$u.get('/app/device/info?sn=' + this.sn).then((res) => {
if (res.code === 200) {
this.deviceInfos = res.data
2024-06-21 18:03:21 +08:00
this.mac=res.data.mac
2024-05-13 18:03:20 +08:00
this.latitude= parseFloat(this.deviceInfos.latitude)
this.longitude= parseFloat(this.deviceInfos.longitude )
if (this.deviceInfos.status == 0) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u76wT0QiWdAGJdF4v6AR',
callout: {
content: '未上架', // 修改为你想要显示的文字内容
color: '#ffffff', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#000000', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
} else if (this.deviceInfos.status == 1) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u1UD93BU1vfshWFoDwgX',
callout: {
content: '待租' + this.deviceInfos.remainingPower + '%', // 修改为你想要显示的文字内容
color: '#2679D1', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#D4ECFF', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
} else if (this.deviceInfos.status == 2) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u1UD93BU1vfshWFoDwgX',
callout: {
content: '预约' + this.deviceInfos.remainingPower + '%', // 修改为你想要显示的文字内容
color: '#2679D1', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#D4ECFF', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
} else if (this.deviceInfos.status == 3) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u1UD93BU1vfshWFoDwgX',
callout: {
content: '骑行' + this.deviceInfos.remainingPower + '%', // 修改为你想要显示的文字内容
color: '#2679D1', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#D4ECFF', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
} else if (this.deviceInfos.status == 4) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u1UD93BU1vfshWFoDwgX',
callout: {
content: '锁车' + this.deviceInfos.remainingPower + '%', // 修改为你想要显示的文字内容
color: '#2679D1', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#D4ECFF', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
} else if (this.deviceInfos.status == 8) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u76wT0QiWdAGJdF4v6AR',
callout: {
content: '下线', // 修改为你想要显示的文字内容
color: '#ffffff', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#000000', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
}
if (this.deviceInfos.onlineStatus == 0) {
this.markers.push({
id: parseFloat(this.deviceInfos.sn),
latitude: parseFloat(this.deviceInfos.latitude),
longitude: parseFloat(this.deviceInfos.longitude),
// title: item.deviceName,
width: 40,
height: 40,
iconPath: 'https://lxnapi.ccttiot.com/bike/img/static/u4UKmB47AxOj3YKIaajM',
callout: {
content: '离线', // 修改为你想要显示的文字内容
color: '#ffffff', // 修改为文字颜色
fontSize: 14, // 修改为文字大小
borderRadius: 10, // 修改为气泡圆角大小
bgColor: '#000000', // 修改为气泡背景颜色
padding: 6, // 修改为气泡内边距
display: 'ALWAYS', // 修改为气泡的显示策略
}
})
}
}
})
},
convertBoundaryToPolyline(boundary) {
if (!boundary) return null;
const points = JSON.parse(boundary).map(coord => ({
latitude: coord[1],
longitude: coord[0]
}));
const polyline = {
points: points,
fillColor: "#55888840", //填充颜色
strokeColor: "#22FF00", //描边颜色
strokeWidth: 2, //描边宽度
zIndex: 1, //层级
};
return polyline;
},
2024-06-20 18:08:54 +08:00
convertBoundaryToPolylines(boundaries,num) {
if(num==1){
console.log('判断');
return boundaries.map(boundary => {
if (!boundary) return null;
let coords;
try {
coords = JSON.parse(boundary);
} catch (error) {
console.error("Error parsing boundary JSON:", error);
return null;
}
if (!Array.isArray(coords)) {
console.error("Parsed boundary is not an array:", coords);
return null;
}
const points = coords.map(coord => ({
latitude: coord[1],
longitude: coord[0]
}));
return {
points: points,
fillColor: "#3A7EDB40", //填充颜色
strokeColor: "#3A7EDB", //描边颜色
strokeWidth: 2, //描边宽度
zIndex: 1, //层级
};
}).filter(polyline => polyline !== null); // 过滤掉无效的折线数据
}else if(num==2){
return boundaries.map(boundary => {
if (!boundary) return null;
let coords;
try {
coords = JSON.parse(boundary);
} catch (error) {
console.error("Error parsing boundary JSON:", error);
return null;
}
if (!Array.isArray(coords)) {
console.error("Parsed boundary is not an array:", coords);
return null;
}
const points = coords.map(coord => ({
latitude: coord[1],
longitude: coord[0]
}));
return {
points: points,
fillColor: "#FFF5D640", //填充颜色
strokeColor: "#FFC107", //描边颜色
strokeWidth: 2, //描边宽度
zIndex: 1, //层级
};
}).filter(polyline => polyline !== null); // 过滤掉无效的折线数据
}else if(num==3){
return boundaries.map(boundary => {
if (!boundary) return null;
let coords;
try {
coords = JSON.parse(boundary);
} catch (error) {
console.error("Error parsing boundary JSON:", error);
return null;
}
if (!Array.isArray(coords)) {
console.error("Parsed boundary is not an array:", coords);
return null;
}
const points = coords.map(coord => ({
latitude: coord[1],
longitude: coord[0]
}));
return {
points: points,
fillColor: "#FFD1CF40", //填充颜色
strokeColor: "#FF473E", //描边颜色
strokeWidth: 2, //描边宽度
zIndex: 1, //层级
};
}).filter(polyline => polyline !== null); // 过滤掉无效的折线数据
}
2024-06-24 17:59:49 +08:00
},
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: 28.95,
iconPath: item.type == 1 ?'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3':item.type == 2 ?'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t' :' https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq',
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));
}
2024-05-13 18:03:20 +08:00
},
getParking() {
// 发送请求获取数据
this.$u.get('/app/parking/list').then((res) => {
if (res.code === 200) {
// 处理接口返回的数据
2024-06-20 18:08:54 +08:00
const type1Data = [];
const type2Data = [];
const type3Data = [];
res.rows.forEach(row => {
if (row.type == 1) {
type1Data.push(row);
} else if (row.type == 2) {
type2Data.push(row);
} else if (row.type == 3) {
type3Data.push(row);
}
});
const validBoundaries = type1Data.map(row => row.boundaryStr).filter(boundary =>
2024-05-13 18:03:20 +08:00
typeof boundary === 'string' && boundary.trim() !== '');
2024-06-20 18:08:54 +08:00
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 validBoundaries2 = type3Data.map(row => row.boundaryStr).filter(boundary =>
typeof boundary === 'string' && boundary.trim() !== '');
const polylines2 = this.convertBoundaryToPolylines(validBoundaries2,3);
2024-05-13 18:03:20 +08:00
// 将处理后的数据添加到 this.polyline 中
2024-06-20 18:08:54 +08:00
this.polyline = this.polyline.concat(polylines2);
this.polyline = this.polyline.concat(polylines1);
2024-05-13 18:03:20 +08:00
this.polyline = this.polyline.concat(polylines);
2024-06-24 17:59:49 +08:00
this.parkingList = res.rows
2024-05-13 18:03:20 +08:00
// console.log(this.polyline);
2024-06-24 17:59:49 +08:00
2024-05-13 18:03:20 +08:00
}
}).catch(error => {
console.error("Error fetching parking data:", error);
});
},
getArea() {
// 发送请求获取数据
this.$u.get('/app/area/list').then((res) => {
if (res.code === 200) {
// 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构
const polylines = res.rows
.filter(area => area.boundaryStr) // 过滤掉boundary为空的数据
.map(area => this.convertBoundaryToPolyline(area.boundaryStr));
// 更新折线数据
this.polyline = polylines;
// console.log(this.polyline);
2024-06-20 18:08:54 +08:00
this.getParking()
2024-05-13 18:03:20 +08:00
}
}).catch(error => {
console.error("Error fetching area data:", error);
});
},
2024-05-09 18:00:26 +08:00
}
}
</script>
2024-05-09 20:58:53 +08:00
<style lang="scss">
page {
2024-05-13 18:03:20 +08:00
overflow-x: hidden;
2024-05-09 20:58:53 +08:00
background-color: #F3F3F3;
}
.page {
padding-bottom: 250rpx;
width: 750rpx;
.map {
2024-06-24 17:59:49 +08:00
position: relative;
2024-05-09 20:58:53 +08:00
width: 750rpx;
height: 752rpx;
2024-06-24 17:59:49 +08:00
.park {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
right: 30rpx;
bottom: 40rpx;
// background-color: #fff;
border-radius: 50%;
width: 82rpx;
height: 82rpx;
z-index: 10;
.img {
width: 82rpx;
height: 82rpx;
}
}
2024-05-09 20:58:53 +08:00
}
2024-06-24 17:59:49 +08:00
2024-05-09 20:58:53 +08:00
.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;
}
}
}
.bot_btn{
position: fixed;
bottom: 0;
display: flex;
flex-wrap: wrap;
padding: 40rpx 18rpx;
width: 750rpx;
2024-06-21 18:03:21 +08:00
// height: 230rpx;
2024-05-09 20:58:53 +08:00
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);
border-radius: 0rpx 0rpx 0rpx 0rpx;
.btn:nth-child(4n) {
margin-right: 0;
}
.btn{
2024-06-21 18:03:21 +08:00
margin-top: 10rpx;
2024-05-09 20:58:53 +08:00
margin-right: 18rpx;
display: flex;
align-items: center;
justify-content: center;
width: 164rpx;
height: 66rpx;
background: #E2F2FF;
border-radius: 0rpx 0rpx 0rpx 0rpx;
border: 2rpx solid #4C97E7;
font-weight: 400;
font-size: 28rpx;
color: #3D3D3D;
}
}
.info_card {
background: #FFFFFF;
.info_tit {
display: flex;
flex-wrap: nowrap;
padding: 22rpx 28rpx;
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
2024-05-09 18:00:26 +08:00
2024-05-09 20:58:53 +08:00
.money {
margin-left: auto;
font-weight: 500;
font-size: 32rpx;
color: #4C97E7;
}
}
.lines {
width: 750rpx;
height: 2rpx;
border: 2rpx solid #ccc;
}
.cont {
padding: 26rpx 28rpx;
.info_li {
2024-05-13 18:03:20 +08:00
width: 98%;
2024-05-09 20:58:53 +08:00
display: flex;
flex-wrap: nowrap;
font-weight: 400;
font-size: 28rpx;
color: #808080;
span {
color: #3D3D3D;
}
2024-05-13 18:03:20 +08:00
white-space: nowrap;
/* 禁止换行 */
overflow: hidden;
/* 超出部分隐藏 */
text-overflow: ellipsis;
/* 显示省略号 */
2024-05-09 20:58:53 +08:00
line-height: 48rpx;
.half_infoli {
display: flex;
flex-wrap: nowrap;
width: 50%;
font-weight: 400;
font-size: 28rpx;
color: #808080;
span {
color: #3D3D3D;
}
.input{
width: 30%;
}
}
}
}
}
}
</style>