肖凡4.8提交

yinyuyang^2
肖凡 2024-04-08 10:20:16 +08:00
parent 3eab588178
commit 1e9f7abf01
3 changed files with 46 additions and 46 deletions

View File

@ -55,7 +55,7 @@ service.interceptors.request.use(config => {
const s_url = sessionObj.url; // 请求地址 const s_url = sessionObj.url; // 请求地址
const s_data = sessionObj.data; // 请求数据 const s_data = sessionObj.data; // 请求数据
const s_time = sessionObj.time; // 请求时间 const s_time = sessionObj.time; // 请求时间
const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 const interval = 500; // 间隔时间(ms),小于此时间视为重复提交
if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
const message = '数据正在处理,请勿重复提交'; const message = '数据正在处理,请勿重复提交';
console.warn(`[${s_url}]: ` + message) console.warn(`[${s_url}]: ` + message)

View File

@ -163,7 +163,7 @@
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-eleme"
@click="$router.push({ @click="$router.push({
path:'track', path:'track',
query:{ query:{

View File

@ -1,9 +1,16 @@
<template> <template>
<div id="container"></div> <div>
<div id="container" style="width: 25%; height: 250px;"></div>
<div>
{{carData}}
</div>
</div>
</template> </template>
<script> <script>
import AMapLoader from "@amap/amap-jsapi-loader"; import AMapLoader from "@amap/amap-jsapi-loader";
import {getRealTimeData} from "@/api/system/car";
import {getRealTimeDataTwo} from "@/api/system/car"; import {getRealTimeDataTwo} from "@/api/system/car";
@ -13,21 +20,23 @@ export default {
return { return {
carPosition: ["116.397428", "39.90923"], // carPosition: ["116.397428", "39.90923"], //
carMarker: null, // Marker carMarker: null, // Marker
animationInterval:null// animationInterval:null,//
lastUpdateTime:0,//
animationFramId:null,//ID
carData:[],//
}; };
}, },
mounted() { mounted() {
this.initAMap(); this.initAMap()
// this.getRealTimeDataAndUpdatePosition(this.$route.query.carVin); //
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.animationInterval);// clearInterval(this.animationInterval);//
this.map?.destroy(); this.map?.destroy();
cancelAnimationFrame(this.animationFramId);//
}, },
methods: { methods: {
initAMap() { initAMap() {
AMapLoader.load({ AMapLoader.load({
key: "e7398786b61ee782417e1749de1f2b39", // WebKey load key: "e7398786b61ee782417e1749de1f2b39", // WebKey load
@ -57,53 +66,44 @@ export default {
}); });
}, },
startCarAnimation() { startCarAnimation() {
this.animationInterval = setInterval(() => { // this.animationInterval = setInterval(() => {
let vin=this.$route.query.carVin; // let vin = this.$route.query.carVin;
// this.getRealTimeDataAndUpdatePosition(vin);
// }, 1000);
const animate = () => {
const currentTime = Date.now();
const deltaTime = currentTime - this.lastUpdateTime;
if (deltaTime > 1000) {
//
this.lastUpdateTime = currentTime;
let vin = this.$route.query.carVin;
this.getRealTimeDataAndUpdatePosition(vin); this.getRealTimeDataAndUpdatePosition(vin);
}, 1000); }
this.animationFramId = requestAnimationFrame(animate);
};
this.animationFramId = requestAnimationFrame(animate);
}, },
getRealTimeDataAndUpdatePosition(vin){ 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) getRealTimeDataTwo(vin)
.then(response=>{ .then(response => {
// debugger console.log('Response from getRealTimeDataTwo:', response);
// { longitude: ..., latitude: ... } // this.$message.success('Real-time data:',response);
this.$message.success('Real-time data:',response); this.carData = response
let carData=response
// //
this.carPosition=[carData.longitude,carData.latitude]; this.carPosition = [this.carData.longitude, this.carData.latitude];
// debugger
//Marker //Marker
this.carMarker.setPosition(this.carPosition); this.carMarker.setPosition(this.carPosition);
//
}) })
// .catch(error=>{ },
// console.error("Error fetching real-time data:",error)
// });
}
}, },
}; };
</script> </script>
<style scoped> <style scoped>
#container {
width: 25%;
height: 250px;
}
.amap-marker-icon {
border: none !important; /* 移除Marker的边框 */
box-shadow: none !important; /* 移除Marker的阴影 */
}
</style> </style>