This commit is contained in:
parent
52004b1df4
commit
f4a9b5ce21
|
@ -19,9 +19,12 @@ const openPush=(uid=11)=>{
|
||||||
// 假设用户uid为1
|
// 假设用户uid为1
|
||||||
// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
||||||
var user_channel = connection.subscribe( uid==11?'user-' + uid:uid+'user-plant' );
|
var user_channel = connection.subscribe( uid==11?'user-' + uid:uid+'user-plant' );
|
||||||
|
// var user_channel = connection.subscribe('zhanguan'+'user-plant' );
|
||||||
|
|
||||||
|
|
||||||
// 当user-2频道有message事件的消息时
|
// 当user-2频道有message事件的消息时
|
||||||
user_channel.on('message', function (data) {
|
user_channel.on('message', function (data) {
|
||||||
|
console.log(data,'收到事件')
|
||||||
globalEventBus.emit(data.content.event, data.content.data)
|
globalEventBus.emit(data.content.event, data.content.data)
|
||||||
});
|
});
|
||||||
// 断线事件
|
// 断线事件
|
||||||
|
|
|
@ -42,11 +42,12 @@ import geoJsonJiangyang from "/static/jsonData/jiangyang_geo.js"
|
||||||
import geoJsonLongmatan from "/static/jsonData/longmatan_geo.js"
|
import geoJsonLongmatan from "/static/jsonData/longmatan_geo.js"
|
||||||
import geoJsonNaxi from "/static/jsonData/naxi_geo.js"
|
import geoJsonNaxi from "/static/jsonData/naxi_geo.js"
|
||||||
import geoJsonXuyong from "/static/jsonData/xuyong_geo.js"
|
import geoJsonXuyong from "/static/jsonData/xuyong_geo.js"
|
||||||
import { useRouter } from "vue-router"
|
import { useRouter,useRoute } from "vue-router"
|
||||||
import { areaObj } from "@/store/index.js"
|
import { areaObj } from "@/store/index.js"
|
||||||
import { landListApi } from "@/api.js"
|
import { landListApi } from "@/api.js"
|
||||||
import { globalEventBus } from '@/common/eventBus'
|
import { globalEventBus } from '@/common/eventBus'
|
||||||
import { sendMsg } from "@/api.js"
|
import { sendMsg } from "@/api.js"
|
||||||
|
const route=useRoute()
|
||||||
|
|
||||||
const sendFn = (event, data = '') => {
|
const sendFn = (event, data = '') => {
|
||||||
sendMsg({ channel: 'user-11', event, data })
|
sendMsg({ channel: 'user-11', event, data })
|
||||||
|
@ -62,8 +63,6 @@ const getFamrCenter = async () => {
|
||||||
return Promise.resolve(farmarCenter);
|
return Promise.resolve(farmarCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const isMainScreen = JSON.parse(localStorage.getItem("TRADE_TYPE"))
|
const isMainScreen = JSON.parse(localStorage.getItem("TRADE_TYPE"))
|
||||||
let geoJson = geoJsonLuxian
|
let geoJson = geoJsonLuxian
|
||||||
const areaStore = areaObj()
|
const areaStore = areaObj()
|
||||||
|
@ -561,10 +560,23 @@ const initTownMap = async (name) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => areaStore.userInfo, (value, oldValue) => {
|
watch(() => areaStore.userInfo, (value, oldValue) => {
|
||||||
|
console.log("监听到了",value)
|
||||||
if (!value.streetCode) {
|
if (!value.streetCode) {
|
||||||
|
initGeoJson(value.areaCode)
|
||||||
|
getFamrCenter().then(res => {
|
||||||
|
initAreaMap()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
initTownMap(value.name)
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
deep: true,
|
||||||
|
}
|
||||||
|
|
||||||
switch (value.areaCode) {
|
)
|
||||||
|
|
||||||
|
const initGeoJson=(code)=>{
|
||||||
|
switch (code) {
|
||||||
case "510521":
|
case "510521":
|
||||||
geoJson = geoJsonLuxian
|
geoJson = geoJsonLuxian
|
||||||
break;
|
break;
|
||||||
|
@ -591,22 +603,18 @@ watch(() => areaStore.userInfo, (value, oldValue) => {
|
||||||
case '510525':
|
case '510525':
|
||||||
geoJson = geoJsonGulin
|
geoJson = geoJsonGulin
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
getFamrCenter().then(res => {
|
|
||||||
initAreaMap()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
initTownMap(value.name)
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
deep: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
)
|
if(route.query.areaCode){
|
||||||
|
// initGeoJson(areaCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getFamrCenter()
|
await getFamrCenter()
|
||||||
if (areaStore.userInfo.streetCode) return;
|
if (areaStore.userInfo.streetCode) return;
|
||||||
|
console.log("初始化")
|
||||||
setTimeout(() => { showArea.value ? initAreaMap() : initTownMap() }, 500)
|
setTimeout(() => { showArea.value ? initAreaMap() : initTownMap() }, 500)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@ globalEventBus.on('backHome', data => {
|
||||||
|
|
||||||
})
|
})
|
||||||
globalEventBus.on('choserArea', data => {
|
globalEventBus.on('choserArea', data => {
|
||||||
router.push("/")
|
// console.log(data.code)
|
||||||
|
router.push("/home?areaCode="+data.code)
|
||||||
areaStore.changeUserInfoFn(data.code, '', data.name)
|
areaStore.changeUserInfoFn(data.code, '', data.name)
|
||||||
})
|
})
|
||||||
globalEventBus.on('choseTown', data => {
|
globalEventBus.on('choseTown', data => {
|
||||||
|
|
Loading…
Reference in New Issue