肖凡4.6提交

yinyuyang^2
肖凡 2024-04-06 21:55:27 +08:00
parent 184a5a9ddf
commit 3eab588178
5 changed files with 91 additions and 15 deletions

View File

@ -52,7 +52,9 @@
"nprogress": "0.2.0",
"quill": "1.3.7",
"screenfull": "5.0.2",
"sockjs-client": "^1.6.1",
"sortablejs": "1.10.2",
"stompjs": "^2.3.3",
"vue": "2.6.12",
"vue-count-to": "1.0.13",
"vue-cropper": "0.5.5",

View File

@ -73,3 +73,16 @@ export function findById(carId) {
}
export function getRealTimeData() {
return request({
url: '/analyze/realTimeData',
method: 'get'
})
}
export function getRealTimeDataTwo(vin) {
return request({
url: '/analyze/realTimeDataTwo/' +vin,
method: 'post'
})
}

View File

@ -87,7 +87,22 @@ export const constantRoutes = [
meta: { title: '个人中心', icon: 'user' }
}
]
},
{
path: '/track',
component: Layout,
hidden: true,
redirect: 'track',
children: [
{
path: 'index',
component: () => import('@/views/system/track/index'),
name: 'track',
meta: { title: '实时轨迹' }
}
]
}
]
// 动态路由,基于用户权限动态去加载

View File

@ -160,6 +160,15 @@
@click="handleDelete(scope.row)"
v-hasPermi="['system:car:remove']"
>删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="$router.push({
path:'track',
query:{
carVin:scope.row.carVin}})"
>实时轨迹查询</el-button>
</template>
</el-table-column>
</el-table>
@ -218,6 +227,7 @@
<script>
import {list, add, update, findById, del, exportA, selectFence,open,close} from "@/api/system/car";
import {getRealTimeDataTwo} from "@/api/system/car";
export default {
name: "Car",

View File

@ -3,22 +3,31 @@
</template>
<script>
import AMapLoader from "@amap/amap-jsapi-loader";
import {getRealTimeData} from "@/api/system/car";
import {getRealTimeDataTwo} from "@/api/system/car";
export default {
name: "map-view",
data() {
return {
carPosition: [116.397428, 39.90923], //
carPosition: ["116.397428", "39.90923"], //
carMarker: null, // Marker
animationInterval:null//
};
},
mounted() {
this.initAMap();
},
unmounted() {
beforeDestroy() {
clearInterval(this.animationInterval);//
this.map?.destroy();
},
methods: {
initAMap() {
AMapLoader.load({
key: "e7398786b61ee782417e1749de1f2b39", // WebKey load
@ -30,7 +39,7 @@ export default {
// id
viewMode: "3D", // 3D
zoom: 11, //
center: [116.397428, 39.90923], //
center: ["116.397428", "39.90923"], //
});
//
@ -48,20 +57,42 @@ export default {
});
},
startCarAnimation() {
setInterval(() => {
//
this.carPosition = this.getRandomPosition();
// Marker
this.carMarker.setPosition(this.carPosition);
this.animationInterval = setInterval(() => {
let vin=this.$route.query.carVin;
this.getRealTimeDataAndUpdatePosition(vin);
}, 1000);
},
getRandomPosition() {
//
const delta = 0.01; //
const lat = this.carPosition[0] + (Math.random() - 0.5) * delta;
const lng = this.carPosition[1] + (Math.random() - 0.5) * delta;
return [lat, lng];
},
getRealTimeDataAndUpdatePosition(vin){
// getRealTimeData().then(response=>{
// // { longitude: ..., latitude: ... }
// const realTimeData = response.data; // response.data
// this.$message.success('Real-time data:',response.data)
// //
// this.carPosition = [realTimeData.longitude, realTimeData.latitude];
// // Marker
// this.carMarker.setPosition(this.carPosition);
// })
// .catch((error)=>{
// console.error("Error fetching real-time data:",error);
// })
getRealTimeDataTwo(vin)
.then(response=>{
// debugger
// { longitude: ..., latitude: ... }
this.$message.success('Real-time data:',response);
let carData=response
//
this.carPosition=[carData.longitude,carData.latitude];
// debugger
//Marker
this.carMarker.setPosition(this.carPosition);
})
// .catch(error=>{
// console.error("Error fetching real-time data:",error)
// });
}
},
};
</script>
@ -70,4 +101,9 @@ export default {
width: 25%;
height: 250px;
}
.amap-marker-icon {
border: none !important; /* 移除Marker的边框 */
box-shadow: none !important; /* 移除Marker的阴影 */
}
</style>