This commit is contained in:
zmj 2024-01-09 22:15:10 +08:00
parent 45f1b937cc
commit c2899beea1
3 changed files with 54 additions and 25 deletions

View File

@ -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',
});
// uid1
var uid = 3;
// user-2uid1
var user_channel = connection.subscribe('user-' + uid);
// var connection = new Push({
// url: 'ws://192.168.1.10:3131', // websocket
// app_key: 'aaea61749929eb53a4bd75a1474c1d27',
// });
// // uid1
// var uid = 3;
// // user-2uid1
// var user_channel = connection.subscribe('user-' + uid);
// user-2message
user_channel.on('message', function (data) {
globalEventBus.emit(data.content.event, data.content.data)
// // user-2message
// 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");
//WebSocketonopen
ws.onopen = function () {
console.log("open");
}
//onmessagee.dataserver
ws.onmessage = function (e) {
let data =JSON.parse(e.data)
globalEventBus.emit(data.event, data.data ||'')
}
</script>
<template>
<router-view></router-view>

View File

@ -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>

View File

@ -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>