<template>
  <div
    class="pinBottom-container"
    :class="{
      mobile: isMobile,
    }"
  >
    <div class="pinBottom center">
      <div id="view-controllers" />
    </div>

    <div class="pinBottom left">
      <div>
        <div class="viewContainer">
          <!-- <div
            id="previous"
            class="previous desktop-only ui-icon"
            style="display: none"
          >
            <a>
              <img
                rel="tooltip"
                title=""
                :src="require('@/assets/images/play.png')"
                data-original-title="播放"
                draggable="false"
              />
            </a>
          </div> -->
          <!-- <div
            id="play"
            class="ui-icon"
            rel="tooltip"
            data-original-title="播放"
          >
            <a>
              <img
                :src="require('@/assets/images/auto-roaming-paused.png')"
                draggable="false"
              >
            </a>
          </div> -->
          <!-- <div
            id="pause"
            class="ui-icon"
            style="display: none"
          >
            <a>
              <img
                rel="tooltip"
                title=""
                :src="require('@/assets/images/auto-roaming.png')"
                data-original-title="暂停"
                draggable="false"
              >
            </a>
          </div> -->
          <!-- <div
            id="next"
            class="next desktop-only ui-icon wide"
            style="display: none"
          >
            <a>
              <i
                draggable="false"
                rel="tooltip"
                title=""
                class="icon icon-dpad-right"
                data-original-title="下一个"
              ></i>
            </a>
          </div> -->

          <div
            id="gui-modes-inside"
            data-original-title="全景漫游"
            rel="tooltip"
          >
            <img
              draggable="false"
              class="icon icon-inside active"
              :src="require('@/assets/images/inside.png')"
            >
            <img
              draggable="false"
              class="icon icon-inside inactive"
              :src="require('@/assets/images/inside-inactive.png')"
            >
          </div>
          <div
            id="pullTab"
            data-original-title="导览"
            rel="tooltip"
            title="场景导览"
          >
            <img
              v-if="isGuide"
              draggable="false"
              title=""
              class="icon icon-inside active"
              src="@/assets/images/scenes-guide.png"
            >
            <img
              v-if="!isGuide"
              draggable="false"
              title=""
              class="icon icon-inside inactive"
              src="@/assets/images/scenes-guide-paused.png"
            >
          </div>
          <div
            id="hotList"
            data-original-title="热点列表"
            rel="tooltip"
            title=""
            @click="$router.push({name: 'HotspotList', query: $route.query })"
          >
            <img
              draggable="false"
              class="icon icon-inside"
              :src="require('@/assets/images/hotlist.png')"
            >
          </div>
          <div
            id="gui-modes-dollhouse"
            title="迷你模型"
            data-original-title="迷你模型"
            rel="tooltip"
          >
            <!-- 鼠标移入的显示 -->
            <img
              draggable="false"
              class="icon icon-inside active"
              :src="require('@/assets/images/dollhouse.png')"
            >
            <img
              draggable="false"
              class="icon icon-inside inactive"
              :src="require('@/assets/images/dollhouse-inactive.png')"
            >
          </div>
          <div
            id="gui-modes-floorplan"
            data-original-title="俯视图"
            rel="tooltip"
            title="顶部俯视"
          >
            <!-- 鼠标移入的显示 -->
            <img
              draggable="false"
              class="icon icon-inside active"
              :src="require('@/assets/images/floor.png')"
            >
            <img
              draggable="false"
              class="icon icon-inside inactive"
              :src="require('@/assets/images/floor-inactive.png')"
            >
          </div>
          <!-- <div
              data-original-title="VR"
              id="vr"
              rel="tooltip"
              title=""
              style="display: none"
            >
              <img
                draggable="false"
                class="icon icon-inside"
                :src="require('@/assets/images/VR.png')"
              />
            </div> -->
          <!-- <div
              data-original-title="消除外壳"
              id="gui-remove-face"
              rel="tooltip"
              title=""
              style="display: none; float: left"
            >
              <img
                draggable="false"
                class="icon icon-inside"
                :src="require('@/assets/images/face.jpg')"
              />
            </div> -->
        </div>
      </div>
    </div>

    <div class="pinBottom right hideTarget">
      <div class="rightViewContainer clearfix">
        <!-- 音乐 -->
        <div
          id="volume"
          class="ui-icon wide"
          title="音乐"
        >
          <a>
            <img
              id="openMusic"
              style="display: block"
              src="../../assets/images/music-muted.png"
              alt=""
              title="打开音乐"
              @click="switchBGM(true)"
            >
            <img
              id="closeMusic"
              style="display: none"
              src="../../assets/images/music.png"
              alt=""
              title="关闭音乐"
              @click="switchBGM(false)"
            >
          </a>
        </div>

        <!-- 全屏 -->
        <!-- <div
          id="gui-fullscreen"
          class="ui-icon wide"
          data-placement="top"
          rel="tooltip"
          title="全屏"
        >
          <a>
            <img
              title="全屏"
              :src="require('@/assets/images/full.png')"
              draggable="false"
            >
          </a>
        </div> -->

        <!-- 取消全屏 -->
        <!-- <div
          id="gui-fullscreen-exit"
          class="ui-icon wide"
          data-placement="top"
          rel="tooltip"
          title="关闭全屏"
          style="display: none"
        >
          <a>
            <img
              title="关闭全屏"
              :src="require('@/assets/images/fullAc.png')"
              draggable="false"
            >
          </a>
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      isGuide: false,
      mutationObserver: null,
    }
  },
  computed: {
    currentSceneCode() {
      return this.$route.query.m
    }
  },
  watch: {
  },
  mounted() {
    // 创建一个观察器实例并传入回调函数
    this.mutationObserver = new MutationObserver((mutationsList, observer) => {
      for (let mutation of mutationsList) {
        if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
          if (mutation.target.classList.contains('open')) {
            this.isGuide = true
          } else {
            this.isGuide = false
          }
        }
      }
    })

    // 选择需要观察变动的节点
    const targetNode = document.querySelector('.pinBottom.left')
    // 以上述配置开始观察目标节点
    this.mutationObserver.observe(targetNode, { attributes: true, childList: false, subtree: false })
  },
  beforeDistroy() {
    this.mutationObserver.disconnect()
  },
  methods: {
    switchBGM(flag) {
      if (flag) {
        window.manage.switchBgmState(true)
        document.querySelector("#openMusic").style.display = "none"
        document.querySelector("#closeMusic").style.display = "block"
      } else {
        window.manage.switchBgmState(false)
        document.querySelector("#openMusic").style.display = "block"
        document.querySelector("#closeMusic").style.display = "none"
      }
    },
  },
}
</script>

<style lang="less" scoped>
@button-size: 47px;
@margin-right: 15px;
// ----------左下方菜单--------------
.pinBottom.left {
  bottom: 30px;
  &.playing {
    bottom: 50px !important;
  }
  &.open {
    bottom: 170px !important;
  }
  &.open.playing {
    bottom: 190px !important
  }
  > div {
    > .viewContainer {
      display: flex;
      flex-direction: row;
      margin-left: 30px;
      padding: 0;
      #play,
      #pause {
        margin-right: @margin-right;
        width: @button-size;
        height: @button-size;
        padding: 0;
        img {
          height: 100%;
          width: 100%;
        }
      }
      > div {
        margin-right: @margin-right;
        width: @button-size;
        height: @button-size;
        padding: 0;
        > img {
          height: 100%;
          width: 100%;
        }
      }
      > #pullTab {
        > img.inactive {
          display: block !important;
          opacity: 0.6;
        }
        > img.active {
          display: block !important;
        }
      }
      > #gui-modes-inside {
        > img.active {
          display: none;
        }
        > img.inactive {
          display: block;
          opacity: 0.6;
        }
      }
      > #gui-modes-dollhouse {
        > img.active {
          display: none;
        }
        > img.inactive {
          display: block;
          opacity: 0.6;
        }
      }
      > #gui-modes-floorplan {
        > img.active {
          display: none;
        }
        > img.inactive {
          display: block;
          opacity: 0.6;
        }
      }
      > #gui-modes-inside.active {
        > img.active {
          display: block;
        }
        > img.inactive {
          display: none;
        }
      }
      > #gui-modes-dollhouse.active {
        > img.active {
          display: block;
        }
        > img.inactive {
          display: none;
        }
      }
      > #gui-modes-floorplan.active {
        > img.active {
          display: block;
        }
        > img.inactive {
          display: none;
        }
      }
    }
  }
}
// ----------end of 左下方菜单--------------

// ----------右下方菜单---------------
.pinBottom.right {
  &.playing {
    bottom: 50px !important;
  }
  &.open {
    bottom: 170px !important;
  }
  &.open.playing {
    bottom: 190px !important
  }
  .rightViewContainer {
    display: flex !important;
    align-items: center !important;
    margin-right: 30px;
    .ui-icon {
      width: 47px;
      height: 47px;
      margin-left: 15px;
      margin-right: initial;
      background: none;
      border: none;
      padding: 0 !important;
      > a {
        width: 100% !important;
        height: 100% !important;
        > img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
// ----------end of 右下方菜单---------------

// -------------移动端特殊样式---------------
.mobile {
  .pinBottom.left {
    left: 0;
    bottom: 0;
    &.playing {
      bottom: 20px !important;
    }
    &.open {
      bottom: 137px !important;
    }
    &.open.playing {
      bottom: 157px !important
    }
    > div {
      > .viewContainer {
        flex-direction: column;
        margin-left: 3.6vw;
        margin-bottom: 8.8vw;
        padding: 1.3vw;
        background: rgba(255,255,255,0.3);
        border-radius: 0.9vw;
        #play,
        #pause,
        #gui-modes-inside,
        #pullTab,
        #hotList,
        #gui-modes-dollhouse,
        #gui-modes-floorplan {
          margin-bottom: 5.3vw;
          margin-right: 0;
          width: 8vw;
          height: 8vw;
          img {
          }
        }
        #gui-modes-floorplan {
          margin-bottom: initial;
          img {
          }
        }
      }
    }
  }

  .pinBottom.right {
    right: 0;
    bottom: 0;
    &.playing {
      bottom: 20px !important;
    }
    &.open {
      bottom: 137px !important;
    }
    &.open.playing {
      bottom: 157px !important
    }
    .rightViewContainer {
      margin-right: 3.6vw;
      margin-bottom: 8.8vw;
      padding: 1.3vw;
      flex-direction: column;
      align-items: flex-end !important;
      background: rgba(255,255,255,0.3);
      border-radius: 0.9vw;
      .ui-icon {
        width: 8vw;
        height: 8vw;
        margin-bottom: 5.3vw;
        margin-left: initial;
        > a {
          > img {
          }
        }
      }
      .ui-icon:last-of-type {
        margin-bottom: 0;
      }
    }
  }
}
// -------------end of 移动端特殊样式---------------

</style>
