forked from huangdaju/cloud-ui
肖凡4.6提交
parent
184a5a9ddf
commit
3eab588178
|
@ -52,7 +52,9 @@
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"quill": "1.3.7",
|
"quill": "1.3.7",
|
||||||
"screenfull": "5.0.2",
|
"screenfull": "5.0.2",
|
||||||
|
"sockjs-client": "^1.6.1",
|
||||||
"sortablejs": "1.10.2",
|
"sortablejs": "1.10.2",
|
||||||
|
"stompjs": "^2.3.3",
|
||||||
"vue": "2.6.12",
|
"vue": "2.6.12",
|
||||||
"vue-count-to": "1.0.13",
|
"vue-count-to": "1.0.13",
|
||||||
"vue-cropper": "0.5.5",
|
"vue-cropper": "0.5.5",
|
||||||
|
|
|
@ -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'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -87,7 +87,22 @@ export const constantRoutes = [
|
||||||
meta: { title: '个人中心', icon: 'user' }
|
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: '实时轨迹' }
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// 动态路由,基于用户权限动态去加载
|
// 动态路由,基于用户权限动态去加载
|
||||||
|
|
|
@ -160,6 +160,15 @@
|
||||||
@click="handleDelete(scope.row)"
|
@click="handleDelete(scope.row)"
|
||||||
v-hasPermi="['system:car:remove']"
|
v-hasPermi="['system:car:remove']"
|
||||||
>删除</el-button>
|
>删除</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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
@ -218,6 +227,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {list, add, update, findById, del, exportA, selectFence,open,close} from "@/api/system/car";
|
import {list, add, update, findById, del, exportA, selectFence,open,close} from "@/api/system/car";
|
||||||
|
import {getRealTimeDataTwo} from "@/api/system/car";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Car",
|
name: "Car",
|
||||||
|
|
|
@ -3,22 +3,31 @@
|
||||||
</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";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "map-view",
|
name: "map-view",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
carPosition: [116.397428, 39.90923], // 初始化小汽车位置
|
carPosition: ["116.397428", "39.90923"], // 初始化小汽车位置
|
||||||
carMarker: null, // 存储小汽车Marker
|
carMarker: null, // 存储小汽车Marker
|
||||||
|
animationInterval:null//存储动画定时器
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initAMap();
|
this.initAMap();
|
||||||
},
|
},
|
||||||
unmounted() {
|
beforeDestroy() {
|
||||||
|
clearInterval(this.animationInterval);//清除定时器
|
||||||
this.map?.destroy();
|
this.map?.destroy();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
initAMap() {
|
initAMap() {
|
||||||
AMapLoader.load({
|
AMapLoader.load({
|
||||||
key: "e7398786b61ee782417e1749de1f2b39", // 申请好的Web端开发者Key,首次调用 load 时必填
|
key: "e7398786b61ee782417e1749de1f2b39", // 申请好的Web端开发者Key,首次调用 load 时必填
|
||||||
|
@ -30,7 +39,7 @@ export default {
|
||||||
// 设置地图容器id
|
// 设置地图容器id
|
||||||
viewMode: "3D", // 是否为3D地图模式
|
viewMode: "3D", // 是否为3D地图模式
|
||||||
zoom: 11, // 初始化地图级别
|
zoom: 11, // 初始化地图级别
|
||||||
center: [116.397428, 39.90923], // 初始化地图中心点位置
|
center: ["116.397428", "39.90923"], // 初始化地图中心点位置
|
||||||
});
|
});
|
||||||
|
|
||||||
// 车辆初始化
|
// 车辆初始化
|
||||||
|
@ -48,20 +57,42 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
startCarAnimation() {
|
startCarAnimation() {
|
||||||
setInterval(() => {
|
this.animationInterval = setInterval(() => {
|
||||||
// 更新小汽车位置
|
let vin=this.$route.query.carVin;
|
||||||
this.carPosition = this.getRandomPosition();
|
this.getRealTimeDataAndUpdatePosition(vin);
|
||||||
// 更新小汽车Marker的位置
|
|
||||||
this.carMarker.setPosition(this.carPosition);
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
getRandomPosition() {
|
getRealTimeDataAndUpdatePosition(vin){
|
||||||
// 模拟随机生成新的经纬度位置
|
// getRealTimeData().then(response=>{
|
||||||
const delta = 0.01; // 控制随机位置变化的大小
|
// // 假设实时数据的格式为 { longitude: ..., latitude: ... }
|
||||||
const lat = this.carPosition[0] + (Math.random() - 0.5) * delta;
|
// const realTimeData = response.data; // 假设实时数据在 response.data 中
|
||||||
const lng = this.carPosition[1] + (Math.random() - 0.5) * delta;
|
// this.$message.success('Real-time data:',response.data)
|
||||||
return [lat, lng];
|
// // 更新小汽车位置
|
||||||
},
|
// 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>
|
</script>
|
||||||
|
@ -70,4 +101,9 @@ export default {
|
||||||
width: 25%;
|
width: 25%;
|
||||||
height: 250px;
|
height: 250px;
|
||||||
}
|
}
|
||||||
|
.amap-marker-icon {
|
||||||
|
border: none !important; /* 移除Marker的边框 */
|
||||||
|
box-shadow: none !important; /* 移除Marker的阴影 */
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue