This commit is contained in:
parent
45f1b937cc
commit
c2899beea1
52
src/App.vue
52
src/App.vue
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
|
||||
|
||||
|
||||
// let Token =localStorage.getItem('TOKEN')
|
||||
import { globalEventBus } from '@/common/eventBus'
|
||||
import { Push } from '@/common/push'
|
||||
|
@ -8,29 +8,47 @@ import { areaObj } from "@/store/index.js"
|
|||
const userInfoStore=areaObj()
|
||||
userInfoStore.changeUserInfoFn(510521)
|
||||
|
||||
var connection = new Push({
|
||||
url: 'ws://192.168.1.10:3131', // websocket地址
|
||||
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
|
||||
});
|
||||
// 假设用户uid为1
|
||||
var uid = 3;
|
||||
// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
||||
var user_channel = connection.subscribe('user-' + uid);
|
||||
// var connection = new Push({
|
||||
// url: 'ws://192.168.1.10:3131', // websocket地址
|
||||
// app_key: 'aaea61749929eb53a4bd75a1474c1d27',
|
||||
// });
|
||||
// // 假设用户uid为1
|
||||
// var uid = 3;
|
||||
// // 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
||||
// var user_channel = connection.subscribe('user-' + uid);
|
||||
|
||||
// 当user-2频道有message事件的消息时
|
||||
user_channel.on('message', function (data) {
|
||||
globalEventBus.emit(data.content.event, data.content.data)
|
||||
// // 当user-2频道有message事件的消息时
|
||||
// user_channel.on('message', function (data) {
|
||||
// globalEventBus.emit(data.content.event, data.content.data)
|
||||
|
||||
|
||||
console.log("收到消息",data)
|
||||
// console.log("收到消息",data)
|
||||
|
||||
});
|
||||
// 断线事件
|
||||
user_channel.on('close', function () {
|
||||
// });
|
||||
// // 断线事件
|
||||
// user_channel.on('close', function () {
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
|
||||
|
||||
var ws = new WebSocket("ws://192.168.26.167:8080");
|
||||
|
||||
//当WebSocket创建成功时,触发onopen事件
|
||||
ws.onopen = function () {
|
||||
console.log("open");
|
||||
}
|
||||
//当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
|
||||
ws.onmessage = function (e) {
|
||||
|
||||
let data =JSON.parse(e.data)
|
||||
|
||||
globalEventBus.emit(data.event, data.data ||'')
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<router-view></router-view>
|
||||
|
|
|
@ -50,11 +50,6 @@ import { areaObj } from "@/store/index.js"
|
|||
import { landListApi } from "@/api.js"
|
||||
import { globalEventBus } from '@/common/eventBus'
|
||||
let geoJson = geoJsonLuxian
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const areaStore = areaObj()
|
||||
const showArea = (ref(true))
|
||||
const router = useRouter()
|
||||
|
@ -348,7 +343,6 @@ const initTownMap = async (name) => {
|
|||
...areaStore.userInfo
|
||||
})
|
||||
|
||||
console.log(showArea.value,"res")
|
||||
|
||||
res.data.list.forEach(item => {
|
||||
|
||||
|
@ -367,6 +361,7 @@ const initTownMap = async (name) => {
|
|||
townJson.features = townJson.features.filter((item) => {
|
||||
return item.properties.name == name
|
||||
})
|
||||
console.log(townJson,"res")
|
||||
|
||||
var mapName = 'town';
|
||||
const myChart = document.getElementById("chart3")
|
||||
|
@ -557,7 +552,11 @@ const initTownMap = async (name) => {
|
|||
|
||||
|
||||
bg.on('click', function (params) {
|
||||
|
||||
|
||||
let longInfo = params.data.coord
|
||||
console.log(params)
|
||||
return
|
||||
areaStore.areaCodeList.forEach(item => {
|
||||
if (item.name == name) {
|
||||
areaStore.changeUserInfoFn(510521, item.code)
|
||||
|
@ -645,14 +644,19 @@ globalEventBus.on('choserArea', data => {
|
|||
})
|
||||
globalEventBus.on('choseTown', data => {
|
||||
getTowmName(data.name)
|
||||
|
||||
areaStore.areaCodeList.forEach(item => {
|
||||
if (item.name == (data.name)) {
|
||||
areaStore.changeUserInfoFn(areaStore.userInfo.areaCode, item.code)
|
||||
areaStore.changeUserInfoFn(areaStore.userInfo.areaCode, item.code,data.name)
|
||||
}
|
||||
})
|
||||
areaStore.changeAddress('', data.name )
|
||||
initTownMap(data.name)
|
||||
|
||||
})
|
||||
|
||||
globalEventBus.on('choseLand', data => {
|
||||
|
||||
router.push(`/detail?landId=${data.id}&town=${areaStore.userInfo.name}&parmas=${JSON.stringify(areaStore.userInfo)}&landName=${data.landName}`)
|
||||
|
||||
})
|
||||
</script>
|
|
@ -40,6 +40,8 @@ import geoJsonLuxian from "/static/jsonData/luxian_geo.js"
|
|||
import { useRoute } from "vue-router"
|
||||
import { areaObj } from "@/store/index.js"
|
||||
import { landListApi } from "@/api.js"
|
||||
import { globalEventBus } from '@/common/eventBus'
|
||||
|
||||
const icon = "https:\/\/ceshi-worker-task.lihaink.cn\/uploads\/images\/20231204\/202312041608529c9e21252.png"
|
||||
|
||||
|
||||
|
@ -362,7 +364,12 @@ onMounted(async () => {
|
|||
|
||||
|
||||
|
||||
globalEventBus.on('detail', data => {
|
||||
|
||||
emit('changeLand', data)
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue