From 94ff46df856f6d4f8d8393e22001351c793f4e5b Mon Sep 17 00:00:00 2001
From: wzp <2040239371@qq.com>
Date: 星期一, 05 五月 2025 16:44:36 +0800
Subject: [PATCH] feat: 新增payInfo测试和部分优化appsecret
---
ruoyi-ui/src/views/system/gps/map.vue | 174 ++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 109 insertions(+), 65 deletions(-)
diff --git a/ruoyi-ui/src/views/system/gps/map.vue b/ruoyi-ui/src/views/system/gps/map.vue
index 2e93143..a9ee044 100644
--- a/ruoyi-ui/src/views/system/gps/map.vue
+++ b/ruoyi-ui/src/views/system/gps/map.vue
@@ -104,7 +104,7 @@
</template>
<script>
-import { listGps } from "@/api/system/gps";
+import { anonymousList } from "@/api/system/gps";
export default {
name: "GpsMap",
@@ -126,9 +126,12 @@
dateRange: [],
// 鏌ヨ鍙傛暟
queryParams: {
- vehicleNo: undefined,
- orderByColumn: "collect_time",
- isAsc: "desc",
+ pageNum: 1,
+ pageSize: 10,
+ deviceId: null,
+ appId: null,
+ sign: null,
+ timestamp: null
},
// 鍦板浘瀵硅薄
map: null,
@@ -151,10 +154,24 @@
};
},
created() {
- // 鑾峰彇URL鍙傛暟涓殑杞︾墝鍙�
- const vehicleNo = this.$route.query.vehicleNo;
- if (vehicleNo) {
- this.queryParams.vehicleNo = vehicleNo;
+ // 鑾峰彇URL鍙傛暟
+ const query = this.$route.query;
+ if (query.vehicleNo) {
+ this.queryParams.vehicleNo = query.vehicleNo;
+ }
+ // 璁剧疆璁よ瘉鍙傛暟
+ if (query.appId) {
+ this.queryParams.appId = query.appId;
+ }
+ if (query.sign) {
+ this.queryParams.sign = query.sign;
+ }
+ if (query.timestamp) {
+ this.queryParams.timestamp = query.timestamp;
+ }
+ // 璁剧疆鏃堕棿鑼冨洿
+ if (query.beginTime && query.endTime) {
+ this.dateRange = [query.beginTime, query.endTime];
}
this.getList();
},
@@ -162,6 +179,10 @@
// 鍔ㄦ�佸姞杞界櫨搴﹀湴鍥続PI
this.loadBMapScript().then(() => {
this.initMap();
+ window.initMapFlag=true;
+ if(window.loadGpsList){
+ this.drawTrack()
+ }
});
},
methods: {
@@ -201,15 +222,16 @@
},
/** 鏌ヨGPS鍒楄〃 */
getList() {
- this.loading = true;
- listGps(this.addDateRange(this.queryParams, this.dateRange)).then(
- (response) => {
- this.gpsList = response.rows;
- this.total = response.total;
- this.loading = false;
+ this.loading = true;
+ anonymousList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
+ this.gpsList = response.rows;
+ this.total = response.total;
+ this.loading = false;
+ window.loadGpsList=true;
+ if(window.initMapFlag){
this.drawTrack();
}
- );
+ });
},
async translatePoints(points) {
// 灏哤GS84鍧愭爣杞崲涓虹櫨搴﹀潗鏍�
@@ -242,6 +264,7 @@
this.map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
// 鍚敤婊氳疆鏀惧ぇ缂╁皬
this.map.enableScrollWheelZoom();
+ console.log("initMap 鍒濆鍖栧湴鍥�")
},
/** 璁$畻涓ょ偣涔嬮棿鐨勮窛绂伙紙绫筹級 */
getDistance(point1, point2) {
@@ -254,34 +277,7 @@
return Math.atan2(dy, dx) * 180 / Math.PI;
},
- /** 鍦ㄤ袱鐐逛箣闂存彃鍏ュ钩婊戠偣 */
- getSmoothPoints(point1, point2) {
- const distance = this.getDistance(point1, point2);
- if (distance < this.minDistance) {
- return [point1, point2];
- }
-
- const angle = this.getAngle(point1, point2);
- const midPoint = new BMap.Point(
- (point1.lng + point2.lng) / 2,
- (point1.lat + point2.lat) / 2
- );
-
- // 璁$畻鎺у埗鐐�
- const controlPoint = new BMap.Point(
- midPoint.lng + this.smoothFactor * distance * Math.cos((angle + 90) * Math.PI / 180),
- midPoint.lat + this.smoothFactor * distance * Math.sin((angle + 90) * Math.PI / 180)
- );
-
- // 浣跨敤浜屾璐濆灏旀洸绾跨敓鎴愬钩婊戠偣
- const points = [];
- for (let t = 0; t <= 1; t += 0.1) {
- const x = Math.pow(1 - t, 2) * point1.lng + 2 * (1 - t) * t * controlPoint.lng + Math.pow(t, 2) * point2.lng;
- const y = Math.pow(1 - t, 2) * point1.lat + 2 * (1 - t) * t * controlPoint.lat + Math.pow(t, 2) * point2.lat;
- points.push(new BMap.Point(x, y));
- }
- return points;
- },
+
/** 缁樺埗杞ㄨ抗 */
async drawTrack() {
@@ -329,11 +325,18 @@
translatePoints.forEach((item, index) => {
const bdPoint = item;
- // 鍙湪璧风偣鍜岀粓鐐瑰垱寤烘爣璁�
- if (index === 0 || index === translatePoints.length - 1) {
+ // 鍒ゆ柇璧风偣鍜岀粓鐐规槸鍚︾浉鍚�
+ const isStartPoint = index === 0;
+ const isEndPoint = index === translatePoints.length - 1;
+ const isStartEndSame = isStartPoint && isEndPoint &&
+ translatePoints[0].lng === translatePoints[translatePoints.length - 1].lng &&
+ translatePoints[0].lat === translatePoints[translatePoints.length - 1].lat;
+
+ // 鍙湪璧风偣鍜岀粓鐐瑰垱寤烘爣璁帮紝涓旇捣鐐瑰拰缁堢偣涓嶅悓鏃舵墠鏄剧ず璧风偣鏍囪
+ if ((isStartPoint && !isStartEndSame) || isEndPoint) {
let marker;
let direction=currentSegment[index].direction;
- if (index === 0) {
+ if (isStartPoint && !isStartEndSame) {
// 璧风偣鏄剧ず"璧�"瀛�
const label = new BMap.Label("璧�", {
offset: new BMap.Size(0, 0),
@@ -347,11 +350,11 @@
padding: "2px 6px",
borderRadius: "3px",
});
+
marker = new BMap.Marker(bdPoint,{rotation:direction});
marker.setLabel(label);
} else {
// 缁堢偣鏄剧ず杞﹁締鍥炬爣
-
const myIcon = new BMap.Icon(
"/car_blue.png",
new BMap.Size(20, 20),
@@ -365,6 +368,20 @@
rotation: direction,
});
}
+ //鍦ㄨ溅鍥炬爣涓婃樉绀鸿溅鐗�
+ const label = new BMap.Label(currentSegment[index].vehicleNo, {
+ offset: new BMap.Size(0, -25), // 鍚戜笂鍋忕Щ25鍍忕礌
+ position: bdPoint,
+ });
+ label.setStyle({
+ color: "white",
+ fontSize: "12px",
+ backgroundColor: "#3388ff",
+ border: "none",
+ padding: "2px 6px",
+ borderRadius: "3px",
+ });
+ marker.setLabel(label);
// 鑾峰彇鍦板潃淇℃伅
const geoc = new BMap.Geocoder();
@@ -377,13 +394,14 @@
addComp.street +
addComp.streetNumber;
- // 娣诲姞淇℃伅绐楀彛
- const infoWindow = new BMap.InfoWindow(
- `鏃堕棿锛�${item.collectTime}<br/>閫熷害锛�${
- item.speed
- }km/h<br/>鏂瑰悜锛�${item.direction}掳<br/>鍦板潃锛�${address}`
- );
+ // 娣诲姞鐐瑰嚮浜嬩欢鐩戝惉鍣�
marker.addEventListener("click", () => {
+ // 鍒涘缓淇℃伅绐楀彛
+ const infoWindow = new BMap.InfoWindow(
+ `鏃堕棿锛�${currentSegment[index].collectTime}<br/>閫熷害锛�${
+ currentSegment[index].speed
+ }km/h<br/>鏂瑰悜锛�${currentSegment[index].direction}掳<br/>鍦板潃锛�${address}`
+ );
this.map.openInfoWindow(infoWindow, bdPoint);
});
});
@@ -391,12 +409,6 @@
this.map.addOverlay(marker);
this.markers.push(marker);
}
- // const smoothPoints = [];
- // for (let i = 0; i < points.length - 1; i++) {
- // const segmentPoints = this.getSmoothPoints(points[i], points[i + 1]);
- // smoothPoints.push(...segmentPoints);
- // }
- // smoothPoints.push(points[points.length - 1]);
// 濡傛灉鏄渶鍚庝竴涓偣锛岀粯鍒惰建杩圭嚎
if (index === currentSegment.length - 1) {
@@ -455,12 +467,25 @@
});
marker.setLabel(label);
- // 娣诲姞淇℃伅绐楀彛
- const infoWindow = new BMap.InfoWindow(
- `鏃堕棿锛�${row.collectTime}<br/>閫熷害锛�${row.speed}km/h<br/>鏂瑰悜锛�${row.direction}掳<br/>鍦板潃锛�${row.address}`
- );
- marker.addEventListener("click", () => {
- this.map.openInfoWindow(infoWindow, data.points[0]);
+ // 鑾峰彇鍦板潃淇℃伅
+ const geoc = new BMap.Geocoder();
+ geoc.getLocation(data.points[0], (rs) => {
+ const addComp = rs.addressComponents;
+ const address =
+ addComp.province +
+ addComp.city +
+ addComp.district +
+ addComp.street +
+ addComp.streetNumber;
+
+ // 娣诲姞鐐瑰嚮浜嬩欢鐩戝惉鍣�
+ marker.addEventListener("click", () => {
+ // 鍒涘缓淇℃伅绐楀彛
+ const infoWindow = new BMap.InfoWindow(
+ `鏃堕棿锛�${row.collectTime}<br/>閫熷害锛�${row.speed}km/h<br/>鏂瑰悜锛�${row.direction}掳<br/>鍦板潃锛�${address}`
+ );
+ this.map.openInfoWindow(infoWindow, data.points[0]);
+ });
});
// 淇濆瓨褰撳墠鏍囪鐐瑰紩鐢�
@@ -500,6 +525,25 @@
convertor.translate([point], 1, 5, (data) => {
if (data.status === 0) {
const bdPoint = data.points[0];
+ //鏄剧ず杞﹁締鍥炬爣
+ const myIcon = new BMap.Icon(
+ "/car_blue.png",
+ new BMap.Size(20, 20),
+ {
+ imageSize: new BMap.Size(20, 20),
+ anchor: new BMap.Size(10, 10),
+ }
+ );
+ const marker = new BMap.Marker(bdPoint, {
+ icon: myIcon,
+ rotation: item.direction,
+ });
+ // 绉婚櫎涔嬪墠鐨勬爣璁扮偣
+ if (this.currentMarker) {
+ this.map.removeOverlay(this.currentMarker);
+ }
+ this.currentMarker=marker;
+ this.map.addOverlay(marker);
this.map.setCenter(bdPoint);
this.map.setZoom(15);
}
--
Gitblit v1.9.1