1
mayisheng
2022-08-15 81f54040c2cb65537c6c6e1db8358a39a57dea0d
src/components/map/components/campusBuildingSearch.vue
@@ -3,7 +3,7 @@
        <div class="map-campus-search" id="CampusSearchPanel">
            <el-input
                class="search-input"
                placeholder="社区搜索…"
                placeholder="校区搜索…"
                v-model="searchInput"
                @input="searchValueChange"
                @focus="shortcutFlag = true"
@@ -23,7 +23,7 @@
                        v-for="(item, index) in searchValList"
                        :key="index"
                        @click="loadPopup(item)"
                    >{{item.mechanismname}}</li>
                    >{{ item.mechanismname }}</li>
                </ul>
            </div>
            <div class="map-campus-shortcut" v-show="shortcutFlag">
@@ -32,7 +32,7 @@
                        <li v-for="(item, index) in shortcutList" :key="index">
                            <el-button @click="openModelPopup(item)">
                                <img :src="item.bgimg" alt />
                                <span>{{item.title}}</span>
                                <span>{{ item.title }}</span>
                            </el-button>
                        </li>
                    </ul>
@@ -43,7 +43,6 @@
</template>
<script>
import { mapGetters } from 'vuex'
import { getList } from '@/api/pc/orgnav/index'
@@ -53,7 +52,6 @@
    name: 'campusBuildingSearch',
    data () {
        return {
            DC: null,
            shortcutList: [
                {
                    bgimg: '/img/search/org.png',
@@ -78,7 +76,7 @@
                // },
                {
                    bgimg: '/img/search/venue.png',
                    title: '社区场馆',
                    title: '校区场馆',
                    type: 'arc',
                    path: '/pcLayout/default/arc/venue',
                    code: 3
@@ -91,12 +89,13 @@
                    code: 7
                }
                // {
                //     bgimg: '/img/search/dorm.png',
                //     title: '社区宿舍',
                //     type: 'arc',
                //     path: '/pcLayout/default/arc/dorm',
                //     code: 4
                //   bgimg: "/img/search/dorm.png",
                //   title: "校区宿舍",
                //   type: "arc",
                //   path: "/pcLayout/default/arc/dorm",
                //   code: 4,
                // },
                // {
                //     bgimg: '/img/search/scenery.png',
                //     title: '文化风景',
@@ -113,24 +112,32 @@
    },
    computed: {
        ...mapGetters([
            'viewer',
            // 社区内导航的显示关闭
            // 校区内导航的显示关闭
            'campusNavFlag',
            'orgNavBarFlag',
            'arcNavBarFlag'
            'arcNavBarFlag',
            'twoOrThree'
        ])
    },
    created () {
        this.DC = global.DC
    },
    methods: {
        coordinate (item) {
            const arr = item.split(',')
            return {
                lng: arr[0],
                lat: arr[1]
            }
        },
        searchValueChange () {
            if (this.searchInput == '') {
                this.searchValList = []
                this.searchValShow = false
                return
            }
            getSearchList({ mechanismName: this.searchInput }).then(res => {
            getSearchList({ mechanismName: this.searchInput }).then((res) => {
                if (res.data.data.length > 0) {
                    this.searchValList = res.data.data
                    this.searchValShow = true
@@ -156,7 +163,7 @@
                })
                return
            }
            getSearchList({ mechanismName: this.searchInput }).then(res => {
            getSearchList({ mechanismName: this.searchInput }).then((res) => {
                if (res.data.data.length > 0) {
                    this.$store.commit('SET_SEARCHPOPUPFLAG', true)
                    this.$store.commit('SET_SEARCHPOPUPLIST', res.data.data)
@@ -175,8 +182,8 @@
                this.$store.commit('SET_ORGNAVBARLIST', [])
                this.$store.commit('SET_ORGNAVBARFLAG', true)
                getList({ type: param.code }).then(res => {
                    res.data.data.records.forEach(item => {
                getList({ type: param.code }).then((res) => {
                    res.data.data.records.forEach((item) => {
                        list.push({
                            navTitle: item.mechanismname,
                            icon: '/img/navicon/tag.png',
@@ -210,7 +217,8 @@
            var sp = document.getElementById('CampusSearchPanel')
            if (sp) {
                if (!sp.contains(event.target)) { // 这句是说如果我们点击到了id为myPanel以外的区域
                if (!sp.contains(event.target)) {
                    // 这句是说如果我们点击到了id为myPanel以外的区域
                    this.shortcutFlag = false
                }
            }
@@ -218,6 +226,19 @@
        loadPopup (param) {
            var that = this
            let obj = {}
            if (param.x && param.x != '') {
                const position = this.coordinate(param.x)
                obj = {
                    lng: position.lng, lat: position.lat
                }
            } else {
                obj = {
                    lng: param.longitude, lat: param.latitude
                }
            }
            that.searchInput = ''
            that.searchValList = []
@@ -229,7 +250,7 @@
            this.$store.commit('SET_POPUPBGURL', imgArr[0])
            this.$store.commit('SET_POPUPQRURL', param.codeurl)
            this.$store.commit('SET_POINTPOSITION', [Number(param.jd), Number(param.wd), Number(param.gd), Number(param.heading), Number(param.pitch), Number(param.roll)])
            this.$store.commit('SET_STATENAME', param.mechanismname)
            this.$store.commit('SET_SITENAME', param.address)
            this.$store.commit('SET_TELEPHONE', param.telephone)
@@ -255,24 +276,70 @@
                this.$store.commit('SET_LIVELIST', [])
            }
            this.newPopup(param)
            this.viewer.flyToPosition(
                new this.DC.Position(Number(param.jd), Number(param.wd), 300, Number(param.heading), Number(param.pitch), Number(param.roll)),
                () => {
            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)
                ])
                },
                0.5
            )
                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) {
            const position = this.DC.Transform.transformWGS84ToCartesian(new this.DC.Position(Number(item.jd), Number(item.wd), Number(item.gd)))
        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 this.DC.DivForms(this.viewer, {
            var popup = new global.DC.DivForms(global.viewer, {
                domId: 'divFormsDomBox',
                position: [
                    position
                ]
                position: [position]
            })
            this.$store.commit('SET_PANORAMAPOPUP', false)
@@ -280,11 +347,10 @@
            this.$store.commit('SET_DETAILSPOPUP', true)
        }
    }
}
</script>
<style lang='scss' scope>
<style lang="scss" scope>
.map-campus-search {
    position: fixed;
    top: 100px;
@@ -374,25 +440,26 @@
    }
    .map-campus-shortcut {
        margin-top: 20px;
        margin-top: 40px;
        width: 100%;
        height: 330px;
        // height: 330px;
        height: auto;
        background: #fff;
        border-radius: 5px;
        .shortcut-box {
            padding-top: 36px;
            height: auto;
            ul {
                display: flex;
                width: 100%;
                height: 120px;
                justify-content: flex-start;
                height: auto;
                // justify-content: space-around;
                flex-wrap: wrap;
                li {
                    margin: 0 13px;
                    width: 84px;
                    height: 76px;
                    margin: 22.5px 0 0 22.5px;
                    width: 80px;
                    height: 70px;
                    .el-button {
                        width: 80px;
@@ -426,6 +493,10 @@
                        border: 1px solid #000;
                    }
                }
                li:last-child {
                    margin-bottom: 22.5px;
                }
            }
        }
    }