feat:完善功能
This commit is contained in:
@@ -131,6 +131,8 @@
|
||||
import icon9 from '@/assets/images/icon-9.png'
|
||||
import icon10 from '@/assets/images/icon-10.png'
|
||||
import icon11 from '@/assets/images/icon-11.png'
|
||||
import carIcon from '@/assets/images/car.png'
|
||||
import shipIcon from '@/assets/images/ship.png'
|
||||
|
||||
import { useMap } from '@/hooks/map'
|
||||
import { useHomeStore } from '@/stores/home'
|
||||
@@ -139,7 +141,7 @@
|
||||
|
||||
let emit = defineEmits(['switch-spot'])
|
||||
|
||||
const { map, initMap } = useMap()
|
||||
const { map, initMap, addMarker } = useMap()
|
||||
|
||||
let spotList = ref([])
|
||||
|
||||
@@ -162,6 +164,27 @@
|
||||
}
|
||||
])
|
||||
let current = ref(0)
|
||||
|
||||
watch(
|
||||
() => [map.value, homeStore.carShipData],
|
||||
() => {
|
||||
if (map.value && homeStore.carShipData) {
|
||||
homeStore.carShipData?.car?.list.map((item) => {
|
||||
if (item.lng && item.lat) {
|
||||
addMarker(carIcon, [item.lng, item.lat], [36, 50])
|
||||
}
|
||||
})
|
||||
homeStore.carShipData?.ship?.list.map((item) => {
|
||||
if (item.lng && item.lat) {
|
||||
addMarker(shipIcon, [item.lng, item.lat], [36, 50])
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
}
|
||||
)
|
||||
const handleMap = (e) => {
|
||||
emit('switch-spot', e)
|
||||
// map.value.centerAndZoom(new BMapGL.Point('108.704166', '30.94776'), 16)
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
)
|
||||
const homeStore = useHomeStore()
|
||||
|
||||
let timer = null
|
||||
|
||||
watch(
|
||||
() => isConnected.value,
|
||||
(val) => {
|
||||
@@ -25,7 +27,7 @@
|
||||
sendMessage(
|
||||
JSON.stringify({
|
||||
action: 'start',
|
||||
type: 'index',
|
||||
type: '',
|
||||
scenicSpot: ''
|
||||
})
|
||||
)
|
||||
@@ -35,8 +37,8 @@
|
||||
watch(
|
||||
() => dataRes.value,
|
||||
(val) => {
|
||||
console.log(val, '景区接受消息')
|
||||
if (val) {
|
||||
console.log(val, '首页接受消息')
|
||||
switch (val.type) {
|
||||
case 'userPortrait':
|
||||
homeStore.setUserPortraitData(val.data)
|
||||
@@ -78,9 +80,24 @@
|
||||
homeStore.setHotelData(val.data)
|
||||
break
|
||||
}
|
||||
if (!timer) sendCarShip()
|
||||
}
|
||||
}
|
||||
)
|
||||
const sendCarShip = (e) => {
|
||||
timer = setInterval(() => {
|
||||
if (isConnected.value) {
|
||||
console.log('定时发送车船消息11')
|
||||
sendMessage(
|
||||
JSON.stringify({
|
||||
action: 'start',
|
||||
type: 'carShipData',
|
||||
scenicSpotId: ''
|
||||
})
|
||||
)
|
||||
}
|
||||
}, 5000)
|
||||
}
|
||||
const switchSpot = (e) => {
|
||||
sendMessage(
|
||||
JSON.stringify({
|
||||
@@ -90,4 +107,8 @@
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer) clearInterval(timer)
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user