From 81a26f23ac0567da23b1621d4813a5a2ab54baa2 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 06 Dec 2023 16:36:39 +0800
Subject: [PATCH] 校园搜索功能修改完善,及地图点击弹窗显示内容更换

---
 src/components/campusNav/index.vue                     |    9 +
 src/components/map/components/campusBuildingSearch.vue |  149 ++++++++----------------------------
 src/store/modules/popupParams.js                       |    1 
 src/components/map/index.vue                           |   28 +------
 4 files changed, 46 insertions(+), 141 deletions(-)

diff --git a/src/components/campusNav/index.vue b/src/components/campusNav/index.vue
index 7309cf5..82f7c99 100644
--- a/src/components/campusNav/index.vue
+++ b/src/components/campusNav/index.vue
@@ -130,6 +130,9 @@
             toolTipText: ''
         }
     },
+
+    inject: ["layoutElement"],
+
     computed: {
         ...mapGetters([
             'twoOrThree',
@@ -735,7 +738,8 @@
                 this.toNameShow = false
                 return
             }
-            getSearchList({ mechanismName: this.toNameText }).then((res) => {
+
+            getSearchList({ mechanismName: this.toNameText, campus: this.layoutElement.campusValue }).then((res) => {
                 if (res.data.data.length > 0) {
                     this.toNameList = res.data.data
                     this.toNameShow = true
@@ -749,7 +753,8 @@
                 this.comeNameShow = false
                 return
             }
-            getSearchList({ mechanismName: this.comeNameText }).then((res) => {
+
+            getSearchList({ mechanismName: this.comeNameText, campus: this.layoutElement.campusValue }).then((res) => {
                 if (res.data.data.length > 0) {
                     this.comeNameList = res.data.data
                     this.comeNameShow = true
diff --git a/src/components/map/components/campusBuildingSearch.vue b/src/components/map/components/campusBuildingSearch.vue
index da6bcfc..abd3af4 100644
--- a/src/components/map/components/campusBuildingSearch.vue
+++ b/src/components/map/components/campusBuildingSearch.vue
@@ -39,6 +39,7 @@
     name: 'campusBuildingSearch',
     data () {
         return {
+            map2D: this.$store.state.openlayerData.openlayers.map2D,
             shortcutList: [
                 {
                     bgimg: '/changjing/img/search/org.png',
@@ -54,13 +55,13 @@
                 //     path: '/pcLayout/default/orgnav/ofc',
                 //     code: 2
                 // },
-                // {
-                //     bgimg: '/changjing/img/search/teach.png',
-                //     title: '教学科研',
-                //     type: 'arc',
-                //     path: '/pcLayout/default/arc/teaching',
-                //     code: 2
-                // },
+                {
+                    bgimg: '/changjing/img/search/teach.png',
+                    title: '教学科研',
+                    type: 'arc',
+                    path: '/pcLayout/default/arc/teaching',
+                    code: 2
+                },
                 {
                     bgimg: '/changjing/img/search/venue.png',
                     title: '校园场馆',
@@ -68,13 +69,13 @@
                     path: '/pcLayout/default/arc/venue',
                     code: 3
                 },
-                {
-                    bgimg: '/changjing/img/search/floor.png',
-                    title: '主要场馆',
-                    type: 'arc',
-                    path: '/pcLayout/default/arc/rest',
-                    code: 7
-                }
+                // {
+                //     bgimg: '/changjing/img/search/floor.png',
+                //     title: '主要场馆',
+                //     type: 'arc',
+                //     path: '/pcLayout/default/arc/rest',
+                //     code: 7
+                // }
                 // {
                 //     bgimg: '/changjing/img/search/scenery.png',
                 //     title: '文化风景',
@@ -89,6 +90,9 @@
             searchValList: []
         }
     },
+
+    inject: ["layoutElement"],
+
     computed: {
         ...mapGetters([
             // 校园内导航的显示关闭
@@ -98,8 +102,10 @@
             'twoOrThree'
         ])
     },
+
     created () {
     },
+
     methods: {
         coordinate (item) {
             const arr = item.split(',')
@@ -116,7 +122,8 @@
                 this.searchValShow = false
                 return
             }
-            getSearchList({ mechanismName: this.searchInput }).then((res) => {
+
+            getSearchList({ mechanismName: this.searchInput, campus: this.layoutElement.campusValue }).then((res) => {
                 if (res.data.data.length > 0) {
                     this.searchValList = res.data.data
                     this.searchValShow = true
@@ -223,107 +230,21 @@
             that.searchValList = []
             that.searchValShow = false
 
-            this.$store.commit('CLEAR_ALL', null)
-
-            var imgArr = param.tpurl.split(',')
-
-            this.$store.commit('SET_POPUPBGURL', imgArr[0])
-            this.$store.commit('SET_POPUPQRURL', param.codeurl)
-
-            this.$store.commit('SET_STATENAME', param.mechanismname)
-            this.$store.commit('SET_SITENAME', param.address)
-            this.$store.commit('SET_TELEPHONE', param.telephone)
-            this.$store.commit('SET_INTRODUCETEXT', param.introduce)
-            if (param.panoramaurl != '') {
-                this.$store.commit('SET_PANORAMAURL', param.panoramaurl)
-            }
-            if (param.videourl && param.videourl != '') {
-                this.$store.commit('SET_MONITORURL', param.videourl)
-            }
-            this.$store.commit('SET_POPUPIMGATLAS', imgArr)
-            if (param.jx != undefined && param.jx != '') {
-                var tabOne = param.jx.split(',')
-                this.$store.commit('SET_TEACHLIST', tabOne)
-            } else {
-                this.$store.commit('SET_TEACHLIST', [])
-            }
-
-            if (param.sh != undefined && param.sh != '') {
-                var tabTwo = param.sh.split(',')
-                this.$store.commit('SET_LIVELIST', tabTwo)
-            } else {
-                this.$store.commit('SET_LIVELIST', [])
-            }
-
-            this.newPopup(param, obj)
-            if (this.twoOrThree == '三 维') {
-                this.$store.commit('SET_POINTPOSITION', [
-                    Number(obj.lng),
-                    Number(obj.lat),
-                    Number(param.gd),
-                    Number(param.heading),
-                    Number(param.pitch),
-                    Number(param.roll)
-                ])
-
-                global.viewer.flyToPosition(
-                    new global.DC.Position(
-                        Number(obj.lng),
-                        Number(obj.lat),
-                        300,
-                        Number(param.heading),
-                        Number(param.pitch),
-                        Number(param.roll)
-                    ),
-                    () => { },
-                    0.5
-                )
-            } else {
-                this.$store.commit('SET_POINTPOSITION', [
-                    Number(param.jd),
-                    Number(param.wd),
-                    Number(50),
-                    Number(param.heading),
-                    Number(param.pitch),
-                    Number(param.roll)
-                ])
-
-                global.viewer.flyToPosition(
-                    new global.DC.Position(
-                        Number(param.jd),
-                        Number(param.wd),
-                        300,
-                        Number(param.heading),
-                        Number(param.pitch),
-                        Number(param.roll)
-                    ),
-                    () => { },
-                    0.5
-                )
-            }
-        },
-
-        newPopup (item, obj) {
-            let position
-            if (this.twoOrThree == '三 维') {
-                position = global.DC.Transform.transformWGS84ToCartesian(
-                    new global.DC.Position(Number(obj.lng), Number(obj.lat), Number(item.gd))
-                )
-            } else {
-                position = global.DC.Transform.transformWGS84ToCartesian(
-                    new global.DC.Position(Number(item.jd), Number(item.wd), Number(50))
-                )
-            }
-
-            // eslint-disable-next-line no-unused-vars
-            var popup = new global.DC.DivForms(global.viewer, {
-                domId: 'divFormsDomBox',
-                position: [position]
+            this.$store.dispatch('setOurDataInPoput', {
+                item: param
             })
 
-            this.$store.commit('SET_PANORAMAPOPUP', false)
-            this.$store.commit('SET_MONITORPOPUP', false)
-            this.$store.commit('SET_DETAILSPOPUP', true)
+            this.openPopups({
+                lng: Number(obj.lng),
+                lat: Number(obj.lat),
+                item: param,
+            })
+        },
+
+        openPopups (value) {
+            this.map2D.getView().setCenter([value.lng, value.lat])
+
+            this.$EventBus.$emit('openInfoWindowHtml', value)
         }
     }
 }
diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index ea0be1c..8112c63 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -6,7 +6,7 @@
 
         <mapPopup />
 
-        <!-- <campusBuildingSearch ref="campusBuildingSearch" /> -->
+        <campusBuildingSearch ref="campusBuildingSearch" />
 
         <campusNav ref="campusNavRoute" v-show="campusNavFlag" />
 
@@ -357,29 +357,9 @@
                 if (JSON.stringify(res.data.data) == '{}') return
                 let result = res.data.data
 
-                that.$store.commit('SET_MONITORPOPUP', false)
-                that.$store.commit("SET_PANORAMAPOPUP", false)
-
-                this.$store.commit('SET_STATENAME', result.mechanismname)
-                this.$store.commit('SET_PANORAMAURL', result.panoramaurl)
-                this.$store.commit('SET_INTRODUCETEXT', result.introduce)
-
-                let imgArr = result.tpurl.split(',')
-
-                this.$store.commit('SET_POPUPBGURL', imgArr[0])
-                this.$store.commit('SET_POPUPIMGATLAS', imgArr)
-                this.$store.commit('SET_POPUPQRURL', result.codeurl)
-
-                this.$store.commit("SET_POINTPOSITION", [
-                    Number(event.event.coordinate[0]),
-                    Number(event.event.coordinate[1]),
-                    Number(0),
-                    Number(0),
-                    Number(-90),
-                    Number(0),
-                ])
-
-                this.$store.commit("SET_DETAILSPOPUP", true)
+                this.$store.dispatch('setOurDataInPoput', {
+                    item: result
+                })
 
                 this.openPopups({
                     lng: Number(event.event.coordinate[0]),
diff --git a/src/store/modules/popupParams.js b/src/store/modules/popupParams.js
index f418130..e0cb917 100644
--- a/src/store/modules/popupParams.js
+++ b/src/store/modules/popupParams.js
@@ -190,7 +190,6 @@
     },
     setOurDataInPoput({ state, commit, dispatch }, value) {
       // 弹窗使用方法
-
       commit("CLEAR_ALL", null);
       commit("SET_MONITORPOPUP", false);
       commit("SET_PANORAMAPOPUP", false);

--
Gitblit v1.9.3