From 81f54040c2cb65537c6c6e1db8358a39a57dea0d Mon Sep 17 00:00:00 2001
From: mayisheng <admin>
Date: Mon, 15 Aug 2022 16:14:01 +0800
Subject: [PATCH] 1

---
 src/pcviews/specialmap/welcome.vue |  136 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 130 insertions(+), 6 deletions(-)

diff --git a/src/pcviews/specialmap/welcome.vue b/src/pcviews/specialmap/welcome.vue
index cb79c76..1968d5c 100644
--- a/src/pcviews/specialmap/welcome.vue
+++ b/src/pcviews/specialmap/welcome.vue
@@ -18,7 +18,7 @@
                         <img
                             @click="audioPlay"
                             class="audio-control deblurring"
-                            src="/img/navicon/audio.png"
+                            :src="audioImgUrl"
                             alt
                         />
                     </a>
@@ -73,6 +73,16 @@
                 </div>
             </div>
         </div>
+
+        <div v-show="layerList.length > 0" class="layer-manage-container">
+            <div class="header">图层管理</div>
+            <ul class="content">
+                <li v-for="(item, index) in layerList" :key="index">
+                    {{item.name}}:
+                    <el-switch v-model="item.flag" @change="switchChange(item)"></el-switch>
+                </li>
+            </ul>
+        </div>
     </div>
 </template>
 
@@ -82,10 +92,13 @@
 
 let pathLayer = null
 let pointLayer = null
+let special = []
 
 export default {
     data () {
         return {
+            url: '',
+            layerList: [],
             time: '',
             sponsor: '',
             undertake: '',
@@ -102,24 +115,56 @@
             audioCourse: false,
             audioSynth: null,
             audioMsg: null,
-            panoramaShow: false
+            panoramaShow: false,
+            audioImgUrl: '/img/icon/start-video.png',
+            urlDataName: null
         }
     },
     created () { },
     mounted () {
+        var that = this
+
         this.audioSynth = window.speechSynthesis
 
         this.audioMsg = new window.SpeechSynthesisUtterance()
 
         this.audioMsg.onend = function () {
             // this.audioSynth.cancel();
-            this.audioFlag = false
-            this.audioCourse = false
+            that.audioFlag = false
+            that.audioCourse = false
+            that.audioImgUrl = '/img/icon/close-video.png'
         }
-        this.getData()
 
         window.onbeforeunload = e => { // 刷新时弹出提示
             this.audioSynth.cancel()
+        }
+    },
+    watch: {
+        $route: {
+            immediate: true,
+            handler (newData, oldData) {
+                if (this.urlDataName == null) {
+                    this.urlDataName = this.$route.query.name
+                    this.getData()
+                } else if (newData.query.name != this.urlDataName) {
+                    if (special.length > 0) {
+                        special.forEach(item => {
+                            global.viewer.imageryLayers.remove(
+                                item.layer
+                            )
+                        })
+                    }
+                    special = []
+                    this.audioSynth.cancel()
+                    global.viewer.removeLayer(pathLayer)
+                    global.viewer.removeLayer(pointLayer)
+                    this.urlDataName = this.$route.query.name
+                    this.getData()
+                }
+                // if (this.$route.query.type) {//需要监听的参数
+                //     this.type = this.$route.query.type
+                // }
+            }
         }
     },
     computed: {
@@ -131,8 +176,39 @@
         ])
     },
     methods: {
+        switchChange (item) {
+            if (item.flag == true) {
+                this.addArcgisLayer(item.url, item.name)
+            } else {
+                this.removeArcgisLayer(item.name)
+            }
+        },
+
+        addArcgisLayer (url, name) {
+            var layer = global.viewer.imageryLayers.addImageryProvider(
+                new global.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
+                    url: url
+                })
+            )
+            special.push({
+                layer,
+                name
+            })
+        },
+
+        removeArcgisLayer (name) {
+            special.forEach((item, index) => {
+                if (item.name == name) {
+                    global.viewer.imageryLayers.remove(
+                        item.layer
+                    )
+                    special.splice(index, 1)
+                }
+            })
+        },
+
         getData () {
-            getWelcome({ hdname: '校区迎新' }).then((res) => {
+            getWelcome({ hdname: this.urlDataName }).then((res) => {
                 var result = res.data.data
                 this.title = result.hdname
                 this.time = result.time
@@ -148,6 +224,17 @@
                 this.list = result.tpurl.split(',')
                 this.pointNameList = result.addressname.split(',')
                 this.pointList = result.address.split(';')
+                this.layerList = []
+
+                if (result.mapname != '' && result.mapname != null && result.mapname != undefined) {
+                    var mapname = result.mapname.split(',')
+                    var url = result.url.split(',')
+                    mapname.forEach((item, index) => {
+                        this.layerList.push({ flag: false, name: item, url: url[index] })
+                    })
+                    this.layerList[0].flag = true
+                    this.addArcgisLayer(this.layerList[0].url, this.layerList[0].name)
+                }
 
                 var a = result.lx.split(';')
 
@@ -178,6 +265,7 @@
                 this.pointList.forEach((item, index) => {
                     this.drawPoint(item.split(','), this.pointNameList[index])
                 })
+
                 if (this.pointList.length > 0) {
                     this.$store.dispatch('pcMoveView', {
                         viewer: global.viewer,
@@ -232,17 +320,29 @@
                 this.audioSynth.speak(this.audioMsg)
                 this.audioFlag = true
                 this.audioCourse = true
+                this.audioImgUrl = '/img/icon/start-video.png'
             } else {
                 if (this.audioCourse == true) {
                     this.audioSynth.pause()
                     this.audioCourse = false
+                    this.audioImgUrl = '/img/icon/close-video.png'
                 } else {
                     this.audioSynth.resume()
                     this.audioCourse = true
+                    this.audioImgUrl = '/img/icon/start-video.png'
                 }
             }
         },
         closeModel () {
+            if (special.length > 0) {
+                special.forEach(item => {
+                    global.viewer.imageryLayers.remove(
+                        item.layer
+                    )
+                })
+            }
+            special = []
+
             global.viewer.removeLayer(pathLayer)
             global.viewer.removeLayer(pointLayer)
 
@@ -502,4 +602,28 @@
         }
     }
 }
+
+.layer-manage-container {
+    padding: 0 10px 10px 10px;
+    position: fixed;
+    right: 10px;
+    bottom: 240px;
+    width: 120px;
+    background: rgba(40, 187, 240, 0.7);
+    border-radius: 10px;
+    color: #fff;
+    border: 1px solid #29baf1;
+    box-shadow: 0 0 10px 2px #29baf1;
+
+    .header {
+        line-height: 36px;
+        text-align: center;
+    }
+
+    .content {
+        max-height: calc(180px - 36px);
+        overflow-y: auto;
+        text-align: center;
+    }
+}
 </style>

--
Gitblit v1.9.3