feat:完善功能
This commit is contained in:
@@ -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