From 2d6c08ad36ae4ae442ab34efa7097dde71d73112 Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Tue, 5 Mar 2024 16:42:04 +0800 Subject: [PATCH] =?UTF-8?q?CN-1563=20feat:=20=E5=85=B3=E6=B3=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8F=98=E6=9B=B4=E5=90=8E=E5=9C=B0=E5=9B=BE=E4=B8=8A?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E6=A0=87=E4=B9=9F=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/location/Index.vue | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/views/location/Index.vue b/src/views/location/Index.vue index 5d9ee4d6..29217e3d 100644 --- a/src/views/location/Index.vue +++ b/src/views/location/Index.vue @@ -741,6 +741,7 @@ export default { const mapMarker = new maplibregl.Marker({ element: el }) .setLngLat([marker.subscriberDto.subscriberLongitude, marker.subscriberDto.subscriberLatitude]) .addTo(this.mapChart) + mapMarker.subscriberId = marker.subscriberId this.humanMarkers.push(mapMarker) } else if (type === this.tooltipType.baseStation) { const el = document.createElement('div') @@ -1151,6 +1152,12 @@ export default { this.$message({ duration: 2000, type: 'success', message: this.$t('location.cancleFollow.success') }) /* 刷新右侧关注列表 */ this.queryFollowedList() + // 删除地图中对应的人 + this.humanMarkers.forEach(marker => { + if (marker.subscriberId === item.subscriberId) { + marker.remove() + } + }) } else { this.$message.error(res.data.message) } @@ -1164,6 +1171,14 @@ export default { if (res.status === 200) { this.$message({ duration: 2000, type: 'success', message: this.$t('location.cancleFollow.success') }) item.follow = 0 + // 删除地图中对应的人 + this.humanMarkers.forEach(marker => { + if (marker.subscriberId === item.subscriberId) { + marker.remove() + } + }) + /* 刷新右侧关注列表 */ + this.queryFollowedList() } else { this.$message.error(res.data.message) } @@ -1171,10 +1186,19 @@ export default { this.$message.error(this.errorMsgHandler(e)) }) } else { - axios.post(api.location.follow, { subscriberId: item.subscriberId }).then(res => { + axios.post(api.location.follow, { subscriberId: item.subscriberId }).then(async res => { if (res.status === 200) { this.$message({ duration: 2000, type: 'success', message: this.$t('location.follow.success') }) item.follow = 1 + /* 刷新右侧关注列表 */ + await this.queryFollowedList() + // 刷新地图上的人 + this.humanMarkers.forEach(marker => { + marker.remove && marker.remove() + }) + this.humanMarkers = [] + const mapFollowedSubscriberData = await this.queryMapFollowedSubscriber() + this.renderMarker(mapFollowedSubscriberData, this.tooltipType.human) } else { this.$message.error(res.data.message) } @@ -1182,8 +1206,6 @@ export default { this.$message.error(this.errorMsgHandler(e)) }) } - /* 刷新右侧关注列表 */ - this.queryFollowedList() }, clearSearchValue () { },