shuishen
2022-03-08 368cadf28a912e35bd9d8017588cb0aefffc7b79
src/components/searchDetails/index.vue
@@ -1,317 +1,310 @@
<template>
  <div class="search-nav-bar" ref="searchNavBar">
    <div class="container">
      <div class="header" @mousedown="move" :class="{ move: moveFlag }">
        <div class="title">
          <img class="icon deblurring" src="/img/icon/search.png" alt />
          <span>查询结果</span>
    <div class="search-nav-bar" ref="searchNavBar">
        <div class="container">
            <div class="header" @mousedown="move" :class="{ move: moveFlag }">
                <div class="title">
                    <img class="icon deblurring" src="/img/icon/search.png" alt />
                    <span>查询结果</span>
                </div>
                <img class="close" src="/img/navicon/close.png" alt @click="closeModel" />
            </div>
            <div class="content">
                <ul>
                    <li
                        v-for="(item, index) in searchPopupList"
                        :key="index"
                        @click="mapPopup(item)"
                    >
                        <img src="/img/navicon/tag.png" alt />
                        <span>{{ item.mechanismname }}</span>
                    </li>
                </ul>
            </div>
        </div>
        <img
          class="close"
          src="/img/navicon/close.png"
          alt
          @click="closeModel"
        />
      </div>
      <div class="content">
        <ul>
          <li
            v-for="(item, index) in searchPopupList"
            :key="index"
            @click="mapPopup(item)"
          >
            <img src="/img/navicon/tag.png" alt />
            <span>{{ item.mechanismname }}</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { mapGetters } from 'vuex'
export default {
  name: "searchDetails",
  data() {
    return {
      moveFlag: false,
      DC: null,
    };
  },
  created() {
    this.DC = global.DC;
  },
  computed: {
    ...mapGetters([
      "viewer",
      "popupBgUrl",
      "pupupQRUrl",
      // 点信息
      "pointPosition",
      // 点名称
      "stateName",
      // 地址
      "siteName",
      // 介绍
      "introduceText",
      // 全景地址
      "panoramaUrl",
      "searchPopupList",
    ]),
  },
  methods: {
    move(e) {
      const that = this;
      const odiv = this.$refs.searchNavBar; // 获取目标元素
      // 算出鼠标相对元素的位置
      const disX = e.clientX - odiv.offsetLeft;
      const disY = e.clientY - odiv.offsetTop;
      const disH = odiv.offsetHeight;
      const disW = odiv.offsetWidth;
      document.onmousemove = (e) => {
        that.moveFlag = true;
        // 鼠标按下并移动的事件
        // 用鼠标的位置减去鼠标相对元素的位置,得到元素的位置
        let left = e.clientX - disX;
        let top = e.clientY - disY;
        // 绑定元素位置到positionX和positionY上面
        if (left >= window.innerWidth - disW) {
          left = window.innerWidth - disW;
    name: 'searchDetails',
    data () {
        return {
            moveFlag: false
        }
    },
    created () {
    },
    computed: {
        ...mapGetters([
            'viewer',
            'popupBgUrl',
            'pupupQRUrl',
            // 点信息
            'pointPosition',
            // 点名称
            'stateName',
            // 地址
            'siteName',
            // 介绍
            'introduceText',
            // 全景地址
            'panoramaUrl',
            'searchPopupList'
        ])
    },
    methods: {
        move (e) {
            const that = this
            const odiv = this.$refs.searchNavBar // 获取目标元素
            // 算出鼠标相对元素的位置
            const disX = e.clientX - odiv.offsetLeft
            const disY = e.clientY - odiv.offsetTop
        if (left <= 0) {
          left = 0;
            const disH = odiv.offsetHeight
            const disW = odiv.offsetWidth
            document.onmousemove = (e) => {
                that.moveFlag = true
                // 鼠标按下并移动的事件
                // 用鼠标的位置减去鼠标相对元素的位置,得到元素的位置
                let left = e.clientX - disX
                let top = e.clientY - disY
                // 绑定元素位置到positionX和positionY上面
                if (left >= window.innerWidth - disW) {
                    left = window.innerWidth - disW
                }
                if (left <= 0) {
                    left = 0
                }
                if (top >= window.innerHeight - disH) {
                    top = window.innerHeight - disH
                }
                if (top <= 60) {
                    top = 60
                }
                // 移动当前元素
                odiv.style.left = left + 'px'
                odiv.style.top = top + 'px'
                odiv.style.bottom = 'auto'
            }
            document.onmouseup = (e) => {
                that.moveFlag = false
                document.onmousemove = null
                document.onmouseup = null
            }
        },
        mapPopup (item) {
            this.$store.commit('CLEAR_ALL', null)
            var imgArr = item.tpurl.split(',')
            this.$store.commit('SET_POPUPBGURL', imgArr[0])
            this.$store.commit('SET_POPUPQRURL', item.codeurl)
            this.$store.commit('SET_POINTPOSITION', [
                Number(item.jd),
                Number(item.wd),
                Number(item.gd),
                Number(item.heading),
                Number(item.pitch),
                Number(item.roll)
            ])
            this.$store.commit('SET_STATENAME', item.mechanismname)
            this.$store.commit('SET_SITENAME', item.address)
            this.$store.commit('SET_TELEPHONE', item.telephone)
            this.$store.commit('SET_INTRODUCETEXT', item.introduce)
            this.$store.commit('SET_PANORAMAURL', item.panoramaurl)
            this.$store.commit('SET_POPUPIMGATLAS', imgArr)
            if (item.videourl && item.videourl != '') {
                this.$store.commit('SET_MONITORURL', item.videourl)
            }
            if (item.jx != undefined && item.jx != '') {
                var tabOne = item.jx.split(',')
                this.$store.commit('SET_TEACHLIST', tabOne)
            } else {
                this.$store.commit('SET_TEACHLIST', [])
            }
            if (item.sh != undefined && item.sh != '') {
                var tabTwo = item.sh.split(',')
                this.$store.commit('SET_LIVELIST', tabTwo)
            } else {
                this.$store.commit('SET_LIVELIST', [])
            }
            this.newPopup(item)
            this.viewer.flyToPosition(
                new global.DC.Position(
                    Number(item.jd),
                    Number(item.wd),
                    Number(300),
                    Number(item.heading),
                    Number(item.pitch),
                    Number(item.roll)
                ),
                function () { },
                3
            )
        },
        newPopup (item) {
            const position = global.DC.Transform.transformWGS84ToCartesian(
                new global.DC.Position(
                    Number(item.jd),
                    Number(item.wd),
                    Number(item.gd),
                    Number(item.heading),
                    Number(item.pitch),
                    Number(item.roll)
                )
            )
            // eslint-disable-next-line no-unused-vars
            var popup = new global.DC.DivForms(this.viewer, {
                domId: 'divFormsDomBox',
                position: [position]
            })
            this.$store.commit('SET_PANORAMAPOPUP', false)
            this.$store.commit('SET_MONITORPOPUP', false)
            this.$store.commit('SET_DETAILSPOPUP', true)
        },
        closeModel () {
            this.$store.commit('SET_SEARCHPOPUPFLAG', false)
            this.$store.commit('SET_SEARCHPOPUPLIST', [])
        }
        if (top >= window.innerHeight - disH) {
          top = window.innerHeight - disH;
        }
        if (top <= 60) {
          top = 60;
        }
        // 移动当前元素
        odiv.style.left = left + "px";
        odiv.style.top = top + "px";
        odiv.style.bottom = "auto";
      };
      document.onmouseup = (e) => {
        that.moveFlag = false;
        document.onmousemove = null;
        document.onmouseup = null;
      };
    },
    mapPopup(item) {
      this.$store.commit("CLEAR_ALL", null);
      var imgArr = item.tpurl.split(",");
      this.$store.commit("SET_POPUPBGURL", imgArr[0]);
      this.$store.commit("SET_POPUPQRURL", item.codeurl);
      this.$store.commit("SET_POINTPOSITION", [
        Number(item.jd),
        Number(item.wd),
        Number(item.gd),
        Number(item.heading),
        Number(item.pitch),
        Number(item.roll),
      ]);
      this.$store.commit("SET_STATENAME", item.mechanismname);
      this.$store.commit("SET_SITENAME", item.address);
      this.$store.commit("SET_TELEPHONE", item.telephone);
      this.$store.commit("SET_INTRODUCETEXT", item.introduce);
      this.$store.commit("SET_PANORAMAURL", item.panoramaurl);
      this.$store.commit("SET_POPUPIMGATLAS", imgArr);
      if (item.videourl && item.videourl != "") {
        this.$store.commit("SET_MONITORURL", item.videourl);
      }
      if (item.jx != undefined && item.jx != "") {
        var tabOne = item.jx.split(",");
        this.$store.commit("SET_TEACHLIST", tabOne);
      } else {
        this.$store.commit("SET_TEACHLIST", []);
      }
      if (item.sh != undefined && item.sh != "") {
        var tabTwo = item.sh.split(",");
        this.$store.commit("SET_LIVELIST", tabTwo);
      } else {
        this.$store.commit("SET_LIVELIST", []);
      }
      this.newPopup(item);
      this.viewer.flyToPosition(
        new this.DC.Position(
          Number(item.jd),
          Number(item.wd),
          Number(300),
          Number(item.heading),
          Number(item.pitch),
          Number(item.roll)
        ),
        function () {},
        3
      );
    },
    newPopup(item) {
      const position = this.DC.Transform.transformWGS84ToCartesian(
        new this.DC.Position(
          Number(item.jd),
          Number(item.wd),
          Number(item.gd),
          Number(item.heading),
          Number(item.pitch),
          Number(item.roll)
        )
      );
      // eslint-disable-next-line no-unused-vars
      var popup = new this.DC.DivForms(this.viewer, {
        domId: "divFormsDomBox",
        position: [position],
      });
      this.$store.commit("SET_PANORAMAPOPUP", false);
      this.$store.commit("SET_MONITORPOPUP", false);
      this.$store.commit("SET_DETAILSPOPUP", true);
    },
    closeModel() {
      this.$store.commit("SET_SEARCHPOPUPFLAG", false);
      this.$store.commit("SET_SEARCHPOPUPLIST", []);
    },
  },
};
    }
}
</script>
<style scoped lang="scss">
.search-nav-bar {
  position: fixed;
  width: 322px;
  height: auto;
  border-radius: 8px;
  top: 140px;
  left: 140px;
  background-color: transparent;
  z-index: 999;
  font-size: 14px;
    position: fixed;
    width: 322px;
    height: auto;
    border-radius: 8px;
    top: 140px;
    left: 140px;
    background-color: transparent;
    z-index: 999;
    font-size: 14px;
  .container {
    .header {
      position: relative;
      border-radius: 8px 8px 0 0;
      width: 100%;
      height: 36px;
      line-height: 36px;
      background: rgba(0, 131, 176, 0.7); /* fallback for old browsers */
      background: -webkit-linear-gradient(
        to left,
        rgba(0, 180, 219, 0.7),
        rgba(0, 131, 176, 0.7)
      ); /* Chrome 10-25, Safari 5.1-6 */
      background: linear-gradient(
        to left,
        rgba(0, 180, 219, 0.7),
        rgba(0, 131, 176, 0.7)
      ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    .container {
        .header {
            position: relative;
            border-radius: 8px 8px 0 0;
            width: 100%;
            height: 36px;
            line-height: 36px;
            background: rgba(0, 131, 176, 0.7); /* fallback for old browsers */
            background: -webkit-linear-gradient(
                to left,
                rgba(0, 180, 219, 0.7),
                rgba(0, 131, 176, 0.7)
            ); /* Chrome 10-25, Safari 5.1-6 */
            background: linear-gradient(
                to left,
                rgba(0, 180, 219, 0.7),
                rgba(0, 131, 176, 0.7)
            ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
      .title {
        padding-left: 10px;
            .title {
                padding-left: 10px;
        img {
          width: 20px;
          height: 20px;
          vertical-align: middle;
                img {
                    width: 20px;
                    height: 20px;
                    vertical-align: middle;
                }
                span {
                    margin-left: 6px;
                    display: inline-block;
                    vertical-align: middle;
                    color: #fff;
                }
            }
            .close {
                position: absolute;
                right: 6px;
                top: 0;
                left: auto;
                bottom: 0;
                margin: auto;
                width: 14px;
                height: 14px;
                cursor: pointer;
            }
        }
        span {
          margin-left: 6px;
          display: inline-block;
          vertical-align: middle;
          color: #fff;
        .move {
            cursor: move;
        }
      }
      .close {
        position: absolute;
        right: 6px;
        top: 0;
        left: auto;
        bottom: 0;
        margin: auto;
        width: 14px;
        height: 14px;
        cursor: pointer;
      }
    }
        .content {
            clear: both;
            width: 100%;
            height: 440px;
            margin-top: 0px;
            text-align: center;
            overflow-y: auto;
            background: rgba(0, 131, 176, 0.7); /* fallback for old browsers */
            background: -webkit-linear-gradient(
                to left,
                rgba(0, 180, 219, 0.7),
                rgba(0, 131, 176, 0.7)
            ); /* Chrome 10-25, Safari 5.1-6 */
            background: linear-gradient(
                to left,
                rgba(0, 180, 219, 0.7),
                rgba(0, 131, 176, 0.7)
            ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
            border-radius: 0 0 8px 8px;
    .move {
      cursor: move;
    }
            ul {
                padding: 15px;
                padding-top: 4px;
    .content {
      clear: both;
      width: 100%;
      height: 440px;
      margin-top: 0px;
      text-align: center;
      overflow-y: auto;
      background: rgba(0, 131, 176, 0.7); /* fallback for old browsers */
      background: -webkit-linear-gradient(
        to left,
        rgba(0, 180, 219, 0.7),
        rgba(0, 131, 176, 0.7)
      ); /* Chrome 10-25, Safari 5.1-6 */
      background: linear-gradient(
        to left,
        rgba(0, 180, 219, 0.7),
        rgba(0, 131, 176, 0.7)
      ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
      border-radius: 0 0 8px 8px;
                li {
                    padding-left: 24px;
                    position: relative;
                    height: 40px;
                    line-height: 40px;
                    list-style: none;
                    border-bottom: 1px dashed #ccc;
                    text-align: left;
      ul {
        padding: 15px;
        padding-top: 4px;
                    img {
                        position: absolute;
                        left: 0;
                        right: auto;
                        top: 0;
                        bottom: 0;
                        margin: auto;
                        width: 14px;
                    }
        li {
          padding-left: 24px;
          position: relative;
          height: 40px;
          line-height: 40px;
          list-style: none;
          border-bottom: 1px dashed #ccc;
          text-align: left;
                    span {
                        color: #fff;
                        cursor: pointer;
                    }
          img {
            position: absolute;
            left: 0;
            right: auto;
            top: 0;
            bottom: 0;
            margin: auto;
            width: 14px;
          }
          span {
            color: #fff;
            cursor: pointer;
          }
          span:hover {
            text-decoration: underline;
          }
                    span:hover {
                        text-decoration: underline;
                    }
                }
            }
        }
      }
    }
  }
}
</style>