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,7 @@
{
"usingComponents": {
"van-empty": "@vant/weapp/empty/index",
"van-popup": "@vant/weapp/popup/index"
},
"navigationBarTitleText": "搜索车辆"
}
@@ -0,0 +1,71 @@
/* pages/vehicleMonitoring/component/vehicleSearch/vehicleSearch.wxss */
.container {
>.search {
width: calc(100% - 16px);
height: 36px;
padding: 8px;
margin: 8px auto;
box-sizing: border-box;
border-radius: 4px;
background: #F6F7F9;
border: 1px solid #E6EAF2;
display: flex;
align-items: center;
.icon {
width: 20px;
height: 20px;
margin-right: 8px;
image {
width: 100%;
height: 100%;
}
}
input {
flex: 1;
font-size: 14px;
}
}
.search-list {
padding: 0 18rpx;
.item {
padding: 22rpx 18rpx;
border-bottom: 2rpx solid #E6EAF2;
display: flex;
justify-content: space-between;
align-items: center;
.company {
font-size: 40rpx;
color: #2B3A51;
display: flex;
.hight-light {
color: #3977F7;
}
}
.priority {
color: #888888;
font-size: 36rpx;
display: flex;
align-items: center;
.common-use {
width: 34rpx;
height: 34rpx;
margin-left: 14rpx;
display: inline-block;
border-radius: 50%;
border: 2rpx solid #A2A2A2;
color: #A2A2A2;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
}
.iscommon {
border: 2rpx solid #3D7EEA;
background: #3D7EEA;
color: #fff;
}
}
}
}
}
@@ -0,0 +1,111 @@
// pages/vehicleMonitoring/component/vehicleSearch/vehicleSearch.ts
import { getAction } from '../../../../api/base';
Page({
/**
* 页面的初始数据
*/
data: {
plateNumber: '',
searchList: []
},
getPlateNumber(e: any) {
let val = e.detail.value;
let parms = {
plateNumber: val
};
getAction('api/monitor/vehicle/listByAll', parms)
.then((res: any) => {
if (res.code == 200) {
console.log(res.result);
let tmpArr = res.result;
for (let i = 0; i < tmpArr.length; i++) {
let item: any = tmpArr[i];
item.valueTxt = this.getHilightStrArray(item.plateNumber, val);
}
this.setData({
searchList: tmpArr,
plateNumber: val
});
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
})
.catch((err: any) => {
this.setData({
loading: false
});
wx.showToast({
title: err.message,
icon: 'none'
});
});
},
// 返回一个使用key切割str后的数组,key仍在数组中
getHilightStrArray(str: string, key: string) {
return str.replace(new RegExp(`${key}`, 'g'), `%%${key}%%`).split('%%');
},
selectOption(e: any) {
console.log(e.currentTarget.dataset);
if (wx.getStorageSync('isGlobal') == 1) {
wx.setStorageSync('selectCar', e.currentTarget.dataset.item);
wx.navigateTo({
url: '../../realtime/realtime',
fail: e => {
console.log(e);
}
});
} else {
// 传参,跳转
wx.setStorageSync('selectCarInf', e.currentTarget.dataset.item);
wx.navigateBack({
delta: 1,
fail: e => {
console.log(e);
}
});
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
});
@@ -0,0 +1,30 @@
<!--pages/vehicleMonitoring/component/vehicleSearch/vehicleSearch.wxml-->
<view class="container">
<view class="search">
<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="{{plateNumber}}"
bindinput="getPlateNumber" />
</view>
<view class="search-list">
<view class="item" wx:for="{{searchList}}" wx:key="index" data-item="{{item}}" catchtap="selectOption">
<view class="company">
<view wx:for="{{item.valueTxt}}" wx:for-item="nameItem" wx:key="index" class="{{nameItem == plateNumber ? 'hight-light' : ''}}">{{nameItem}}</view>
</view>
<!-- <view class="priority">
{{item.orgName}}
<view class="common-use {{item.topping ? 'iscommon' : ''}}" data-item="{{item}}" catchtap="setrouteTop">
<van-icon name="down" style="transform: rotate(180deg);" />
</view>
</view> -->
</view>
<view class="no-data" wx:if="{{searchList.length == 0}}">
<van-empty description="无数据" />
</view>
</view>
</view>
@@ -0,0 +1,13 @@
{
"usingComponents": {
"van-picker": "@vant/weapp/picker/index",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index",
"van-popup": "@vant/weapp/popup/index",
"van-icon": "@vant/weapp/icon/index",
"van-empty": "@vant/weapp/empty/index",
"van-divider": "@vant/weapp/divider/index"
},
"enablePullDownRefresh": true,
"navigationBarTitleText": "提醒"
}
@@ -0,0 +1,339 @@
/* pages/vehicleMonitoring/failureAlert/failureAlert.wxss */
.container {
height: 100vh;
background: #EFF1F4;
position: relative;
overflow: hidden;
.search-container {
padding: 10px 8px;
border-top: 1px solid #DBDBDB;
background: #ffffff;
.row {
margin-bottom: 8px;
display: flex;
justify-content: space-between;
align-items: center;
>.number-plate, >.project-select,.status-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 {
width: 100%;
.icon_search {
width: 20px;
height: 20px;
margin-right: 8px;
image {
width: 100%;
height: 100%;
}
}
input {
flex: 1;
font-size: 14px;
}
.btn {
width: 18px;
padding: 0 4px;
color: #949CB5;
font-size: 18px;
}
}
>.project-select, .status-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: 4px;
transform: translateY(-2px);
}
}
.select-box {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
.val {
width: 90%;
font-size: 14px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.placeholder{
color: #949CB5;
}
.arrow{
width: 0;
height: 0;
border-left: 13rpx solid transparent;
border-right: 13rpx solid transparent;
border-top: 15rpx solid #636B83;
margin-left: 18rpx;
}
}
}
.line {
width: 10px;
height: 1px;
background: #949CB5;
}
.date {
width: calc((100% - 10px - 70px) / 2);
height: 36px;
padding: 8px 10px;
box-sizing: border-box;
border-radius: 4px;
border: 1px solid #E6EAF2;
display: flex;
align-items: center;
.icon {
width: 16px;
height: 16px;
margin-left: 8px;
image {
width: 100%;
height: 100%;
}
}
input {
flex: 1;
color: #2E3A4F;
font-size: 14px;
}
}
>.btn {
// height: 36px;
padding: 8px 14px;
margin-left: 12px;
background: linear-gradient(90deg, #3B7CFC 0%, #548BFC 100%);
border-radius: 8px;
color: #fff;
font-size: 15px;
display: flex;
align-items: center;
white-space: nowrap;
}
}
}
.list-content {
.total {
padding: 6px 18px;
font-size: 14px;
display: flex;
.number {
margin: 0 4px;
color: #4381FC;
font-weight: bold;
}
}
.list {
height: calc(100vh - 44px - 150px - 32px);
padding: 2px 0;
box-sizing: border-box;
// overflow-y: auto;
.scroll-view_H {
height: 100%;
// padding: 0 8px;
box-sizing: border-box;
}
.item {
padding: 10px 0 4px;
margin: 0 8px 8px;
background: #FFFFFF;
border-radius: 8px;
box-shadow: 0 0 4px 0 rgba(0,0,0,.4);
.top {
padding: 0 8px;
margin-bottom: 8px;
display: flex;
align-items: center;
justify-content: space-between;
.number-plate {
font-size: 16px;
font-weight: bold;
color: #2E3A4F;
}
.t-right {
font-size: 14px;
display: flex;
.project-name {
margin-right: 6px;
}
.type {
padding: 0 8px;
border-radius: 2px;
border: 1px solid #3977F7;
color: #3977F7;
}
}
}
.row {
padding: 0 8px;
margin-bottom: 8px;
font-size: 14px;
display: flex;
align-items: center;
justify-content: space-between;
.label {
color: #858CA0;
}
.val {
color: #2E3A4F;
}
}
.time-container {
padding: 0 8px;
display: flex;
align-items: center;
justify-content: space-between;
>.time {
width: calc((100% - 20px) / 3);
.val {
min-height: 58px;
margin-bottom: 4px;
background: #ECEFF5;
border-radius: 8px;
color: #303133;
font-size: 14px;
text-align: center;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.val-f16 {
font-size: 16px;
}
.label {
color: #8A90A4;
font-size: 12px;
text-align: center;
}
}
>.normal {
.val {
color: #4381FC;
}
}
>.error {
.val {
background-color: #FFEDED;
color: #E04D4D;
}
}
}
}
}
}
.nodata {
text-align: center;
margin: 60px;
font-size: 26px;
}
}
// 时间选择器
.date-btn-box {
// background: #fff;
// border-radius: 4px 4px 0 0;
border-bottom: 2rpx solid #F1F1F1;
font-size: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.btn {
padding: 20rpx 36rpx;
color: #888888;
}
.btn-confirm{
color: #3D7EEA;
}
}
.date-title {
padding: 20rpx 36rpx;
font-size: 36rpx;
color: #888888;
border-bottom: 2rpx solid #F1F1F1;
display: flex;
justify-content: space-evenly;
align-items: center;
.line {
width: 10px;
height: 1px;
margin: 0 14px;
background: #949CB5;
}
.date {
width: calc((100% - 10px - 28px) / 2);
height: 36px;
padding: 8px 10px;
box-sizing: border-box;
border-radius: 4px;
border: 1px solid #E6EAF2;
display: flex;
align-items: center;
.icon {
width: 16px;
height: 16px;
margin-left: 8px;
image {
width: 100%;
height: 100%;
display: block;
}
}
input {
flex: 1;
color: #2E3A4F;
font-size: 14px;
}
}
.select {
border: 1px solid #1677FF;
input {
color: #1677FF !important;
}
}
}
.picker-box {
width: 100%;
display: flex;
justify-content: space-between;
}
@@ -0,0 +1,640 @@
// pages/vehicleMonitoring/failureAlert/failureAlert.ts
import { getAction } from '../../../api/base';
Page({
/**
* 页面的初始数据
*/
data: {
tabActive: 0,
startDate: '',
endDate: '',
startDateTmp: '',
endDateTmp: '',
selectDate: 'startDate',
showDateSelect: false,
dateList: {
years: [2023, 2024, 2025],
months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
date: [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
]
},
dateValue: [0, 0, 0],
loading: false,
current: 1,
isLast: false,
plateNumber: '',
showSelect: {
projectSelectShow: false,
statusSelectShow: false
},
projectOptions: [
{
value: '',
text: '全部'
}
] as any,
selectProjectIndex: 0,
statusOptions: [
{
value: '',
text: '全部'
},
{
value: '1',
text: '已结束'
},
{
value: '0',
text: '未结束'
}
],
selectStatusIndex: 2,
selectProject: {} as any,
listTotal: 0,
fenceAlarmList: [],
speedAlarmlistTotal: 0,
overTimeAlarmlistTotal: 0,
speedAlarmList: [],
overTimeAlarmList: []
},
toSearch() {
wx.setStorageSync('isGlobal', '');
wx.navigateTo({
url: '../component/vehicleSearch/vehicleSearch',
fail: e => {
console.log(e);
}
});
},
// 日期相关--------------
showDate(e: any) {
// selectDate
let clickDate = null as any;
if (e.currentTarget.dataset.key == 'startDate') {
clickDate = this.data.startDate;
} else {
clickDate = this.data.endDate;
}
let y = this.data.dateList.years.findIndex(
(x: number) => x == Number(clickDate.split('-')[0])
);
let m = this.data.dateList.months.findIndex(
(x: number) => x == Number(clickDate.split('-')[1])
);
let d = this.data.dateList.date.findIndex(
(x: number) => x == Number(clickDate.split('-')[2])
);
// console.log(this.data.startDate.split('-'))
console.log([y, m, d]);
this.setData({
showDateSelect: true,
selectDate: e.currentTarget.dataset.key,
startDateTmp: this.data.startDate,
endDateTmp: this.data.endDate,
dateValue: [y, m, d]
});
},
hideDate() {
this.setData({
showDateSelect: false
});
},
changeSelectDate(e: any) {
this.setData({
selectDate: e.currentTarget.dataset.key,
current: 1,
isLast: false,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: []
});
},
selectDate(e: any) {
console.log(e.detail.value);
let y: string | number = this.data.dateList.years[e.detail.value[0]];
let m: string | number = this.data.dateList.months[e.detail.value[1]];
let d: string | number = this.data.dateList.date[e.detail.value[2]];
y = y < 10 ? '0' + y : y;
m = m < 10 ? '0' + m : m;
d = d < 10 ? '0' + d : d;
if (this.data.selectDate == 'startDate') {
this.setData({
startDateTmp: `${y}-${m}-${d}`
});
} else {
this.setData({
endDateTmp: `${y}-${m}-${d}`
});
}
},
changeDate(e: any) {
console.log(
new Date(this.data.startDateTmp).getTime(),
new Date(this.data.endDateTmp).getTime()
);
if (
new Date(this.data.startDateTmp).getTime() >
new Date(this.data.endDateTmp).getTime()
) {
wx.showToast({
title: '结束时间不能早于开始时间',
icon: 'none'
});
return;
}
this.setData({
startDate: this.data.startDateTmp,
endDate: this.data.endDateTmp,
showDateSelect: false
});
},
// 日期相关--------------end
tabOnClick(event: any) {
console.log(event.detail.name);
// 看情况要不要重置查询条件
this.setData({
current: 1,
isLast: false,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: [],
tabActive: event.detail.name
// selectProjectIndex: 0
});
// 查询
if (event.detail.name == 0) {
this.getFenceAlarmList();
} else if (event.detail.name == 1) {
this.getSpeedAlarmList();
} else if (event.detail.name == 2) {
this.getOverTimeAlarmList();
}
},
getNextList() {
if (this.data.loading) return;
if (!this.data.isLast) {
this.setData({
current: this.data.current + 1
});
this.getFenceAlarmList();
} else {
wx.showToast({
title: '告警信息已加载完毕',
duration: 1000,
icon: 'none'
});
}
},
searchList() {
this.setData({
current: 1,
isLast: false,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: [],
listTotal: 0,
speedAlarmlistTotal: 0,
overTimeAlarmlistTotal: 0
});
// 查询
if (this.data.tabActive == 0) {
this.getFenceAlarmList();
} else if (this.data.tabActive == 1) {
this.getSpeedAlarmList();
} else if (this.data.tabActive == 2) {
this.getOverTimeAlarmList();
}
},
getFenceAlarmList() {
let parms = {
status: this.data.statusOptions[this.data.selectStatusIndex].value,
projectId: this.data.projectOptions[this.data.selectProjectIndex].value,
plateNumber: this.data.plateNumber,
startTime: this.data.startDate + ' 00:00:00',
endTime: this.data.endDate + ' 23:59:59',
pageNo: this.data.current,
pageSize: 10
};
this.setData({
loading: true
});
wx.showLoading({
title: '加载中'
});
getAction('api/monitor/fenceAlarm/list', parms)
.then((res: any) => {
wx.hideLoading();
this.setData({
loading: false
});
if (res.code == 200) {
let tmpArr = this.data.fenceAlarmList.concat(res.result.records);
this.setData({
listTotal: res.result.total,
fenceAlarmList: tmpArr
});
if (res.result.total == tmpArr.length) {
// tmpArr 目前只是调试流程用
this.setData({
isLast: true
});
}
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
})
.catch((err: any) => {
this.setData({
loading: false
});
wx.showToast({
title: err.message,
icon: 'none'
});
});
},
getSpeedAlarmList() {
let parms = {
status: this.data.statusOptions[this.data.selectStatusIndex].value,
projectId: this.data.projectOptions[this.data.selectProjectIndex].value,
plateNumber: this.data.plateNumber,
startTime: this.data.startDate + ' 00:00:00',
endTime: this.data.endDate + ' 23:59:59',
pageNo: this.data.current,
pageSize: 10
};
this.setData({
loading: true
});
wx.showLoading({
title: '加载中'
});
getAction('api/monitor/speedAlarm/list', parms)
.then((res: any) => {
wx.hideLoading();
this.setData({
loading: false
});
if (res.code == 200) {
let tmpArr = this.data.speedAlarmList.concat(res.result.records);
this.setData({
speedAlarmlistTotal: res.result.total,
speedAlarmList: tmpArr
});
if (res.result.total == tmpArr.length) {
// tmpArr 目前只是调试流程用
this.setData({
isLast: true
});
}
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
})
.catch((err: any) => {
this.setData({
loading: false
});
wx.showToast({
title: err.message,
icon: 'none'
});
});
},
// 获取停车超时数据
getOverTimeAlarmList() {
let parms = {
status: this.data.statusOptions[this.data.selectStatusIndex].value,
projectId: this.data.projectOptions[this.data.selectProjectIndex].value,
plateNumber: this.data.plateNumber,
startTime: this.data.startDate + ' 00:00:00',
endTime: this.data.endDate + ' 23:59:59',
pageNo: this.data.current,
pageSize: 10
};
this.setData({
loading: true
});
wx.showLoading({
title: '加载中'
});
getAction('api/monitor/stopAlarm/list', parms)
.then((res: any) => {
wx.hideLoading();
this.setData({
loading: false
});
if (res.code == 200) {
console.log(res.result);
let tmpArr = this.data.overTimeAlarmList.concat(res.result.records);
this.setData({
overTimeAlarmlistTotal: res.result.total,
overTimeAlarmList: tmpArr
});
if (res.result.total == tmpArr.length) {
// tmpArr 目前只是调试流程用
this.setData({
isLast: true
});
}
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
})
.catch((err: any) => {
this.setData({
loading: false
});
wx.showToast({
title: err.message,
icon: 'none'
});
});
},
getProjectOptions() {
getAction('api/projects/list').then((res: any) => {
if (res.code == 200) {
res.result.unshift({
id: '',
projectName: '全部'
});
let arr = [] as any;
res.result.forEach((item: any) => {
arr.push({
text: item.projectName,
value: item.id
});
});
this.setData({
projectOptions: arr,
selectProjectIndex: 0,
selectProject: arr[0]
});
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
});
},
toDetail(e: any) {
wx.setStorageSync('selectCar', e.currentTarget.dataset.inf);
if (this.data.tabActive == 0) {
wx.navigateTo({
url: '../realtime/realtime',
fail: e => {
console.log(e);
}
});
} else {
console.log('跳转到超速详情');
}
},
bindPickerProject(e: any) {
console.log(e);
let index = Number(e.detail.value);
this.setData({
selectProject: this.data.projectOptions[index],
selectProjectIndex: index,
current: 1,
isLast: false,
listTotal: 0,
speedAlarmlistTotal: 0,
overTimeAlarmlistTotal: 0,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: []
});
// 查询
if (this.data.tabActive == 0) {
this.getFenceAlarmList();
} else if (this.data.tabActive == 1) {
this.getSpeedAlarmList();
} else if (this.data.tabActive == 2) {
this.getOverTimeAlarmList();
}
},
pickerChange(event: any) {
//下拉框切换是否展示
let fieldName: any = event.currentTarget.dataset.fieldname;
let data: any = { ...this.data };
data.showSelect[fieldName] = true;
this.setData(data);
},
hidePicker() {
let showSelect = this.data.showSelect;
showSelect = {
projectSelectShow: false,
statusSelectShow: false
};
this.setData({
showSelect: showSelect
});
},
pickerConfirm(event: any) {
console.log(event);
//下拉框点击确认
let { fieldname, fieldindex } = event.currentTarget.dataset;
let detail = event.detail;
let data: any = { ...this.data };
// if (fieldname === 'projectId') {
// data.params[fieldname] = detail.value.value;
// data[fieldindex] = detail.index;
// } else {
data[fieldname] = this.data.projectOptions[detail.index];
data[fieldindex] = detail.index;
// }
console.log(this.data);
this.setData(data);
this.hidePicker();
this.setData({
current: 1,
isLast: false,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: [],
listTotal: 0,
speedAlarmlistTotal: 0,
overTimeAlarmlistTotal: 0
});
// 查询
if (this.data.tabActive == 0) {
this.getFenceAlarmList();
} else if (this.data.tabActive == 1) {
this.getSpeedAlarmList();
} else if (this.data.tabActive == 2) {
this.getOverTimeAlarmList();
}
},
clearValue() {
this.setData({
plateNumber: ''
});
},
// 日期初始化
initDate() {
let year = new Date().getFullYear();
let mon = (new Date().getMonth() + 1) as any;
let day =
new Date().getDate() < 10
? '0' + new Date().getDate()
: new Date().getDate();
let years = [] as any;
let sy = mon > 1 ? year : year - 1;
let smon = mon > 1 ? mon - 1 : (12 as any);
mon = mon < 10 ? '0' + mon : mon;
smon = smon < 10 ? '0' + smon : smon;
for (let i = -3; i < 6; i++) {
years.push(year + i);
}
this.setData({
dateList: {
years: years,
months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
date: [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
]
},
dateValue: [0, 0, 0],
startDate: `${sy}-${smon}-${day}`,
endDate: `${year}-${mon}-${day}`,
startDateTmp: `${sy}-${smon}-${day}`,
endDateTmp: `${year}-${mon}-${day}`
});
},
lower(e: any) {
console.log(e.detail.direction == 'bottom');
if (this.data.isLast) {
wx.showToast({
title: '已经是最后一页',
icon: 'none'
});
return;
}
if (e.detail.direction == 'bottom' && !this.data.loading) {
// this.data.current += 1
this.setData({
loading: true,
current: (this.data.current += 1)
});
// 查询
if (this.data.tabActive == 0) {
this.getFenceAlarmList();
} else if (this.data.tabActive == 1) {
this.getSpeedAlarmList();
} else if (this.data.tabActive == 2) {
this.getOverTimeAlarmList();
}
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.initDate();
this.getProjectOptions();
this.getFenceAlarmList();
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// this.initDate();
let plateNumber = wx.getStorageSync('selectCarInf').plateNumber;
this.setData({
plateNumber: plateNumber ? plateNumber : this.data.plateNumber,
current: 1,
isLast: false,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: [],
listTotal: 0,
speedAlarmlistTotal: 0,
overTimeAlarmlistTotal: 0
});
console.log(this.data);
wx.removeStorageSync('selectCarInf');
if (this.data.tabActive == 0) {
this.getFenceAlarmList();
} else if (this.data.tabActive == 1) {
this.getSpeedAlarmList();
} else if (this.data.tabActive == 2) {
this.getOverTimeAlarmList();
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
wx.setStorageSync('selectCarInf', '');
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
wx.setStorageSync('selectCarInf', '');
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.initDate();
this.getProjectOptions();
this.setData({
plateNumber: '',
current: 1,
isLast: false,
fenceAlarmList: [],
speedAlarmList: [],
overTimeAlarmList: []
});
if (this.data.tabActive == 0) {
this.getFenceAlarmList();
} else if (this.data.tabActive == 1) {
this.getSpeedAlarmList();
} else if (this.data.tabActive == 2) {
this.getOverTimeAlarmList();
}
//停止下拉刷新
wx.stopPullDownRefresh();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
});
@@ -0,0 +1,354 @@
<!--pages/vehicleMonitoring/failureAlert/failureAlert.wxml-->
<view class="container">
<van-tabs color="#4381FC" bind:click="tabOnClick">
<van-tab title="电子围栏告警">
<view class="search-container">
<view class="row">
<view class="number-plate" catchtap="toSearch">
<view class="icon_search">
<image src="../../../images/icon_search.png" mode="" />
</view>
<input type="text" placeholder="搜索车辆" placeholder-style="color:#949CB5; font-size: 28rpx; font-weight: 400;" value="{{ plateNumber }}" disabled="true" bindinput="getPassword" />
<view class="btn" data-type="1" catchtap="clearValue">
<van-icon name="close" />
</view>
</view>
</view>
<view class="row">
<view class="status-select">
<view class="select-box" data-fieldName="satausSelectShow" catch:tap="pickerChange">
<view class="val" wx:if="{{true}}">{{statusOptions[selectStatusIndex].text}}</view>
<view class="placeholder" wx:else>请选择</view>
<view class="arrow"></view>
</view>
<!-- 项目下拉选择 -->
<van-popup show="{{showSelect.satausSelectShow}}" position="bottom" bind:close="hidePicker">
<van-picker data-fieldname="sataus" default-index="{{ selectStatusIndex }}" data-fieldindex="selectStatusIndex" show-toolbar columns="{{statusOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
</van-picker>
</van-popup>
</view>
<view class="project-select">
<view class="select-box" data-fieldName="projectSelectShow" catch:tap="pickerChange">
<view class="val" wx:if="{{selectProject.value > 0}}">{{projectOptions[selectProjectIndex].text}}</view>
<view class="placeholder" wx:else>请选择</view>
<view class="arrow"></view>
</view>
<!-- 项目下拉选择 -->
<van-popup show="{{showSelect.projectSelectShow}}" position="bottom" bind:close="hidePicker">
<van-picker data-fieldname="selectProject" data-fieldindex="selectProjectIndex" show-toolbar columns="{{projectOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
</van-picker>
</van-popup>
<!-- <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="row">
<view class="date" data-key="startDate" catchtap="showDate">
<input type="text" value="{{startDate}}" disabled="true" bindinput="getPassword" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="line"></view>
<view class="date" data-key="endDate" catchtap="showDate">
<input type="text" value="{{endDate}}" disabled="true" bindinput="getPassword" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="btn" catchtap="searchList">搜索</view>
</view>
</view>
<view class="list-content">
<view class="total">共 <view class="number">{{listTotal}}</view> 条告警记录</view>
<view class="list">
<scroll-view class="scroll-view_H" scroll-y="true" bindscrolltolower="lower" style="width: 100%">
<view class="item" wx:for="{{fenceAlarmList}}" wx:key="index" data-inf="{{item}}" catchtap="toDetail">
<view class="top">
<view class="number-plate">{{item.plateNumber}}</view>
<view class="t-right">
<view class="project-name">{{item.projectName}}</view>
<view class="type" wx:if="{{item.fenceType == 1}}">停场围栏</view>
<view class="type" wx:if="{{item.fenceType == 2}}">行驶围栏</view>
</view>
</view>
<view class="time-container">
<view class="time {{item.endTime ? 'normal' : ''}}">
<view class="val">{{item.startTime ? item.startTime : '/'}}</view>
<view class="label">开始时间</view>
</view>
<view class="time {{item.endTime ? 'normal' : ''}}">
<view class="val">{{item.endTime ? item.endTime : '/'}}</view>
<view class="label">结束时间</view>
</view>
<view class="time {{item.endTime ? 'normal' : 'error'}}">
<view class="val val-f16">{{item.durTime ? item.durTime : '/'}}</view>
<view class="label">持续时间</view>
</view>
</view>
</view>
<view class="is-last" wx:if="{{isLast && fenceAlarmList.length > 0}}" style="padding-bottom: 40rpx;">
<van-divider contentPosition="center">已加载完全部数据</van-divider>
</view>
<view class="no-data" wx:if="{{fenceAlarmList.length == 0}}">
<van-empty description="无数据" />
</view>
</scroll-view>
</view>
</view>
</van-tab>
<van-tab title="超速告警">
<view class="search-container">
<view class="row">
<view class="number-plate" catchtap="toSearch">
<view class="icon_search">
<image src="../../../images/icon_search.png" mode="" />
</view>
<input type="text" placeholder="搜索车辆" placeholder-style="color:#949CB5; font-size: 28rpx; font-weight: 400;" value="{{ plateNumber }}" disabled="true" bindinput="getPassword" />
<view class="btn" data-type="1" catchtap="clearValue">
<van-icon name="close" />
</view>
</view>
</view>
<view class="row">
<view class="status-select">
<view class="select-box" data-fieldName="satausSelectShow" catch:tap="pickerChange">
<view class="val" wx:if="{{true}}">{{statusOptions[selectStatusIndex].text}}</view>
<view class="placeholder" wx:else>请选择</view>
<view class="arrow"></view>
</view>
<!-- 项目下拉选择 -->
<van-popup show="{{showSelect.satausSelectShow}}" position="bottom" bind:close="hidePicker">
<van-picker data-fieldname="sataus" default-index="{{ selectStatusIndex }}" data-fieldindex="selectStatusIndex" show-toolbar columns="{{statusOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
</van-picker>
</van-popup>
</view>
<view class="project-select">
<view class="select-box" data-fieldName="projectSelectShow" catch:tap="pickerChange">
<view class="val" wx:if="{{selectProject.value > 0}}">{{projectOptions[selectProjectIndex].text}}</view>
<view class="placeholder" wx:else>请选择</view>
<view class="arrow"></view>
</view>
<!-- 项目下拉选择 -->
<van-popup show="{{showSelect.projectSelectShow}}" position="bottom" bind:close="hidePicker">
<van-picker data-fieldname="selectProject" data-fieldindex="selectProjectIndex" show-toolbar columns="{{projectOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
</van-picker>
</van-popup>
<!-- <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="row">
<view class="date" data-key="startDate" catchtap="showDate">
<input type="text" value="{{startDate}}" disabled="true" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="line"></view>
<view class="date" data-key="endDate" catchtap="showDate">
<input type="text" value="{{endDate}}" disabled="true" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="btn" catchtap="searchList">搜索</view>
</view>
</view>
<view class="list-content">
<view class="total">共 <view class="number">{{speedAlarmlistTotal}}</view> 条告警记录</view>
<view class="list">
<scroll-view class="scroll-view_H" scroll-y="true" bindscrolltolower="lower" style="width: 100%">
<view class="item" wx:for="{{speedAlarmList}}" wx:key="index" data-inf="{{item}}" catchtap="toDetail">
<view class="top">
<view class="number-plate">{{item.plateNumber}}</view>
<view class="t-right">
<view class="project-name">{{item.projectName}}</view>
</view>
</view>
<view class="row">
<view class="label">车速</view>
<view class="val">{{item.speed}}km/h</view>
</view>
<view class="row">
<view class="label">规定车速</view>
<view class="val">{{item.ruleSpeed}}km/h</view>
</view>
<view class="time-container">
<view class="time {{item.endTime ? 'normal' : ''}}">
<view class="val">{{item.startTime ? item.startTime : '/'}}</view>
<view class="label">开始时间</view>
</view>
<view class="time {{item.endTime ? 'normal' : ''}}">
<view class="val">{{item.endTime ? item.endTime : '/'}}</view>
<view class="label">结束时间</view>
</view>
<view class="time {{item.endTime ? 'normal' : 'error'}}">
<view class="val val-f16">{{item.durTime ? item.durTime : '/'}}</view>
<view class="label">持续时间</view>
</view>
</view>
</view>
<view class="is-last" wx:if="{{isLast && speedAlarmList.length > 0}}" style="padding-bottom: 40rpx;">
<van-divider contentPosition="center">已加载完全部数据</van-divider>
</view>
<view class="no-data" wx:if="{{speedAlarmList.length == 0}}">
<van-empty description="无数据" />
</view>
</scroll-view>
</view>
</view>
</van-tab>
<van-tab title="停车超时告警">
<view class="search-container">
<view class="row">
<view class="number-plate" catchtap="toSearch">
<view class="icon_search">
<image src="../../../images/icon_search.png" mode="" />
</view>
<input type="text" placeholder="搜索车辆" placeholder-style="color:#949CB5; font-size: 28rpx; font-weight: 400;" value="{{ plateNumber }}" disabled="true" bindinput="getPassword" />
<view class="btn" data-type="1" catchtap="clearValue">
<van-icon name="close" />
</view>
</view>
</view>
<view class="row">
<view class="status-select">
<view class="select-box" data-fieldName="satausSelectShow" catch:tap="pickerChange">
<view class="val" wx:if="{{true}}">{{statusOptions[selectStatusIndex].text}}</view>
<view class="placeholder" wx:else>请选择</view>
<view class="arrow"></view>
</view>
<!-- 项目下拉选择 -->
<van-popup show="{{showSelect.satausSelectShow}}" position="bottom" bind:close="hidePicker">
<van-picker data-fieldname="sataus" default-index="{{ selectStatusIndex }}" data-fieldindex="selectStatusIndex" show-toolbar columns="{{statusOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
</van-picker>
</van-popup>
</view>
<view class="project-select">
<view class="select-box" data-fieldName="projectSelectShow" catch:tap="pickerChange">
<view class="val" wx:if="{{selectProject.value > 0}}">{{projectOptions[selectProjectIndex].text}}</view>
<view class="placeholder" wx:else>请选择</view>
<view class="arrow"></view>
</view>
<!-- 项目下拉选择 -->
<van-popup show="{{showSelect.projectSelectShow}}" position="bottom" bind:close="hidePicker">
<van-picker data-fieldname="selectProject" data-fieldindex="selectProjectIndex" show-toolbar columns="{{projectOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
</van-picker>
</van-popup>
<!-- <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="row">
<view class="date" data-key="startDate" catchtap="showDate">
<input type="text" value="{{startDate}}" disabled="true" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="line"></view>
<view class="date" data-key="endDate" catchtap="showDate">
<input type="text" value="{{endDate}}" disabled="true" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="btn" catchtap="searchList">搜索</view>
</view>
</view>
<view class="list-content">
<view class="total">共 <view class="number">{{overTimeAlarmlistTotal}}</view> 条告警记录</view>
<view class="list">
<scroll-view class="scroll-view_H" scroll-y="true" bindscrolltolower="lower" style="width: 100%">
<view class="item" wx:for="{{overTimeAlarmList}}" wx:key="index" data-inf="{{item}}" catchtap="toDetail">
<view class="top">
<view class="number-plate">{{item.plateNumber}}</view>
<view class="t-right">
<view class="project-name">{{item.projectName}}</view>
</view>
</view>
<view class="row">
<view class="label">停车时长</view>
<view class="val">{{item.stopTime ? item.stopTime + '秒' : '/'}}</view>
</view>
<view class="time-container">
<view class="time {{item.endTime ? 'normal' : ''}}">
<view class="val">{{item.startTime ? item.startTime : '/'}}</view>
<view class="label">开始时间</view>
</view>
<view class="time {{item.endTime ? 'normal' : ''}}">
<view class="val">{{item.endTime ? item.endTime : '/'}}</view>
<view class="label">结束时间</view>
</view>
<view class="time {{item.endTime ? 'normal' : 'error'}}">
<view class="val val-f16">{{item.durTime ? item.durTime : '/'}}</view>
<view class="label">持续时间</view>
</view>
</view>
</view>
<view class="is-last" wx:if="{{isLast && overTimeAlarmList.length > 0}}" style="padding-bottom: 40rpx;">
<van-divider contentPosition="center">已加载完全部数据</van-divider>
</view>
<view class="no-data" wx:if="{{overTimeAlarmList.length == 0}}">
<van-empty description="无数据" />
</view>
</scroll-view>
</view>
</view>
</van-tab>
</van-tabs>
<!-- 日期范围选择 -->
<van-popup show="{{ showDateSelect }}" position="bottom" custom-style="height: 60%;" bind:click-overlay="hideDate">
<view style="background: #fff;border-radius: 4px 4px 0 0;overflow: hidden;">
<view class="date-btn-box">
<view class="btn btn-cancel" bindtap="hideDate">取消</view>
<view class="title">选择开始结束时间</view>
<view class="btn btn-confirm" bindtap="changeDate">确定</view>
</view>
<view class="date-title">
<view class="date {{selectDate == 'startDate' ? 'select' : ''}}" data-key="startDate" catchtap="changeSelectDate">
<input type="text" value="{{startDateTmp}}" disabled="true" bindinput="getPassword" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
<view class="line"></view>
<view class="date {{selectDate == 'endDate' ? 'select' : ''}}" data-key="endDate" catchtap="changeSelectDate">
<input type="text" value="{{endDateTmp}}" disabled="true" bindinput="getPassword" />
<view class="icon">
<image src="../../../images/icon_cal.png" mode="" />
</view>
</view>
</view>
<view class="picker-box">
<picker-view data-key="dateRang" value="{{dateValue}}" indicator-style="height: 50px;" style="width: 100%; height: 500rpx;" bindchange="selectDate">
<picker-view-column>
<view style="line-height: 50px; text-align: center;" wx:for="{{dateList.years}}" wx:key="index">{{item}}年</view>
</picker-view-column>
<picker-view-column>
<view style="line-height: 50px; text-align: center;" wx:for="{{dateList.months}}" wx:key="index">{{item}}月</view>
</picker-view-column>
<picker-view-column>
<view style="line-height: 50px; text-align: center;" wx:for="{{dateList.date}}" wx:key="index">{{item}}日</view>
</picker-view-column>
</picker-view>
</view>
</view>
</van-popup>
</view>
@@ -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>
@@ -0,0 +1,6 @@
{
"usingComponents": {
"van-popup": "@vant/weapp/popup/index"
},
"navigationBarTitleText": "车辆详情"
}
@@ -0,0 +1,231 @@
/* pages/vehicleMonitoring/realtime/realtime.wxss */
.container {
width: 100vw;
height: 100vh;
position: relative;
#map-container {
width: 100%;
// height: 100%;
height: 30%;
position: absolute;
}
.h100 {
height: 100% !important;
}
.btn {
width: 28px;
height: 28px;
background: #FFFFFF;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.2);
border-radius: 4px;
display: flex;
align-items: center;
position: absolute;
justify-content: center;
right: 8px;
z-index: 10;
image {
width: 14px;
height: 14px;
display: block;
}
}
.reload {
top: 8px;
}
.navigation {
top: 42px;
}
.inf-container {
width: 100%;
height: 70vh;
padding: 0 8px;
box-sizing: border-box;
background: #FFFFFF;
box-shadow: 0px 0px 16px 0px rgba(0, 0, 0, 0.1);
border-radius: 24px 24px 8px 8px;
position: absolute;
bottom: 0;
overflow: hidden;
.top {
width: 100%;
height: 18px;
display: flex;
justify-content: center;
align-items: center;
.line {
width: 48px;
height: 4px;
background: #CBCACA;
border-radius: 2px;
}
}
.base-inf {
padding: 0 10px 6px;
.row {
margin-bottom: 4px;
font-size: 14px;
display: flex;
justify-content: space-between;
align-items: center;
.number-plate {
color: #333333;
font-size: 16px;
font-weight: bold;
}
.code {
color: #888888;
}
.project-name {
color: #2E3A4F;
}
.car-type {
height: 20px;
padding: 0 8px;
box-sizing: border-box;
border-radius: 2px;
border: 1px solid #3977F7;
color: #4381FC;
}
}
}
.detail-inf {
height: calc(100% - 74px);
border-top: 1px solid #DFDFDF;
display: flex;
.sidebar {
width: 82px;
height: 100%;
background: #EFF1F4;
.item {
width: 82px;
height: 40px;
box-shadow: inset 0px -1px 0px 0px #DFDFDF;
font-size: 14px;
display: flex;
justify-content: center;
align-items: center;
}
.select {
background: #FFFFFF;
border-left: 4px solid #3977F7;
box-sizing: border-box;
color: #4381FC;
font-weight: bold;
}
}
.content {
width: calc(100% - 80px);
padding: 0 6px;
box-sizing: border-box;
overflow-y: auto;
.row {
padding: 0 6px;
min-height: 28px;
display: flex;
justify-content: space-between;
align-items: center;
white-space: nowrap;
.label {
color: #8A90A4;
}
.val {
color: #2E3A4F;
font-size: 14px;
white-space: pre-wrap;
text-align: right;
word-break: break-all;
}
.width74{
width: 74%;
}
.val-r {
color: #EA4955;
}
.online,
.offline,
.errline {
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);
}
.errline {
background: #FFF1F0;
border: 1px solid #FFA39E;
color: #FF4D4F;
}
.fileList {
width: 80%;
.file {
text-align: right;
.label {
padding: 4px 0;
// width: 80%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #409EFF;
word-wrap: break-word;
word-break: break-all;
white-space: pre-line;
}
.check {
font-size: 14px;
color: #409EFF;
}
}
}
}
.row:nth-child(2n) {
background: #F5F7FA;
}
}
}
}
}
@@ -0,0 +1,845 @@
// pages/vehicleMonitoring/realtime/realtime.ts
import { getAction } from '../../../api/base';
var QQMapWX = require('../../../utils/qqmap-wx-jssdk.min.js');
// 实例化API核心类
var qqmapsdk = new QQMapWX({
key: 'KDEBZ-EV5KH-XN5DU-WYZGD-SN3YK-WZBZI'
});
Page({
/**
* 页面的初始数据
*/
data: {
mapCenter: {
longitude: '104.06439',
latitude: '30.57812'
},
mapObj: null as any,
carMarkers: [],
setting: {
scale: 10
},
show: true,
tabs: [
{
tabName: '实时状态'
},
{
tabName: '整车数据'
},
{
tabName: '报警数据'
},
{
tabName: '电机'
}
] as any,
activeIndex: 0,
infObj: {} as any,
address: '',
tmpOptions: {
gpsTime: {
key: 'gpsTime',
value: '-',
label: '定位时间'
},
totalMileage: {
key: 'totalMileage',
value: '-',
label: '里程'
},
acc_dictText: {
key: 'acc_dictText',
value: '-',
label: '点火状态'
},
isOnline: {
key: 'isOnline',
value: '-',
label: '在线状态'
},
// {
// key: '',
// value: '-',
// label: 'GPS定位'
// },
chargeStatus_dictText: {
key: 'chargeStatus_dictText',
value: '-',
label: '充电状态'
},
alert: {
key: 'alert',
value: '-',
label: '告警'
},
// stateOfCharge:{
// key: 'stateOfCharge',
// value: '-',
// label: '剩余电量'
// },
maxRpm: {
key: 'maxRpm',
value: '-',
label: '转速'
},
speed: {
key: 'speed',
value: '-',
label: '速度'
},
stateOfCharge: {
key: 'stateOfCharge',
value: '-',
label: 'SOC'
}
} as any,
tmpOptions1: {
status: {
key: 'status',
value: '-',
label: '车辆状态'
},
speed: {
key: 'speed',
value: '-',
label: '速度'
},
totalCurrent: {
key: 'totalCurrent',
value: '-',
label: '总电流'
},
gearPosition: {
key: 'gearPosition',
value: '-',
label: '档位'
},
// chargeStatus_dictText:{
// key: 'chargeStatus_dictText',
// value: '-',
// label: '制动踏板状态'
// },
chargeStatus: {
key: 'chargeStatus',
value: '-',
label: '充电状态'
},
totalMileage: {
key: 'totalMileage',
value: '-',
label: '累计里程'
},
stateOfCharge: {
key: 'stateOfCharge',
value: '-',
label: 'SOC值'
},
insulationResistance: {
key: 'insulationResistance',
value: '-',
label: '绝缘电阻'
},
// maxRpm:{
// key: 'maxRpm',
// value: '-',
// label: '驱动力状态'
// },
operatingMode: {
key: 'operatingMode',
value: '-',
label: '运行模式'
},
totalVoltage: {
key: 'totalVoltage',
value: '-',
label: '总电压'
},
dcDcStatus: {
key: 'dcDcStatus',
value: '-',
label: 'DC-DC状态'
}
} as any,
tmpOptions2: {
maxAlarmLevel: {
key: 'maxAlarmLevel',
value: '-',
label: '最高报警等级'
},
batteryHighTemperatureAlarm: {
key: 'batteryHighTemperatureAlarm',
value: '-',
label: '电池高温报警'
},
underVoltageAlarm: {
key: 'underVoltageAlarm',
value: '-',
label: '车载储能装欠压报警'
},
overVoltageSingleBatteryAlarm: {
key: 'overVoltageSingleBatteryAlarm',
value: '-',
label: '单体电池过压报警'
},
highSocAlarm: {
key: 'highSocAlarm',
value: '-',
label: 'SOC过高报警'
},
mismatchedEnergyStorageAlarm: {
key: 'mismatchedEnergyStorageAlarm',
value: '-',
label: '可充电储能不匹配报警'
},
dcDcTemperatureAlarm: {
key: 'dcDcTemperatureAlarm',
value: '-',
label: 'DC-DC温度报警'
},
overChargeAlarm: {
key: 'overChargeAlarm',
value: '-',
label: '车载储能装置过充报警'
},
insulationAlarm: {
key: 'insulationAlarm',
value: '-',
label: '绝缘报警'
},
brakeSystemAlarm: {
key: 'brakeSystemAlarm',
value: '-',
label: '制动系统报警'
},
motorControllerTemperatureAlarm: {
key: 'motorControllerTemperatureAlarm',
value: '-',
label: '驱动电机控制器温度报警'
},
driveMotorTemperatureAlarm: {
key: 'driveMotorTemperatureAlarm',
value: '-',
label: '驱动电机温度报警'
},
energyStorageFaultCount: {
key: 'energyStorageFaultCount',
value: '-',
label: '可充电储能装置故障总数'
},
dcDcStatusAlarm: {
key: 'dcDcStatusAlarm',
value: '-',
label: 'DC-DC状态报警'
},
driveMotorFaultCount: {
key: 'driveMotorFaultCount',
value: '-',
label: '驱动电机故障总数:'
},
engineFaultCount: {
key: 'engineFaultCount',
value: '-',
label: '发动电机故障总数:'
},
temperatureDifferenceAlarm: {
key: 'temperatureDifferenceAlarm',
value: '-',
label: '温度差异报警'
},
overVoltageAlarm: {
key: 'overVoltageAlarm',
value: '-',
label: '车载储能装置过压报警'
},
lowSocAlarm: {
key: 'lowSocAlarm',
value: '-',
label: 'SOC过低报警'
},
underVoltageSingleBatteryAlarm: {
key: 'underVoltageSingleBatteryAlarm',
value: '-',
label: '单体电池欠压报警'
},
socJumpAlarm: {
key: 'socJumpAlarm',
value: '-',
label: 'SOC跳变报警'
},
batteryInconsistencyAlarm: {
key: 'batteryInconsistencyAlarm',
value: '-',
label: '电池单体一致性差报警'
},
highVoltageInterlockStatusAlarm: {
key: 'highVoltageInterlockStatusAlarm',
value: '-',
label: '高压互锁状态报警'
}
} as any,
tmpOptions3: {
temperature: {
key: 'temperature',
value: '-',
label: '电机温度'
},
controllerTemperature: {
key: 'controllerTemperature',
value: '-',
label: '电机控制器温度'
}
} as any,
tmpOptions4: {
number: {
key: 'number',
value: '-',
label: '序号'
},
status: {
key: 'status',
value: '-',
label: '状态'
},
controllerTemperature: {
key: 'controllerTemperature',
value: '-',
label: '控制器温度'
},
temperature: {
key: 'temperature',
value: '-',
label: '温度'
},
torque: {
key: 'torque',
value: '-',
label: '转矩'
},
inputVoltage: {
key: 'inputVoltage',
value: '-',
label: '控制器输入电压'
},
dcBusCurrent: {
key: 'dcBusCurrent',
value: '-',
label: '直流母线电流'
}
} as any,
tmpOptions5: {
compulsoryCompanyId_dictText: {
key: 'compulsoryCompanyId_dictText',
value: '-',
label: '保险公司'
},
compulsoryStartTime: {
key: 'compulsoryStartTime',
value: '-',
label: '起保日期'
},
compulsoryValidTime: {
key: 'compulsoryValidTime',
value: '-',
label: '有效日期'
},
compulsoryInsuranceNo: {
key: 'compulsoryInsuranceNo',
value: '-',
label: '交强险(保单号)'
},
compulsoryUrl: {
key: 'compulsoryUrl',
value: '-',
label: '交强险'
},
commercialInsuranceNo: {
key: 'commercialInsuranceNo',
value: '-',
label: '商业险(保单号)'
},
commercialUrl: {
key: 'commercialUrl',
value: '-',
label: '商业险'
}
} as any
},
init() {
this.data.mapObj = wx.createMapContext('map-container');
},
showPopup() {
this.setData({ show: true });
this.init();
},
onClose() {
this.setData({ show: false });
this.init();
},
changeTab(e: any) {
console.log(e.currentTarget.dataset);
this.setData({
activeIndex: e.currentTarget.dataset.index
});
},
reloadData() {
this.getRealInfo();
},
// 导航
navigate() {
let mapCenter = this.data.mapCenter;
this.data.mapObj.openMapApp({
longitude: mapCenter.longitude,
latitude: mapCenter.latitude,
destination: this.data.address,
fail: () => {
wx.showToast({
title: '获取定位失败,请开启定位服务',
icon: 'none'
});
}
});
},
getAddress(position: any) {
var _this = this;
qqmapsdk.reverseGeocoder({
location: position,
success: function (res: any) {
//成功后的回调
console.log(res.result.address);
// var res = res.result;
_this.setData({
address: res.result.address
});
_this.setMarker();
}
});
},
getRealInfo() {
let parms = {
plateNumber: wx.getStorageSync('selectCar').plateNumber
};
getAction('api/monitor/vehicle/realInfo', parms).then((res: any) => {
if (res.code == 200) {
console.log(res);
this.getAddress({
latitude: res.result.gdLat,
longitude: res.result.gdLon
});
let tmpOptions = this.data.tmpOptions;
let tmpOptions1 = this.data.tmpOptions1;
for (let key in tmpOptions) {
if (key != 'alert') {
if (!res.result[key]) {
continue;
}
}
tmpOptions[key].value = res.result[key] ? res.result[key] : '-';
tmpOptions[key].type = 'val';
if (key == 'acc_dictText') {
tmpOptions[key].type = 'online';
tmpOptions[key].value = res.result.isOnline ? '点火' : '熄火';
}
if (key == 'isOnline') {
tmpOptions[key].type = 'online';
tmpOptions[key].value = res.result.isOnline ? '在线' : '离线';
}
if (key == 'alert') {
// "faultAlarm": 1, //故障报警 0-正常 1-异常
// "fenceAlarm": 1, //围栏告警 0-正常 1-异常
// "speedingAlarm": 1, //超速告警 0-正常 1-异常
// "safetyAlarm": 1, //主动安全告警-0-正常 1-异常
tmpOptions[key].type = 'errline';
if (res.result.faultAlarm) {
tmpOptions[key].value = res.result.faultAlarm ? '故障' : '';
} else if (res.result.fenceAlarm) {
tmpOptions[key].value = res.result.fenceAlarm ? '围栏' : '';
} else if (res.result.speedingAlarm) {
tmpOptions[key].value = res.result.speedingAlarm ? '超速' : '';
} else if (res.result.safetyAlarm) {
tmpOptions[key].value = res.result.safetyAlarm ? '主动安全' : '';
} else {
tmpOptions[key].type = 'offline';
tmpOptions[key].value = '无告警';
}
}
if (key == 'totalMileage') {
tmpOptions[key].value += 'km';
}
if (key == 'maxRpm') {
tmpOptions[key].value += 'r/min';
}
if (key == 'speed') {
tmpOptions[key].value += 'km/h';
}
if (key == 'stateOfCharge') {
tmpOptions[key].value += '%';
}
}
for (let key in tmpOptions1) {
if (!res.result.vehicleJSONObject) {
break;
}
if (!res.result.vehicleJSONObject[key]) {
continue;
}
tmpOptions1[key].value = res.result.vehicleJSONObject[key]
? res.result.vehicleJSONObject[key]
: '-';
if (key == 'status') {
// 1: '启动',
// 2: '熄火',
// 3: '其他',
// '-99': '无效',
// '-100': '异常'
switch (res.result[key]) {
case 1:
tmpOptions1[key].value = '启动';
break;
case 2:
tmpOptions1[key].value = '熄火';
break;
case 3:
tmpOptions1[key].value = '其他';
break;
case -99:
tmpOptions1[key].value = '无效';
break;
case -100:
tmpOptions1[key].value = '异常';
break;
}
}
if (key == 'chargeStatus') {
// 1-停车充电、2-行驶充电、3-未充电 4-充电完成、-99-无效、-100-异常
switch (res.result[key]) {
case 1:
tmpOptions1[key].value = '停车充电';
break;
case 2:
tmpOptions1[key].value = '行驶充电';
break;
case 3:
tmpOptions1[key].value = '未充电';
break;
case 4:
tmpOptions1[key].value = '充电完成';
break;
case -99:
tmpOptions1[key].value = '无效';
break;
case -100:
tmpOptions1[key].value = '异常';
break;
}
}
if (key == 'operatingMode') {
// 运行模式 1-纯电 2-混动 3-燃油 -99-无效、-100-异常
switch (res.result[key]) {
case 1:
tmpOptions1[key].value = '纯电';
break;
case 2:
tmpOptions1[key].value = '混动';
break;
case 3:
tmpOptions1[key].value = '燃油';
break;
case -99:
tmpOptions1[key].value = '无效';
break;
case -100:
tmpOptions1[key].value = '异常';
break;
}
}
if (key == 'gearPosition') {
tmpOptions1[key].value = res.result[key] ? res.result[key] : '-';
}
if (key == 'speed') {
tmpOptions1[key].value += 'km/h';
}
if (key == 'stateOfCharge') {
tmpOptions1[key].value += '%';
}
if (key == 'totalVoltage') {
tmpOptions1[key].value += 'V';
}
if (key == 'totalCurrent') {
tmpOptions1[key].value =
Math.floor(tmpOptions1[key].value * 100) / 100;
tmpOptions1[key].value += 'A';
}
if (key == 'insulationResistance') {
tmpOptions1[key].value += 'kn';
}
if (key == 'dcDcStatus') {
tmpOptions1[key].value =
tmpOptions1[key].value == 1 ? '工作' : '断开';
}
if (key == 'totalMileage') {
tmpOptions1[key].value =
Math.floor(tmpOptions1[key].value * 100) / 100;
}
}
let tmpOptions2 = this.data.tmpOptions2;
for (let key in tmpOptions2) {
if (!res.result.alarmDataJSONObject) {
break;
}
if (
res.result.alarmDataJSONObject[key] == undefined ||
res.result.alarmDataJSONObject[key] == null
) {
continue;
}
tmpOptions2[key].value = res.result.alarmDataJSONObject[key]
? '报警'
: '正常';
if (res.result.alarmDataJSONObject[key] == 1) {
tmpOptions2[key].type = 'val-r';
}
if (key == 'maxAlarmLevel') {
tmpOptions2[key].value =
res.result.alarmDataJSONObject[key] + '级别';
tmpOptions2[key].type = '';
}
if (key == 'energyStorageFaultCount') {
tmpOptions2[key].value = res.result.alarmDataJSONObject[key]
? res.result.alarmDataJSONObject[key]
: '0';
tmpOptions2[key].type = '';
}
if (key == 'engineFaultCount') {
tmpOptions2[key].value = res.result.alarmDataJSONObject[key]
? res.result.alarmDataJSONObject[key]
: '0';
tmpOptions2[key].type = '';
}
if (key == 'driveMotorFaultCount') {
tmpOptions2[key].value = res.result.alarmDataJSONObject[key]
? res.result.alarmDataJSONObject[key]
: '0';
tmpOptions2[key].type = '';
}
}
let tmpOptions3 = this.data.tmpOptions3;
for (let key in tmpOptions3) {
if (!res.result.electricMotorJSONArray) {
break;
}
console.log(key, res.result.electricMotorJSONArray[0]);
tmpOptions3[key].value = res.result.electricMotorJSONArray[0][key]
? res.result.electricMotorJSONArray[0][key]
: '-';
tmpOptions3[key].value += '℃';
}
let tabs = this.data.tabs;
if (res.result.electricMotorJSONArray) {
res.result.electricMotorJSONArray.map((x: any) => {
let tmpOptions4 = this.data.tmpOptions4;
for (let key in tmpOptions4) {
tmpOptions4[key].value = x[key] ? x[key] : '-';
if (key == 'controllerTemperature' || key == 'temperature') {
tmpOptions4[key].value += '℃';
}
if (key == 'inputVoltage') {
tmpOptions4[key].value += 'V';
}
if (key == 'dcBusCurrent') {
if (tmpOptions4[key].value.indexOf('A') == -1) {
tmpOptions4[key].value += 'A';
}
}
if (key == 'rpm') {
tmpOptions4[key].value += 'r/min';
}
if (key == 'dcBusCurrent') {
tmpOptions4[key].value += 'A';
}
}
tabs.push({
tabName: '驱动电机' + x.number,
options: tmpOptions4
});
});
}
tabs.push({
tabName: '保险信息'
});
let tmpOptions5 = this.data.tmpOptions5;
for (let key in tmpOptions5) {
if (key == 'compulsoryUrl' || key == 'commercialUrl') {
if (res.result.insuranceInfo[key]) {
let list = res.result.insuranceInfo[key].split(',');
tmpOptions5[key].value = list.map((item: string) => {
return {
label: item.split('/')[item.split('/').length - 1],
url: item
};
});
} else tmpOptions5[key].value = res.result.insuranceInfo[key];
} else tmpOptions5[key].value = res.result.insuranceInfo[key];
}
console.log(tabs);
this.setData({
tabs: tabs,
infObj: res.result,
tmpOptions: tmpOptions,
tmpOptions1: tmpOptions1,
tmpOptions2: tmpOptions2,
tmpOptions3: tmpOptions3,
tmpOptions5: tmpOptions5,
mapCenter: {
latitude: res.result.gdLat,
longitude: res.result.gdLon
},
setting: { scale: 10 }
});
} else {
wx.showToast({
title: res.message,
icon: 'none'
});
}
});
},
setMarker() {
let tmp = [] as any;
let imgUrl = '../../../images/car_select.png';
tmp.push({
id: 0,
latitude: this.data.infObj.gdLat,
longitude: this.data.infObj.gdLon,
iconPath: imgUrl,
anchor: {
// 经纬度在标注图标的锚点,
x: 0.5,
y: 1
},
width: 48,
height: 55,
label: {
content: this.data.address,
color: '#FFFFFF',
display: 'ALWAYS',
fontSize: 13,
borderRadius: 4,
bgColor: '#2C6AF3',
textAlign: 'center',
anchorY: 20,
padding: 8
}
});
console.log(tmp);
this.setData({
carMarkers: tmp
});
},
// 查看文件
checkFile(event: any) {
let url = event.currentTarget.dataset.url;
let type = url.split('.')[url.split('.').length - 1];
if (type == 'jpg' || type == 'jpeg' || type == 'png') {
wx.previewImage({
current: url, // 当前显示图片的http链接
urls: [url] // 需要预览的图片http链接列表
});
} else {
wx.showLoading({
title: '数据加载中'
});
wx.downloadFile({
// 示例 url,并非真实存在
url: url,
success: function (res) {
const filePath = res.tempFilePath;
wx.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
wx.hideLoading();
},
fail: function () {
wx.hideLoading();
}
});
},
fail: function () {
wx.hideLoading();
}
});
}
console.log(url);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
this.setData({
tabs: [
{
tabName: '实时状态'
},
{
tabName: '整车数据'
},
{
tabName: '报警数据'
},
{
tabName: '电机'
}
]
});
this.getRealInfo();
this.init();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
});
@@ -0,0 +1,74 @@
<!--pages/vehicleMonitoring/realtime/realtime.wxml-->
<view class="container">
<map id="map-container" class="{{show ? '' : 'h100'}}" longitude="{{mapCenter.longitude}}" latitude="{{mapCenter.latitude}}" markers="{{carMarkers}}" include-points="{{carMarkers}}" scale="{{setting.scale}}" setting="{{setting}}" name="" bindmarkertap="showPopup">
</map>
<view class="reload btn" catch:tap="reloadData">
<image src="../../../images/icon_reload.png" mode="" />
</view>
<view class="navigation btn" catch:tap="navigate">
<image src="../../../images/icon_navigation.png" mode="" />
</view>
<van-popup show="{{ show }}" round custom-style="box-shadow: 0px 0px 16px 0px rgba(0,0,0,0.1);" overlay-style="display: none;" position="bottom" custom-style="height: 70%;" bind:close="onClose">
<view class="inf-container">
<view class="top" catch:tap="onClose" capture-catch:touchmove="">
<view class="line"></view>
</view>
<view class="base-inf">
<view class="row">
<view class="number-plate">{{infObj.plateNumber}}</view>
<view class="code">{{infObj.vinCode}}</view>
</view>
<view class="row">
<view class="project-name">{{infObj.projectId_dictText}}</view>
<view class="car-type">
{{infObj.vehicleType_dictText ? infObj.vehicleType_dictText : '车辆型号未知'}}
</view>
</view>
</view>
<view class="detail-inf">
<view class="sidebar">
<view class="item {{ activeIndex == index ? 'select' : '' }}" wx:for="{{ tabs }}" wx:key="index" data-index="{{index}}" data-inf="{{item}}" catch:tap="changeTab">
{{item.tabName}}
</view>
</view>
<view class="content">
<view class="row" wx:if="{{activeIndex == 0}}" wx:for="{{ tmpOptions }}" wx:key="index" data-index="{{index}}">
<view class="label">{{item.label}}</view>
<view class="val {{item.type == 'val' ? '' : item.type}}">{{item.value}}</view>
</view>
<view class="row" wx:if="{{activeIndex == 1}}" wx:for="{{ tmpOptions1 }}" wx:key="index" data-index="{{index}}">
<view class="label">{{item.label}}</view>
<view class="val {{item.type == 'val' ? '' : item.type}}">{{item.value}}</view>
</view>
<view class="row" wx:if="{{activeIndex == 2}}" wx:for="{{ tmpOptions2 }}" wx:key="index" data-index="{{index}}">
<view class="label">{{item.label}}</view>
<view class="val {{item.type == 'val' ? '' : item.type}}">{{item.value}}</view>
</view>
<view class="row" wx:if="{{activeIndex == 3}}" wx:for="{{ tmpOptions3 }}" wx:key="index" data-index="{{index}}">
<view class="label">{{item.label}}</view>
<view class="val {{item.type == 'val' ? '' : item.type}}">{{item.value}}</view>
</view>
<view class="row" wx:if="{{activeIndex > 3 && activeIndex < tabs.length - 1}}" wx:for="{{ tabs[activeIndex].options }}" wx:key="index" data-index="{{index}}">
<view class="label">{{item.label}}</view>
<view class="val {{item.type == 'val' ? '' : item.type}}">{{item.value}}</view>
</view>
<!-- 保险信息 -->
<view class="row" wx:if="{{activeIndex == tabs.length - 1}}" wx:for="{{ tmpOptions5 }}" wx:key="index" data-index="{{index}}">
<view class="label">{{item.label}}</view>
<view class="val width74" wx:if="{{item.key != 'compulsoryUrl' && item.key != 'commercialUrl'}}">{{item.value || '-'}}</view>
<view wx:else class="fileList">
<block wx:if="{{item.value}}">
<view wx:for="{{ item.value }}" wx:for-item='file' class="file">
<view class="val label" catch:tap="checkFile" data-url="{{file.url}}">{{file.label}}</view>
<!-- <view class="check" catch:tap="checkFile" data-url="{{file.url}}">查看</view> -->
</view>
</block>
<view wx:else style="text-align: right;">-</view>
</view>
</view>
</view>
</view>
</view>
</van-popup>
</view>