This commit is contained in:
parent
ef9a657d75
commit
52004b1df4
25
src/App.vue
25
src/App.vue
|
@ -11,15 +11,14 @@ const userInfoStore=areaObj()
|
|||
userInfoStore.changeUserInfoFn(510521)
|
||||
|
||||
|
||||
const openPush=()=>{
|
||||
const openPush=(uid=11)=>{
|
||||
var connection = new Push({
|
||||
url: 'wss://chat.lihaink.cn/tts', // websocket地址
|
||||
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
|
||||
});
|
||||
// 假设用户uid为1
|
||||
var uid = 11;
|
||||
// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
||||
var user_channel = connection.subscribe('user-' + uid);
|
||||
var user_channel = connection.subscribe( uid==11?'user-' + uid:uid+'user-plant' );
|
||||
|
||||
// 当user-2频道有message事件的消息时
|
||||
user_channel.on('message', function (data) {
|
||||
|
@ -35,7 +34,25 @@ globalEventBus.on('refresh', data => {
|
|||
router.go(0)
|
||||
})
|
||||
|
||||
if( !JSON.parse(localStorage.getItem("TRADE_TYPE")) )openPush();
|
||||
|
||||
|
||||
|
||||
// 获取 URL 中的查询参数部分
|
||||
var queryString = window.location.hash.split("?")[1];
|
||||
// 解析查询参数字符串
|
||||
const searchParams = new URLSearchParams(queryString);
|
||||
|
||||
// 读取名为 id 的参数
|
||||
const id = searchParams.get('local') || '';
|
||||
if (!JSON.parse(localStorage.getItem("TRADE_TYPE"))) {
|
||||
if (id) {
|
||||
openPush(id);
|
||||
|
||||
}
|
||||
else {
|
||||
openPush();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
import { ref, onMounted, watch, defineEmits, nextTick } from "vue"
|
||||
import * as echarts from 'echarts';
|
||||
import geoJsonLuxian from "/static/jsonData/luxian_geo.js"
|
||||
// import geoJsonGulin from "/static/jsonData/gulin_geo.js"
|
||||
// import geoJsonHejiang from "/static/jsonData/hejiang_geo.js"
|
||||
// import geoJsonJiangyang from "/static/jsonData/jiangyang_geo.js"
|
||||
// import geoJsonLongmatan from "/static/jsonData/longmatan_geo.js"
|
||||
// import geoJsonNaxi from "/static/jsonData/naxi_geo.js"
|
||||
// import geoJsonXuyong from "/static/jsonData/xuyong_geo.js"
|
||||
import geoJsonGulin from "/static/jsonData/gulin_geo.js"
|
||||
import geoJsonHejiang from "/static/jsonData/hejiang_geo.js"
|
||||
import geoJsonJiangyang from "/static/jsonData/jiangyang_geo.js"
|
||||
import geoJsonLongmatan from "/static/jsonData/longmatan_geo.js"
|
||||
import geoJsonNaxi from "/static/jsonData/naxi_geo.js"
|
||||
import geoJsonXuyong from "/static/jsonData/xuyong_geo.js"
|
||||
import { useRouter } from "vue-router"
|
||||
import { areaObj } from "@/store/index.js"
|
||||
import { landListApi } from "@/api.js"
|
||||
|
@ -54,10 +54,12 @@ const sendFn = (event, data = '') => {
|
|||
|
||||
let farmarCenter = []
|
||||
const getFamrCenter = async () => {
|
||||
farmarCenter = []
|
||||
let res = await landListApi({
|
||||
...areaStore.userInfo
|
||||
})
|
||||
farmarCenter = res.data.list.map(item => ([item.longitude, item.latitude]))
|
||||
return Promise.resolve(farmarCenter);
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,7 +294,6 @@ const initAreaMap =async () => {
|
|||
资产数: farmarCenter
|
||||
|
||||
}
|
||||
console.log(farmarCenter,"center")
|
||||
let finalData = []
|
||||
Object.keys(data).map((i, index) => {
|
||||
let child = data[i].map((row, index) => ({
|
||||
|
@ -560,14 +561,51 @@ const initTownMap = async (name) => {
|
|||
}
|
||||
|
||||
watch(() => areaStore.userInfo, (value, oldValue) => {
|
||||
value.name == '泸县' ? initAreaMap() : initTownMap(value.name)
|
||||
|
||||
if (!value.streetCode) {
|
||||
|
||||
switch (value.areaCode) {
|
||||
case "510521":
|
||||
geoJson = geoJsonLuxian
|
||||
break;
|
||||
case '510502':
|
||||
geoJson = geoJsonJiangyang
|
||||
|
||||
break;
|
||||
case '510503':
|
||||
geoJson = geoJsonNaxi
|
||||
|
||||
break;
|
||||
case '510504':
|
||||
geoJson = geoJsonLongmatan
|
||||
|
||||
break;
|
||||
case '510522':
|
||||
geoJson = geoJsonHejiang
|
||||
|
||||
break;
|
||||
case '510524':
|
||||
geoJson = geoJsonXuyong
|
||||
|
||||
break;
|
||||
case '510525':
|
||||
geoJson = geoJsonGulin
|
||||
break;
|
||||
|
||||
}
|
||||
getFamrCenter().then(res => {
|
||||
initAreaMap()
|
||||
})
|
||||
} else {
|
||||
initTownMap(value.name)
|
||||
}
|
||||
}, {
|
||||
deep: true,
|
||||
}
|
||||
|
||||
)
|
||||
onMounted(async () => {
|
||||
getFamrCenter()
|
||||
await getFamrCenter()
|
||||
if (areaStore.userInfo.streetCode) return;
|
||||
setTimeout(() => { showArea.value ? initAreaMap() : initTownMap() }, 500)
|
||||
})
|
||||
|
@ -585,9 +623,10 @@ globalEventBus.on('choseTown', data => {
|
|||
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}`)
|
||||
// })
|
||||
globalEventBus.on('choseLand', data => {
|
||||
areaStore.changeUserInfoFn(data.areaCode, data.townCode, data.town_name)
|
||||
router.push(`/detail?landId=${data.id}&town=${areaStore.userInfo.name}&parmas=${JSON.stringify(areaStore.userInfo)}&landName=${data.landName}`)
|
||||
})
|
||||
|
||||
// globalEventBus.on('initAreaMap', data => {
|
||||
// areaStore.changeUserInfoFn(areaStore.userInfo.areaCode, '', '')
|
||||
|
|
|
@ -93,7 +93,7 @@ const deepCopy = (obj) => {
|
|||
return copy;
|
||||
}
|
||||
|
||||
const townJson = deepCopy(JSON.parse( JSON.stringify(geoJson)) )
|
||||
let townJson = deepCopy(JSON.parse(JSON.stringify(geoJson)))
|
||||
townJson.features = geoJson.features
|
||||
townJson.features = townJson.features.filter((item) => {
|
||||
return item.properties.name == route.query.town
|
||||
|
@ -341,6 +341,58 @@ const initMap=async ()=>{
|
|||
|
||||
}
|
||||
|
||||
watch(() => areaStore.userInfo, (value, oldValue) => {
|
||||
|
||||
// if (!value.streetCode) {
|
||||
|
||||
switch (value.areaCode) {
|
||||
case "510521":
|
||||
geoJson = geoJsonLuxian
|
||||
break;
|
||||
case '510502':
|
||||
geoJson = geoJsonJiangyang
|
||||
|
||||
break;
|
||||
case '510503':
|
||||
geoJson = geoJsonNaxi
|
||||
|
||||
break;
|
||||
case '510504':
|
||||
geoJson = geoJsonLongmatan
|
||||
|
||||
break;
|
||||
case '510522':
|
||||
geoJson = geoJsonHejiang
|
||||
|
||||
break;
|
||||
case '510524':
|
||||
geoJson = geoJsonXuyong
|
||||
|
||||
break;
|
||||
case '510525':
|
||||
geoJson = geoJsonGulin
|
||||
break;
|
||||
|
||||
}
|
||||
townJson = deepCopy(JSON.parse(JSON.stringify(geoJson)))
|
||||
townJson.features = townJson.features.filter((item) => {
|
||||
return item.properties.name == value.name
|
||||
})
|
||||
console.log(townJson.features)
|
||||
initMap()
|
||||
|
||||
// getFamrCenter().then(res => {
|
||||
// initAreaMap()
|
||||
// })
|
||||
// } else {
|
||||
// initTownMap(value.name)
|
||||
// }
|
||||
}, {
|
||||
deep: true,
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
initMap()
|
||||
|
||||
|
@ -348,9 +400,5 @@ onMounted(async () => {
|
|||
|
||||
|
||||
|
||||
globalEventBus.on('detail', data => {
|
||||
emit('changeLand', data)
|
||||
})
|
||||
|
||||
|
||||
</script>
|
|
@ -8,7 +8,7 @@
|
|||
<leftCenter :data="data" :key="data.land_id"></leftCenter>
|
||||
</div>
|
||||
<div class="top center">
|
||||
<JessibucaDemo v-if="video_url&&showVideo" :src="video_url"></JessibucaDemo>
|
||||
<!-- <JessibucaDemo v-if="video_url&&showVideo" :src="video_url"></JessibucaDemo> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="center">
|
||||
|
@ -118,6 +118,15 @@ const back = () => {
|
|||
|
||||
}
|
||||
|
||||
globalEventBus.on('choseLand', datas => {
|
||||
console.log(data,'data')
|
||||
data.land_id=datas.id
|
||||
landName.value=datas.landName
|
||||
areaStore.changeUserInfoFn(datas.areaCode, datas.townCode, datas.town_name)
|
||||
// router.push(`/detail?landId=${data.id}&town=${areaStore.userInfo.name}&parmas=${JSON.stringify(areaStore.userInfo)}&landName=${data.landName}`)
|
||||
})
|
||||
|
||||
|
||||
globalEventBus.on('backHome', data => {
|
||||
back()
|
||||
|
||||
|
|
Loading…
Reference in New Issue