From 3c732cb7cf0e83e4ccfa2c347a4955ba8ef8d6a0 Mon Sep 17 00:00:00 2001
From: mayisheng <admin>
Date: Wed, 10 Aug 2022 10:23:11 +0800
Subject: [PATCH] 修改3d标签错乱问题

---
 src/components/serviceNavBar/index.vue |   86 ++++++++++++++++++++++++++++++++----------
 1 files changed, 65 insertions(+), 21 deletions(-)

diff --git a/src/components/serviceNavBar/index.vue b/src/components/serviceNavBar/index.vue
index 4a76bf5..05aad93 100644
--- a/src/components/serviceNavBar/index.vue
+++ b/src/components/serviceNavBar/index.vue
@@ -5,7 +5,7 @@
                 <img class="icon deblurring" :src="headerLog" alt />
                 <span>{{ title }}</span>
             </div>
-            <img class="close" src="/img/navicon/close.png" alt @click="closeModel" />
+            <img class="close deblurring" src="/img/navicon/close.png" alt @click="closeModel" />
         </template>
         <template slot="public-box-content">
             <div class="tab" v-show="false">
@@ -36,12 +36,13 @@
 import { mapGetters } from 'vuex'
 import { getList, getLifeList } from '@/api/pc/service/index'
 
+let ourLayer = null
+
 export default {
     name: 'ServiceNavBar',
     data () {
         return {
-            itemNavList: [],
-            ourLayer: null
+            itemNavList: []
         }
     },
     props: {
@@ -57,7 +58,6 @@
     },
     computed: {
         ...mapGetters([
-            'viewer',
             'popupBgUrl',
             'pupupQRUrl',
             // 点信息
@@ -69,12 +69,13 @@
             // 介绍
             'introduceText',
             // 全景地址
-            'panoramaUrl'
+            'panoramaUrl',
+            'twoOrThree'
         ])
     },
     created () {
         this.titleList = []
-        // 三江校区//"土木楼"//"科学园"//"黄河路"//"红旗校区"
+        // 三江社区//"土木楼"//"科学园"//"黄河路"//"红旗社区"
         getList().then((res) => {
             res.data.data.forEach((item) => {
                 // console.log(item, "see");
@@ -89,6 +90,26 @@
 
             this.getChilsNavs(this.titleList[0].key)
         })
+    },
+    watch: {
+        twoOrThree: {
+            handler (newData, oldData) {
+                if (newData == '三 维') {
+                    if (ourLayer != null) {
+                        ourLayer.eachOverlay((item) => {
+                            item.position = new global.DC.Position(Number(item.position.lng), Number(item.position.lat), 0)
+                        })
+                    }
+                } else {
+                    if (ourLayer != null) {
+                        ourLayer.eachOverlay((item) => {
+                            item.position = new global.DC.Position(Number(item.position.lng), Number(item.position.lat), 50)
+                        })
+                    }
+                }
+            },
+            immediate: true
+        }
     },
     mounted () { },
     methods: {
@@ -109,13 +130,13 @@
             const that = this
             //   console.log(this.arcCode, "see22");
             // 判断是否是当前所需要图层并创建 属性为 this.arrCode
-            if (this.ourLayer != null) {
-                this.ourLayer.clear()
+            if (ourLayer != null) {
+                ourLayer.clear()
             } else {
-                this.ourLayer = new global.DC.HtmlLayer('Layer' + this.arcCode)
-                this.viewer.addLayer(this.ourLayer)
+                ourLayer = new global.DC.HtmlLayer('Layer' + this.arcCode)
+                global.viewer.addLayer(ourLayer)
             }
-            //   console.log(this.ourLayer, "see");
+            //   console.log(ourLayer, "see");
             getLifeList({ lifetype: this.arcCode, campus: campus }).then((res) => {
                 res.data.data.records.forEach((item) => {
                     //   console.log(item, "see");
@@ -125,15 +146,19 @@
                         details: item
                     })
                     // 创建图标 做生活设施分层标签
-                    that.addDivIcon(item, this.ourLayer)
+                    that.addDivIcon(item, ourLayer)
                 })
             })
         },
         addDivIcon (item, mylayer) {
             const that = this
-            const divIcon = new global.DC.DivIcon(
-                new global.DC.Position(Number(item.jd), Number(item.wd), 0),
-                `
+
+            let divIcon = null
+
+            if (this.twoOrThree == '三 维') {
+                divIcon = new global.DC.DivIcon(
+                    new global.DC.Position(Number(item.jd), Number(item.wd), 0),
+                    `
                               <div class="tag-entitys-box">
                                   <div class="tag-content">
                                       ${item.mechanismname}
@@ -143,7 +168,23 @@
                                   </div>
                               </div>
                           `
-            )
+                )
+            } else {
+                divIcon = new global.DC.DivIcon(
+                    new global.DC.Position(Number(item.jd), Number(item.wd), 50),
+                    `
+                              <div class="tag-entitys-box">
+                                  <div class="tag-content">
+                                      ${item.mechanismname}
+                                  </div>
+                                  <div class="tag-angle-content">
+                                      <img src="https://map.hit.edu.cn/images/tarrow_xq.png">
+                                  </div>
+                              </div>
+                          `
+                )
+            }
+
             // 订阅事件
             divIcon.on(global.DC.MouseEventType.CLICK, (e) => {
                 // console.log(item, "see");
@@ -184,7 +225,7 @@
             }
 
             this.newPopup(result)
-            this.viewer.flyToPosition(
+            global.viewer.flyToPosition(
                 new global.DC.Position(
                     Number(result.jd),
                     Number(result.wd),
@@ -202,7 +243,7 @@
                 new global.DC.Position(Number(item.jd), Number(item.wd), Number(item.gd))
             )
             // eslint-disable-next-line no-unused-vars
-            var popup = new global.DC.DivForms(this.viewer, {
+            var popup = new global.DC.DivForms(global.viewer, {
                 domId: 'divFormsDomBox',
                 position: [position]
             })
@@ -213,11 +254,14 @@
         }
     },
     destroyed () {
-        if (this.ourLayer != null) {
-            this.ourLayer.remove()
-            this.ourLayer = null
+        if (ourLayer != null) {
+            ourLayer.remove()
+            ourLayer = null
         }
+
         this.$store.commit('SET_DETAILSPOPUP', false)
+        this.$store.commit('SET_PANORAMAPOPUP', false)
+        this.$store.commit('SET_MONITORPOPUP', false)
     }
 }
 </script>

--
Gitblit v1.9.3