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 |  447 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 290 insertions(+), 157 deletions(-)

diff --git a/src/pcviews/specialmap/welcome.vue b/src/pcviews/specialmap/welcome.vue
index cfa5954..1968d5c 100644
--- a/src/pcviews/specialmap/welcome.vue
+++ b/src/pcviews/specialmap/welcome.vue
@@ -1,101 +1,104 @@
-/*
- * @Author: Morpheus
- * @Name: 社区迎新
- * @Date: 2021-11-15 17:14:47
- * @Last Modified by: Morpheus
- * @Last Modified time: 2022-01-26 10:51:24
- */
+/* * @Author: Morpheus * @Name: 校区迎新 * @Date: 2021-11-15 17:14:47 * @Last
+Modified by: Morpheus * @Last Modified time: 2022-01-26 10:51:24 */
 <template>
     <div>
         <div class="welcome-container">
             <div class="header">
                 <div class="title">
                     {{ title }}
-                    <a href="javascript:void(0);"
-                       title="全景浏览">
-                        <img @click="panoramaPlay"
-                             class="panorama-control"
-                             src="/img/icon/panorama.png"
-                             alt="">
+                    <a href="javascript:void(0);" title="全景浏览">
+                        <img
+                            @click="panoramaPlay"
+                            class="panorama-control deblurring"
+                            src="/img/icon/panorama.png"
+                            alt
+                        />
                     </a>
-                    <a href="javascript:void(0);"
-                       title="语音介绍">
-                        <img @click="audioPlay"
-                             class="audio-control"
-                             src="/img/navicon/audio.png"
-                             alt="">
+                    <a href="javascript:void(0);" title="语音介绍">
+                        <img
+                            @click="audioPlay"
+                            class="audio-control deblurring"
+                            :src="audioImgUrl"
+                            alt
+                        />
                     </a>
-                    <a href="javascript:void(0);"
-                       title="关闭">
-                        <img @click="closeModel"
-                             class="close-box"
-                             src="/img/navicon/close.png"
-                             alt="">
+                    <a href="javascript:void(0);" title="关闭">
+                        <img
+                            @click="closeModel"
+                            class="close-box deblurring"
+                            src="/img/navicon/close.png"
+                            alt
+                        />
                     </a>
                 </div>
             </div>
             <div class="content-box">
                 <div class="img-exhibition">
                     <div class="content">
-                        <el-carousel :interval="5000"
-                                     arrow="always"
-                                     height="300px">
-                            <el-carousel-item v-for="item in list"
-                                              :key="item">
-                                <el-image :src="item"
-                                          :preview-src-list="[item]">
-                                </el-image>
+                        <el-carousel :interval="5000" arrow="always" height="300px">
+                            <el-carousel-item v-for="item in list" :key="item">
+                                <el-image :src="item" :preview-src-list="[item]"></el-image>
                             </el-carousel-item>
                         </el-carousel>
                     </div>
                 </div>
-                <div class="organizer">
-                    主办:{{ sponsor }}
-                </div>
-                <div class="undertake">
-                    承办:{{ undertake }}
-                </div>
-                <div class="time-box">
-                    时间:{{ time }}
-                </div>
+                <div class="organizer">主办:{{ sponsor }}</div>
+                <div class="undertake">承办:{{ undertake }}</div>
+                <div class="time-box">时间:{{ time }}</div>
                 <div class="text-introduce">
-                    <div class="title">
-                        相关介绍:
-                    </div>
+                    <div class="title">相关介绍:</div>
                     <div class="content">
-                        <p v-text="introduce">
-
-                        </p>
+                        <p v-text="introduce"></p>
                     </div>
                 </div>
                 <div class="panorama-box" v-show="panoramaShow">
                     <div class="title">
                         全景浏览
-                        <a href="javascript:void(0);"
-                           title="关闭">
-                            <img @click="panoramaShow = false, panoramaUrl = ''"
-                                 class="close-box"
-                                 src="/img/navicon/close.png"
-                                 alt="">
+                        <a href="javascript:void(0);" title="关闭">
+                            <img
+                                @click="(panoramaShow = false), (panoramaUrl = '')"
+                                class="close-box"
+                                src="/img/navicon/close.png"
+                                alt
+                            />
                         </a>
                     </div>
                     <div class="content">
-                        <iframe style="width: 100%; height: 100%" :src="panoramaUrl" frameborder="0"></iframe>
+                        <iframe
+                            style="width: 100%; height: 100%"
+                            :src="panoramaUrl"
+                            frameborder="0"
+                        ></iframe>
                     </div>
                 </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>
 
 <script>
-
 import { getWelcome } from '@/api/pc/public/specialmap'
 import { mapGetters } from 'vuex'
+
+let pathLayer = null
+let pointLayer = null
+let special = []
 
 export default {
     data () {
         return {
+            url: '',
+            layerList: [],
             time: '',
             sponsor: '',
             undertake: '',
@@ -105,9 +108,6 @@
             pathList: [],
             pointNameList: [],
             pointList: [],
-            DC: null,
-            pathLayer: null,
-            pointLayer: null,
             panoramaUrlOne: '',
             panoramaUrl: '',
             audioSource: '',
@@ -115,88 +115,180 @@
             audioCourse: false,
             audioSynth: null,
             audioMsg: null,
-            panoramaShow: false
+            panoramaShow: false,
+            audioImgUrl: '/img/icon/start-video.png',
+            urlDataName: null
         }
     },
-    created () {
-
-    },
+    created () { },
     mounted () {
-        this.DC = global.DC
+        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
+            // this.audioSynth.cancel();
+            that.audioFlag = false
+            that.audioCourse = false
+            that.audioImgUrl = '/img/icon/close-video.png'
         }
 
-        getWelcome({ hdname: '社区迎新' }).then((res) => {
-            var result = res.data.data
-            this.title = result.hdname
-            this.time = result.time
-            this.sponsor = result.sponsor
-            this.undertake = result.undertake
-            this.panoramaUrl = result.panoramaurl
-            this.panoramaUrlOne = result.panoramaurl
-            this.introduce = result.context
-            this.audioSource = result.context
-            this.list = result.tpurl.split(',')
-            this.pointNameList = result.addressname.split(',')
-            this.pointList = result.address.split(';')
-
-            var a = result.lx.split(';')
-
-            a.forEach(item => {
-                var b = item.split('(')
-                var c = b[1].substr(0, b[1].length - 1)
-                var d = c.split(',')
-                var j = []
-                d.forEach(it => {
-                    var e = it.split(' ')
-                    var f = e.join(',')
-                    j.push(f)
-                })
-                var k = j.join(';')
-                this.pathList.push(k)
-            })
-
-            this.pathLayer = new this.DC.VectorLayer('pathLayer')
-            this.viewer.addLayer(this.pathLayer)
-
-            this.pointLayer = new this.DC.HtmlLayer('pointLayer')
-            this.viewer.addLayer(this.pointLayer)
-
-            this.pathList.forEach(item => {
-                this.drawPolyline(item)
-            })
-
-            this.pointList.forEach((item, index) => {
-                this.drawPoint(item.split(','), this.pointNameList[index])
-            })
-        })
+        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: {
         ...mapGetters([
-            'viewer',
-            // 社区内导航的显示关闭
+            // 校区内导航的显示关闭
             'campusNavFlag',
             'orgNavBarFlag',
             'arcNavBarFlag'
         ])
     },
     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: this.urlDataName }).then((res) => {
+                var result = res.data.data
+                this.title = result.hdname
+                this.time = result.time
+                this.sponsor = result.sponsor
+                this.undertake = result.undertake
+                this.panoramaUrl = result.panoramaurl
+                this.panoramaUrlOne = result.panoramaurl
+                this.introduce = result.context
+                this.audioSource = result.context
+
+                this.audioPlay()
+
+                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(';')
+
+                a.forEach((item) => {
+                    var b = item.split('(')
+                    var c = b[1].substr(0, b[1].length - 1)
+                    var d = c.split(',')
+                    var j = []
+                    d.forEach((it) => {
+                        var e = it.split(' ')
+                        var f = e.join(',')
+                        j.push(f)
+                    })
+                    var k = j.join(';')
+                    this.pathList.push(k)
+                })
+
+                pathLayer = new global.DC.VectorLayer('pathLayer')
+                global.viewer.addLayer(pathLayer)
+
+                pointLayer = new global.DC.HtmlLayer('pointLayer')
+                global.viewer.addLayer(pointLayer)
+
+                this.pathList.forEach((item) => {
+                    this.drawPolyline(item)
+                })
+
+                this.pointList.forEach((item, index) => {
+                    this.drawPoint(item.split(','), this.pointNameList[index])
+                })
+
+                if (this.pointList.length > 0) {
+                    this.$store.dispatch('pcMoveView', {
+                        viewer: global.viewer,
+                        jd: +this.pointList[0].split(',')[0] - 0.0005,
+                        wd: this.pointList[0].split(',')[1]
+                    })
+                } else {
+                    this.$store.dispatch('pcMoveView', {
+                        viewer: global.viewer,
+                        jd: +this.pathList[0].split(';')[0].split(',')[0] - 0.0005,
+                        wd: this.pathList[0].split(';')[0].split(',')[1]
+                    })
+                }
+            })
+        },
         drawPolyline (item) {
-            const polyline = new this.DC.Polyline(item)
+            const polyline = new global.DC.Polyline(item)
 
             polyline.setStyle({
                 width: 6,
                 arcType: true,
-                material: new this.DC.PolylineImageTrailMaterialProperty({
-                    color: new this.DC.Color(255, 0, 0),
+                material: new global.DC.PolylineImageTrailMaterialProperty({
+                    color: global.DC.Namespace.Cesium.Color.fromBytes(10, 255, 10),
                     speed: 60,
                     image: '/img/icon/right.png',
                     repeat: { x: 320, y: 1 }
@@ -204,11 +296,11 @@
                 clampToGround: true
             })
 
-            this.pathLayer.addOverlay(polyline)
+            pathLayer.addOverlay(polyline)
         },
         drawPoint (item, name) {
-            const divIcon = new this.DC.DivIcon(
-                new this.DC.Position(Number(item[0]), Number(item[1]), 0),
+            const divIcon = new global.DC.DivIcon(
+                new global.DC.Position(Number(item[0]), Number(item[1]), 0),
                 `
                     <div class="point-entitys-box">
                         <div class="point-logo">
@@ -220,7 +312,7 @@
                     </div>
                 `
             )
-            this.pointLayer.addOverlay(divIcon)
+            pointLayer.addOverlay(divIcon)
         },
         audioPlay () {
             if (this.audioFlag == false) {
@@ -228,19 +320,31 @@
                 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 () {
-            this.viewer.removeLayer(this.pathLayer)
-            this.viewer.removeLayer(this.pointLayer)
+            if (special.length > 0) {
+                special.forEach(item => {
+                    global.viewer.imageryLayers.remove(
+                        item.layer
+                    )
+                })
+            }
+            special = []
+
+            global.viewer.removeLayer(pathLayer)
+            global.viewer.removeLayer(pointLayer)
 
             this.audioSynth.cancel()
             this.audioFlag = false
@@ -253,12 +357,17 @@
             this.panoramaShow = true
             this.panoramaUrl = this.panoramaUrlOne
         }
+    },
+    destroyed () {
+        this.audioSynth.cancel()
+        global.viewer.removeLayer(pathLayer)
+        global.viewer.removeLayer(pointLayer)
+        // console.log("关闭", "see1");
     }
-
 }
 </script>
 
-<style lang='scss' scope>
+<style lang="scss" scope>
 .welcome-container {
     padding: 10px;
     position: fixed;
@@ -416,41 +525,41 @@
                 position: relative;
                 background: #29baf1;
 
-                    .panorama-control {
-                        position: absolute;
-                        top: 0;
-                        right: 56px;
-                        bottom: 0;
-                        left: auto;
-                        margin: auto;
-                        width: 16px;
-                        height: 16px;
-                        cursor: pointer;
-                    }
+                .panorama-control {
+                    position: absolute;
+                    top: 0;
+                    right: 56px;
+                    bottom: 0;
+                    left: auto;
+                    margin: auto;
+                    width: 16px;
+                    height: 16px;
+                    cursor: pointer;
+                }
 
-                    .audio-control {
-                        position: absolute;
-                        top: 0;
-                        right: 32px;
-                        bottom: 0;
-                        left: auto;
-                        margin: auto;
-                        width: 16px;
-                        height: 16px;
-                        cursor: pointer;
-                    }
+                .audio-control {
+                    position: absolute;
+                    top: 0;
+                    right: 32px;
+                    bottom: 0;
+                    left: auto;
+                    margin: auto;
+                    width: 16px;
+                    height: 16px;
+                    cursor: pointer;
+                }
 
-                    .close-box {
-                        position: absolute;
-                        top: 0;
-                        right: 8px;
-                        bottom: 0;
-                        left: auto;
-                        margin: auto;
-                        width: 16px;
-                        height: 16px;
-                        cursor: pointer;
-                    }
+                .close-box {
+                    position: absolute;
+                    top: 0;
+                    right: 8px;
+                    bottom: 0;
+                    left: auto;
+                    margin: auto;
+                    width: 16px;
+                    height: 16px;
+                    cursor: pointer;
+                }
             }
 
             .content {
@@ -493,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