This commit is contained in:
zmj 2024-02-23 23:48:47 +08:00
parent ef9a657d75
commit 52004b1df4
4 changed files with 169 additions and 56 deletions

View File

@ -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',
});
// uid1
var uid = 11;
// user-2uid1
var user_channel = connection.subscribe('user-' + uid);
var user_channel = connection.subscribe( uid==11?'user-' + uid:uid+'user-plant' );
// user-2message
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>

View File

@ -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"
@ -49,15 +49,17 @@ import { globalEventBus } from '@/common/eventBus'
import { sendMsg } from "@/api.js"
const sendFn = (event, data = '') => {
sendMsg({ channel: 'user-11', event, data })
sendMsg({ channel: 'user-11', event, data })
}
let farmarCenter=[]
const getFamrCenter=async()=>{
let res=await landListApi({
...areaStore.userInfo
})
farmarCenter=res.data.list.map( item=>([item.longitude,item.latitude]) )
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);
}
@ -66,7 +68,7 @@ const isMainScreen = JSON.parse(localStorage.getItem("TRADE_TYPE"))
let geoJson = geoJsonLuxian
const areaStore = areaObj()
const showArea = (ref(true))
if(areaStore.userInfo.streetCode)showArea.value=false;
if (areaStore.userInfo.streetCode) showArea.value = false;
const router = useRouter()
@ -94,7 +96,7 @@ const pointerFn = () => {
geoJson.center.forEach((item, index) => {
list.push({
coord: item,
symbol: ('image://' + icon),//
symbol: ('image://' + icon),//
symbolSize: [100, 30], //
symbolOffset: ['50%', '-50%'],
value: geoJson.features[index]?.properties.name || '泸县',
@ -127,7 +129,7 @@ const pointerFn2 = (lists) => {
const initAreaMap =async () => {
const initAreaMap = async () => {
showArea.value = true
await nextTick()
var mapName = 'lz';
@ -273,26 +275,25 @@ const initAreaMap =async () => {
},
//
symbolSize: function (val,parmas) {
symbolSize: function (val, parmas) {
return 4
// return val[2] / 10;
},
markPoint: {
data: pointerFn()
},
itemStyle:{ //
// color:'green'
color:function(params) // seriesIndex, dataIndex, data, value
{
itemStyle: { //
// color:'green'
color: function (params) // seriesIndex, dataIndex, data, value
{
return 'blue';
}
},
}
},
data: (() => {
let data = {
资产数:farmarCenter
资产数: farmarCenter
}
console.log(farmarCenter,"center")
let finalData = []
Object.keys(data).map((i, index) => {
let child = data[i].map((row, index) => ({
@ -549,7 +550,7 @@ const initTownMap = async (name) => {
areaStore.changeUserInfoFn(510521, item.code)
}
})
params.data.data.forEach(item => {
if (item.value[0] == longInfo[0] && item.value[1] == longInfo[1]) {
router.push(`/detail?landId=${item.id}&town=${name}&parmas=${JSON.stringify(areaStore.userInfo)}&landName=${item.name}`)
@ -560,16 +561,53 @@ 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()
if(areaStore.userInfo.streetCode)return;
setTimeout(() => {showArea.value? initAreaMap(): initTownMap() }, 500)
await getFamrCenter()
if (areaStore.userInfo.streetCode) return;
setTimeout(() => { showArea.value ? initAreaMap() : initTownMap() }, 500)
})
globalEventBus.on('choserArea', data => {
@ -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, '', '')

View File

@ -32,7 +32,7 @@
</style>
<script setup>
import { ref, onMounted, defineEmits,watch } from "vue"
import { ref, onMounted, defineEmits, watch } from "vue"
import * as echarts from 'echarts';
import "echarts-gl"
import geoJsonLuxian from "/static/jsonData/luxian_geo.js"
@ -42,23 +42,23 @@ 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 { useRoute,useRouter } from "vue-router"
import { useRoute, useRouter } from "vue-router"
import { areaObj } from "@/store/index.js"
import { landListApi } from "@/api.js"
import { globalEventBus } from '@/common/eventBus'
const router=useRouter()
const router = useRouter()
const route = useRoute()
let geoJson ;
let geoJson;
const icon = "https:\/\/ceshi-worker-task.lihaink.cn\/uploads\/images\/20231204\/202312041608529c9e21252.png"
const areaStore = areaObj()
if(JSON.parse(route.query.parmas).areaCode==510503) geoJson = geoJsonNaxi;
if(JSON.parse(route.query.parmas).areaCode==510502) geoJson = geoJsonJiangyang;
if(JSON.parse(route.query.parmas).areaCode==510504) geoJson = geoJsonLongmatan;
if(JSON.parse(route.query.parmas).areaCode==510521) geoJson = geoJsonLuxian;
if(JSON.parse(route.query.parmas).areaCode==510522) geoJson = geoJsonHejiang;
if(JSON.parse(route.query.parmas).areaCode==510524) geoJson = geoJsonXuyong;
if(JSON.parse(route.query.parmas).areaCode==510525) geoJson = geoJsonGulinc;
if (JSON.parse(route.query.parmas).areaCode == 510503) geoJson = geoJsonNaxi;
if (JSON.parse(route.query.parmas).areaCode == 510502) geoJson = geoJsonJiangyang;
if (JSON.parse(route.query.parmas).areaCode == 510504) geoJson = geoJsonLongmatan;
if (JSON.parse(route.query.parmas).areaCode == 510521) geoJson = geoJsonLuxian;
if (JSON.parse(route.query.parmas).areaCode == 510522) geoJson = geoJsonHejiang;
if (JSON.parse(route.query.parmas).areaCode == 510524) geoJson = geoJsonXuyong;
if (JSON.parse(route.query.parmas).areaCode == 510525) geoJson = geoJsonGulinc;
@ -93,13 +93,13 @@ const deepCopy = (obj) => {
return copy;
}
const townJson = deepCopy(JSON.parse( JSON.stringify(geoJson)) )
townJson.features=geoJson.features
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
})
const lx = "https:\/\/ceshi-worker-task.lihaink.cn\/uploads\/images\/20231205\/20231205092709cfe148712.png"
const initMap=async ()=>{
const initMap = async () => {
let center = []
let pointerList = []
let res = await landListApi({
@ -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>

View File

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