This commit is contained in:
2025-06-19 17:33:18 +08:00
commit f8f31dc4d9
437 changed files with 103080 additions and 0 deletions
@@ -0,0 +1,9 @@
{
"usingComponents": {
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index",
"van-empty": "@vant/weapp/empty/index",
"van-divider": "@vant/weapp/divider/index"
},
"navigationBarTitleText": "车辆监控"
}
@@ -0,0 +1,240 @@
/* pages/vehicleMonitoring/global/global.wxss */
.container {
width: 100vw;
height: 100vh;
position: relative;
#map-container {
width: 100%;
height: 100%;
position: absolute;
}
.top {
width: 100%;
background: #ffffff;
position: absolute;
top: 0;
z-index: 10;
.search-container {
padding: 10px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
>.number-plate,
>.project-select {
width: calc((100% - 6px) / 2);
height: 36px;
padding: 8px 10px;
box-sizing: border-box;
border-radius: 4px;
border: 1px solid #E6EAF2;
display: flex;
align-items: center;
}
>.number-plate {
.icon {
width: 20px;
height: 20px;
margin-right: 8px;
image {
width: 100%;
height: 100%;
}
}
input {
flex: 1;
font-size: 14px;
}
}
>.project-select {
width: calc((100% - 6px) / 2);
picker {
width: 100%;
position: relative;
.picker {
width: 100%;
height: 38px;
// padding-left: 14px;
box-sizing: border-box;
// border: 1px solid #E6EAF2;
border-radius: 4px;
font-size: 14px;
display: flex;
// justify-content: space-between;
align-items: center;
.val {
width: 85%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.picker::after {
content: '';
width: 0;
height: 0;
border-top: 6px solid #636B83;
border-right: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 6px solid transparent;
position: absolute;
top: 50%;
right: 10px;
transform: translateY(-2px);
}
}
}
}
.tab-container {
width: 100%;
height: 48px;
display: flex;
overflow: hidden;
.tabs {
width: calc(100% - 48px);
// overflow-x: auto;
}
.swicth {
width: 48px;
height: 48px;
box-shadow: -4px 2px 4px -2px rgba(0, 0, 0, .25);
// border-left: 1px solid rgba(0,0,0,.25);
position: absolute;
right: 0;
z-index: 10;
display: flex;
justify-content: center;
align-items: center;
image {
width: 20px;
height: 20px;
display: block;
}
}
}
}
.showPlateNumber {
width: 32px;
height: 32px;
background: #ffffff;
position: absolute;
top: 114px;
right: 6px;
z-index: 10;
display: flex;
justify-content: center;
align-items: center;
border-radius: 4px;
box-shadow: 0 0 4px rgba(0, 0, 0, .25);
image {
width: 20px;
height: 20px;
}
}
.car-list {
width: 100%;
height: calc(100vh - 104px);
padding: 8px;
box-sizing: border-box;
background: #EFF1F4;
position: absolute;
bottom: 0;
overflow-y: auto;
.item {
padding: 12px 10px;
margin-bottom: 8px;
background: #fff;
border-radius: 8px;
.row:first-child {
margin-bottom: 8px;
}
.row {
color: #2E3A4F;
display: flex;
justify-content: space-between;
align-items: center;
.number-plate {
font-size: 16px;
font-weight: bold;
}
.project-name {
font-size: 14px;
}
.status {
height: 22px;
line-height: 22px;
padding: 0 8px;
border: 1px solid;
border-radius: 4px;
font-size: 12px;
}
.online {
background: #F6FFED;
border-color: #D9F7BE;
color: #52C41A;
}
.offline {
background: rgba(0, 0, 0, 0.04);
border-color: rgba(0, 0, 0, 0.15);
color: rgba(0, 0, 0, 0.45);
}
.type-list {
display: flex;
.type {
height: 22px;
line-height: 22px;
padding: 0 8px;
margin-left: 5px;
background: #FFF1F0;
border-radius: 4px;
border: 1px solid #FFA39E;
color: #FF4D4F;
font-size: 12px;
}
}
}
}
}
}
.customCallout {
width: 96px;
// height: 100px;
padding: 4px;
text-align: center;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}
.none {
display: none;
}
@@ -0,0 +1,389 @@
// pages/vehicleMonitoring/global/global.ts
import { getAction } from '../../../api/base';
Page({
/**
* 页面的初始数据
*/
// lat: 30.435934
// lon: 104.065605
data: {
mapCenter: {
longitude: '104.065605',
latitude: '30.435934'
},
mapObj: null as any,
tabList: [],
active: 0,
showStatus: 0,
carList: [],
carMarkers: [],
carMarkersInfList: [],
includePoints: [],
timer: null as any,
projectOptions: [],
selectProjectIndex: 0,
selectProject: {} as any,
loading: false,
current: 1,
isLast: false,
mapScale: 0,
// 是否展示车牌
showPlateNumber: true
},
init() {
// this.initDateList()
// this.setData({
// routeId: wx.getStorageSync('diagramRouteInf'),
// })
// console.log(wx.getStorageSync('diagramRouteInf'))
this.data.mapObj = wx.createMapContext('map-container');
// console.log('地图对象', this.data.mapObj)
// this.getRealData()
// let that = this
// this.data.mapObj.getScale({
// success: function (res: any) {
// console.log('当前地图缩放级别:', res.scale);
// that.setData({
// mapScale: res.scale
// })
// }
// })
},
// 切换显示 0:地图 1:列表
swicthShow() {
console.log(this.data.showStatus);
this.setData({
showStatus: this.data.showStatus == 0 ? 1 : 0
});
if (this.data.showStatus == 0) {
this.getMapCarList();
} else {
this.getListByView();
}
},
toSearch() {
wx.setStorageSync('isGlobal', 1);
wx.navigateTo({
url: '../component/vehicleSearch/vehicleSearch',
fail: e => {
console.log(e);
}
});
},
toDetailPage(e: any) {
console.log(e.currentTarget.dataset.inf);
wx.setStorageSync('selectCar', e.currentTarget.dataset.inf);
wx.navigateTo({
url: '../realtime/realtime',
fail: e => {
console.log(e);
}
});
},
getProjectOptions() {
getAction('api/projects/list').then((res: any) => {
if (res.code == 200) {
res.result.unshift({
id: '',
projectName: '全部'
});
this.setData({
projectOptions: res.result,
selectProjectIndex: 0,
selectProject: res.result[0]
});
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
});
},
bindPickerProject(e: any) {
console.log(e);
let index = Number(e.detail.value);
this.setData({
selectProject: this.data.projectOptions[index],
selectProjectIndex: index
});
this.getTabList();
if (this.data.showStatus == 0) {
this.getMapCarList();
} else {
this.getListByView();
}
},
tabOnChange(e: any) {
console.log(e);
this.setData({
active: e.detail.index
});
this.getTabList();
if (this.data.showStatus == 0) {
this.getMapCarList();
} else {
this.getListByView();
}
},
getNextList() {
if (this.data.loading) return;
if (!this.data.isLast) {
this.setData({
current: this.data.current + 1
});
this.getListByView();
} else {
wx.showToast({
title: '告警信息已加载完毕',
duration: 1000,
icon: 'none'
});
}
},
getListByView() {
let parms = {
projectId: this.data.selectProject.id,
statusType: this.data.active == 0 ? '' : this.data.active, //不传查所有,1在线,2-离线,3-故障告警,4-围栏告警,5-超速告警,6-主动安全告警
pageNo: this.data.current,
pageSize: 500
};
getAction('api/monitor/vehicle/listByView', parms).then((res: any) => {
if (res.code == 200) {
this.setData({
carList: res.result.records
});
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
});
},
getMapCarList(isFirst = false) {
let parms = {
projectId: this.data.selectProject.id,
statusType: this.data.active == 0 ? '' : this.data.active, //不传查所有,1在线,2-离线,3-故障告警,4-围栏告警,5-超速告警,6-主动安全告警
lng: this.data.mapCenter.longitude,
lat: this.data.mapCenter.latitude
// mapLevel: 3 // 地图当前层级,默认3
};
this.setData({
loading: true
});
wx.showLoading({
title: '加载中'
});
getAction('api/monitor/vehicle/listByMap', parms).then((res: any) => {
wx.hideLoading();
this.setData({
loading: false
});
if (res.code == 200) {
let tmp = [] as any;
let imgUrl = '../../../images/car.png';
res.result.map((item: any, i: Number) => {
tmp.push({
id: i,
plateNumber: item.plateNumber,
latitude: item.gdLat,
longitude: item.gdLon,
iconPath: imgUrl,
anchor: {
// 经纬度在标注图标的锚点,
x: 0.5,
y: 1
},
customCallout: {
anchorX: 0,
anchorY: 54,
display: 'ALWAYS'
},
width: 21,
height: 24
});
});
this.setData({
carMarkers: tmp,
includePoints: tmp,
carMarkersInfList: res.result,
loading: false
});
// 获取当前层级
let that = this;
// 第一次加载点标记,防止点标记气泡的闪现画面
if (isFirst) {
this.data.mapObj.getScale({
success: function (res: any) {
that.setData({
mapScale: 10
});
}
});
}
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
});
},
// setMapCar() {
// // 车辆数据,调用地图方法渲染
// console.log('渲染车辆')
// },
getTabList() {
let parms = {
projectId: this.data.selectProject.id,
plateNumber: ''
};
getAction('api/monitor/vehicle/count', parms).then((res: any) => {
if (res.code == 200) {
this.setData({
tabList: res.result
});
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
});
},
bindtap(e: any) {
console.log(e);
},
// 视野发生变化时触发,
regionChange(e: any) {
console.log(e);
// 变化完后重载数据,若继续变化就先不重载数据
if (e.causedBy == '"drag"' && e.type == 'end') {
if (this.data.loading) {
return;
}
// let timer = setInterval(() => {
// debugger
// if(this.data.timer) {
// clearInterval(this.data.timer)
// this.setData({
// timer: null
// })
// }
this.getMapCarList();
// },1000)
// this.setData({
// timer: timer
// })
} else {
// clearInterval(this.data.timer)
// this.setData({
// timer: null
// })
}
// 获取当前层级
if (e.type == 'end') {
this.setData({
mapScale: e.detail.scale
});
}
},
showCarInf(e: any) {
//点击车辆图标 跳转到展示车辆信息
let tmp = this.data.carMarkersInfList;
let index = e.detail.markerId;
wx.setStorageSync('selectCar', tmp[index]);
// 存信息然后跳转
wx.navigateTo({
url: '../realtime/realtime',
fail: e => {
console.log(e);
}
});
},
setTimer() {
if (this.data.timer) {
clearInterval(this.data.timer);
}
let timer = setInterval(() => {
this.getTabList();
if (this.data.showStatus == 0) {
this.getMapCarList();
} else {
this.getListByView();
}
}, 30000);
this.setData({
timer: timer
});
},
showPlateNumberFn() {
this.setData({
showPlateNumber: !this.data.showPlateNumber
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.getProjectOptions();
this.init();
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getTabList();
if (this.data.showStatus == 0) {
this.getMapCarList(true);
} else {
this.getListByView();
}
this.setTimer();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
if (this.data.timer) {
clearInterval(this.data.timer);
}
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
if (this.data.timer) {
clearInterval(this.data.timer);
}
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
});
@@ -0,0 +1,74 @@
<!--pages/vehicleMonitoring/global/global.wxml-->
<view class="container">
<map id="map-container" longitude="{{mapCenter.longitude}}" latitude="{{mapCenter.latitude}}" markers="{{carMarkers}}" include-points="{{includePoints}}" name="" bindregionchange="regionChange" bindtap="bindtap" bindmarkertap="showCarInf">
<cover-view slot="callout">
<block wx:for="{{carMarkers}}" wx:key="{{item.id}}">
<cover-view class="customCallout {{(mapScale > 10 && showPlateNumber)? '' : 'none'}}" marker-id="{{item.id}}">
<cover-view>
{{item.plateNumber}}
</cover-view>
</cover-view>
</block>
</cover-view>
</map>
<view class="top">
<view class="search-container">
<view class="number-plate" catchtap="toSearch">
<view class="icon">
<image src="../../../images/icon_search.png" mode="" />
</view>
<input type="text" placeholder="搜索车辆" placeholder-style="color:#949CB5; font-size: 28rpx; font-weight: 400;" value="{{password}}" disabled="true" bindinput="getPassword" />
</view>
<view class="project-select">
<picker bindchange="bindPickerProject" value="{{selectProjectIndex}}" range-key="projectName" range="{{projectOptions}}">
<view class="picker project-select">
<view class="val">{{projectOptions[selectProjectIndex].projectName}}</view>
</view>
</picker>
</view>
</view>
<view class="tab-container">
<view class="tabs">
<van-tabs color="#4381FC" title-active-color="#4381FC" ellipsis="{{false}}" active="{{ active }}" bind:change="tabOnChange">
<van-tab title-style="font-size:16px" wx:for="{{tabList}}" wx:key="index" title="{{item.type + '(' + item.count + ')' }}"></van-tab>
</van-tabs>
</view>
<view class="swicth" catchtap="swicthShow">
<image src="../../../images/icon_map.png" wx:if="{{showStatus == 0}}" mode="" />
<image src="../../../images/icon_list.png" wx:if="{{showStatus == 1}}" mode="" />
</view>
</view>
</view>
<view class="showPlateNumber" catch:tap="showPlateNumberFn">
<image src="../../../images/icon_plateNumber_active.png" mode="" wx:if="{{showPlateNumber}}" />
<image src="../../../images/icon_plateNumber1.png" mode="" wx:else="" />
</view>
<view class="car-list" wx:if="{{showStatus == 1}}">
<view class="item" wx:for="{{carList}}" wx:key="index" data-inf="{{item}}" catchtap="toDetailPage">
<view class="row">
<view class="number-plate">{{item.plateNumber}}</view>
<view class="project-name">{{item.projectId_dictText}}</view>
</view>
<view class="row">
<view class="status offline" wx:if="{{item.isOnline == 0}}">离线</view>
<view class="status online" wx:if="{{item.isOnline == 1}}">在线</view>
<view class="type-list">
<!-- safetyAlarm 主动安全告警-0-正常 1-异常
speedingAlarm 超速告警 0-正常 1-异常
fenceAlarm 围栏告警 0-正常 1-异常
faultAlarm 故障报警 0-正常 1-异常 -->
<view class="type" wx:if="{{item.safetyAlarm == 1}}">主动安全告警</view>
<view class="type" wx:if="{{item.speedingAlarm == 1}}">超速告警</view>
<view class="type" wx:if="{{item.fenceAlarm == 1}}">围栏告警</view>
<view class="type" wx:if="{{item.faultAlarm == 1}}">故障报警</view>
</view>
</view>
</view>
<view class="is-last" wx:if="{{isLast && carList.length > 0}}" style="padding-bottom: 40rpx;">
<van-divider contentPosition="center">已加载完全部数据</van-divider>
</view>
<view class="no-data" wx:if="{{carList.length == 0}}">
<van-empty description="无数据" />
</view>
</view>
</view>