<template>
|
<public-box class="public-org-nav-bar">
|
<template slot="public-box-header">
|
<div class="title">
|
<img class="icon deblurring" :src="publicPath + 'img/icon/xyjz.png'" alt />
|
<span>{{ arcNavBarTitle }}</span>
|
</div>
|
<img class="close deblurring" :src="publicPath + 'img/navicon/close.png'" alt @click="closeModel" />
|
</template>
|
<template slot="public-box-content">
|
<!-- <div class="tab">
|
<ul>
|
<li :class="{ on: item.flag }" v-for="(item, index) in titleList" :key="index"
|
@click="topNavClick(item, index)">{{ item.title }}</li>
|
</ul>
|
</div> -->
|
<ul>
|
<li v-for="(item, index) in itemNavList" :key="index" @click="mapPopup(item)">
|
<img :src="item.icon" alt />
|
<span>{{ item.mechanismName }}</span>
|
</li>
|
</ul>
|
</template>
|
</public-box>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import {
|
getList,
|
getChildNavList,
|
getChildNavDetail
|
} from '@/api/pc/public/arc'
|
|
import VectorLayer from "ol/layer/Vector"
|
import VectorSource from "ol/source/Vector"
|
import Feature from 'ol/Feature.js'
|
import Point from 'ol/geom/Point.js'
|
import { Icon, Style, Fill, Text, Stroke } from 'ol/style.js'
|
|
let currentOrgLayer = null
|
let time
|
|
export default {
|
name: 'ArcNavBar',
|
data () {
|
return {
|
publicPath: process.env.BASE_URL,
|
map2D: this.$store.state.openlayerData.openlayers.map2D,
|
itemNavList: [],
|
titleList: []
|
}
|
},
|
|
inject: ["layoutElement"],
|
|
props: {},
|
|
computed: {
|
...mapGetters([
|
'popupBgUrl',
|
'pupupQRUrl',
|
// 点信息
|
'pointPosition',
|
// 点名称
|
'stateName',
|
// 地址
|
'siteName',
|
// 介绍
|
'introduceText',
|
// 全景地址
|
'panoramaUrl',
|
'arcNavBarTitle',
|
'arcNavBarCode',
|
'twoOrThree'
|
])
|
},
|
|
created () {
|
},
|
|
mounted () {
|
this.$nextTick(() => {
|
currentOrgLayer = new VectorLayer({
|
// 图标图层
|
zIndex: 9,
|
source: new VectorSource(),
|
})
|
this.map2D.addLayer(currentOrgLayer)
|
})
|
},
|
|
watch: {
|
arcNavBarCode: {
|
immediate: true,
|
handler (newCode, oldCode) {
|
// this.titleList = []
|
// getList().then((res) => {
|
// res.data.data.forEach((item) => {
|
// this.titleList.push({
|
// title: item.dictValue,
|
// flag: false,
|
// key: item.dictKey
|
// })
|
// })
|
|
// this.titleList[0].flag = true
|
|
|
// })
|
|
time = setInterval(() => {
|
if (this.layoutElement.campusValue) {
|
this.getChilsNavs(this.layoutElement.campusValue)
|
clearInterval(time)
|
}
|
}, 100)
|
}
|
},
|
},
|
|
methods: {
|
|
coordinate (item) {
|
const arr = item.split(',')
|
|
return {
|
lng: arr[0],
|
lat: arr[1]
|
}
|
},
|
|
topNavClick (item, index) {
|
this.titleList.forEach((item) => {
|
item.flag = false
|
})
|
|
this.titleList[index].flag = true
|
|
this.getChilsNavs(item.key)
|
},
|
|
getChilsNavs (campus) {
|
const that = this
|
|
this.itemNavList = []
|
|
if (currentOrgLayer) {
|
currentOrgLayer.getSource().clear()
|
} else {
|
currentOrgLayer = new VectorLayer({
|
// 图标图层
|
zIndex: 9,
|
source: new VectorSource(),
|
})
|
this.map2D.addLayer(currentOrgLayer)
|
}
|
|
getChildNavList({ campus: campus, type: this.arcNavBarCode }).then(
|
(res) => {
|
this.$EventBus.$emit('closeTagLayer')
|
|
res.data.data.forEach((item) => {
|
item.icon = this.publicPath + 'img/navicon/tag.png'
|
|
let obj = {}
|
if (item.x && item.x != '') {
|
const position = that.coordinate(item.x)
|
obj = {
|
lng: position.lng, lat: position.lat
|
}
|
} else {
|
obj = {
|
lng: item.jd, lat: item.wd
|
}
|
}
|
|
let siteJd = null
|
let siteWd = null
|
|
if (this.twoOrThree == '三 维') {
|
siteJd = obj.lng
|
siteWd = obj.lat
|
} else {
|
siteJd = item.jd
|
siteWd = item.wd
|
}
|
|
currentOrgLayer.getSource().addFeature(that.getCurItemFeature({
|
imgSize: [44, 44],
|
lng: siteJd,
|
lat: siteWd,
|
item,
|
text: item.mechanismName,
|
url: this.publicPath + 'img/icon/bubble.png',
|
anchor: [16, 34],
|
event: (e) => {
|
that.mapPopup(item)
|
}
|
}))
|
})
|
|
this.itemNavList = res.data.data
|
}
|
)
|
},
|
|
getCurItemFeature (params) {
|
const iconFeature = new Feature({
|
geometry: new Point([Number(params.lng), Number(params.lat)]),
|
attributes: params.item
|
})
|
|
var textElement = document.createElement('span')
|
textElement.innerHTML = params.text
|
|
iconFeature.setStyle(new Style({
|
image: new Icon({
|
scale: params.scale || 1,
|
imgSize: params.imgSize || [30, 30],
|
src: params.url,
|
// 设置图标偏移
|
anchor: params.anchor,
|
// X方向单位:分数
|
anchorXUnits: 'pixels',
|
// Y方向单位:像素
|
anchorYUnits: 'pixels',
|
}),
|
|
text: new Text({
|
// 对齐方式
|
textAlign: 'center',
|
// 文本基线
|
textBaseline: 'middle',
|
text: textElement.innerHTML,
|
font: '14px Arial',
|
fill: new Fill({
|
color: '#351FAD'
|
}),
|
stroke: new Stroke({ color: 'white', width: 1 })
|
})
|
}))
|
|
let featureEvent
|
|
if (params.event) {
|
featureEvent = params.event
|
} else {
|
featureEvent = () => { }
|
}
|
|
iconFeature.on('click', featureEvent)
|
|
return iconFeature
|
},
|
|
mapPopup (param) {
|
getChildNavDetail({ id: param.id }).then((res) => {
|
var result = res.data.data[0].list
|
this.$store.commit('CLEAR_ALL', null)
|
|
var imgArr = result.tpurl.split(',')
|
|
const position = this.coordinate(result.x)
|
|
this.$store.commit('SET_POPUPBGURL', imgArr[0])
|
this.$store.commit('SET_POPUPQRURL', result.codeurl)
|
|
this.map2D.getView().setCenter([Number(position.lng), Number(position.lat)])
|
|
this.$store.commit('SET_STATENAME', result.mechanismname)
|
this.$store.commit('SET_SITENAME', result.address)
|
this.$store.commit('SET_TELEPHONE', result.telephone)
|
this.$store.commit('SET_INTRODUCETEXT', result.introduce)
|
this.$store.commit('SET_PANORAMAURL', result.panoramaurl)
|
this.$store.commit('SET_POPUPIMGATLAS', imgArr)
|
if (result.videourl && result.videourl != '') {
|
this.$store.commit('SET_MONITORURL', result.videourl)
|
}
|
if (res.data.data[0].jx != undefined && res.data.data[0].jx != '') {
|
var tabOne = res.data.data[0].jx.split(',')
|
this.$store.commit('SET_TEACHLIST', tabOne)
|
} else {
|
this.$store.commit('SET_TEACHLIST', [])
|
}
|
|
if (res.data.data[0].sh != undefined && res.data.data[0].sh != '') {
|
var tabTwo = res.data.data[0].sh.split(',')
|
this.$store.commit('SET_LIVELIST', tabTwo)
|
} else {
|
this.$store.commit('SET_LIVELIST', [])
|
}
|
|
this.newPopup(result, position)
|
|
if (this.twoOrThree == '三 维') {
|
this.$store.commit('SET_POINTPOSITION', [
|
Number(position.lng),
|
Number(position.lat),
|
Number(result.gd),
|
Number(result.heading),
|
Number(result.pitch),
|
Number(result.roll)
|
])
|
} else {
|
this.$store.commit('SET_POINTPOSITION', [
|
Number(result.jd),
|
Number(result.wd),
|
Number(result.gd),
|
Number(result.heading),
|
Number(result.pitch),
|
Number(result.roll)
|
])
|
}
|
})
|
},
|
|
newPopup (item, positionArr) {
|
if (this.twoOrThree == '三 维') {
|
this.$EventBus.$emit('openInfoWindowHtml', {
|
lng: Number(positionArr.lng),
|
lat: Number(positionArr.lat)
|
})
|
} else {
|
this.$EventBus.$emit('openInfoWindowHtml', {
|
lng: Number(item.jd),
|
lat: Number(item.wd)
|
})
|
}
|
|
this.$store.commit('SET_PANORAMAPOPUP', false)
|
this.$store.commit('SET_MONITORPOPUP', false)
|
this.$store.commit('SET_DETAILSPOPUP', true)
|
},
|
|
closeModel () {
|
var path = this.$route.path
|
if (path.indexOf('/arc') != -1) {
|
this.$store.dispatch('delVisitedViews', this.$route)
|
this.$router.push('/pcLayout/default')
|
}
|
|
this.$store.commit('SET_ARCNAVBARTITLE', '')
|
this.$store.commit('SET_ARCNAVBARCODE', '')
|
this.$store.commit('SET_ARCNAVBARFLAG', false)
|
|
this.$store.commit('SET_DETAILSPOPUP', false)
|
this.$store.commit('SET_PANORAMAPOPUP', false)
|
this.$store.commit('SET_MONITORPOPUP', false)
|
|
if (currentOrgLayer != null) {
|
this.map2D.removeLayer(currentOrgLayer)
|
currentOrgLayer = null
|
}
|
}
|
},
|
|
destroyed () {
|
this.closeModel()
|
}
|
}
|
</script>
|
|
<style scoped lang="scss"></style>
|