floorSelect.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="floorSelect" v-if="urlNum">
  3. <div class="floor_Box" @click="show = !show">
  4. <div class="floor_icon"></div>
  5. </div>
  6. <div class="floor_num">{{ numTxt }}</div>
  7. <!-- 点击出来的选择框 -->
  8. <div class="floor_show" v-show="show">
  9. <div
  10. @click="skipUrl(item.path)"
  11. class="floor_row"
  12. :class="{ floor_active: item.path == urlNum }"
  13. v-for="item in data"
  14. :key="item.id"
  15. >
  16. {{ item.name }}
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. name: "floorSelect",
  24. components: {},
  25. data() {
  26. return {
  27. data: [
  28. { id: 4, name: "4层", path: "1197" },
  29. { id: 3, name: "3层", path: "1196" },
  30. { id: 2, name: "2层", path: "1195" },
  31. { id: 1, name: "1层", path: "1194" },
  32. ],
  33. show: false,
  34. urlNum: "",
  35. numTxt: "",
  36. };
  37. },
  38. computed: {},
  39. watch: {},
  40. methods: {
  41. skipUrl(url) {
  42. window.location.href =
  43. window.location.origin + window.location.pathname + `#/?m=${url}`;
  44. setTimeout(() => {
  45. location.reload(true);
  46. }, 200);
  47. },
  48. },
  49. created() {
  50. const num = window.number;
  51. const arr = ["1194", "1195", "1196", "1197"];
  52. if (arr.includes(num)) {
  53. // 隐藏原本的楼层选择
  54. setTimeout(() => {
  55. const dom = document.querySelector(".gui-floor");
  56. if (dom) {
  57. dom.style.display = "none";
  58. }
  59. }, 200);
  60. this.urlNum = num;
  61. this.numTxt =
  62. num == 1194 ? "1" : num == 1195 ? "2" : num == 1196 ? "3" : "4";
  63. }
  64. },
  65. mounted() {},
  66. beforeCreate() {}, //生命周期 - 创建之前
  67. beforeMount() {}, //生命周期 - 挂载之前
  68. beforeUpdate() {}, //生命周期 - 更新之前
  69. updated() {}, //生命周期 - 更新之后
  70. beforeDestroy() {}, //生命周期 - 销毁之前
  71. destroyed() {}, //生命周期 - 销毁完成
  72. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  73. };
  74. </script>
  75. <style lang='less' scoped>
  76. .floorSelect {
  77. width: 48px;
  78. margin-right: 10px;
  79. height: 48px;
  80. color: #fff;
  81. font-size: 11px;
  82. border-radius: 10px;
  83. background: rgba(0, 0, 0, 0.2);
  84. position: relative;
  85. .floor_Box {
  86. cursor: pointer;
  87. display: flex;
  88. align-items: center;
  89. justify-content: center;
  90. width: 100%;
  91. height: 100%;
  92. .floor_icon {
  93. width: 32px;
  94. height: 29px;
  95. background: url("../../../assets/img/floor-icon.png") left top no-repeat;
  96. background-size: 98%;
  97. }
  98. }
  99. .floor_num {
  100. pointer-events: none;
  101. position: absolute;
  102. top: 2px;
  103. left: 50%;
  104. transform: translateX(-50%);
  105. }
  106. .floor_show {
  107. width: 86px;
  108. position: absolute;
  109. bottom: 50px;
  110. transition: all 0.3s;
  111. z-index: 100;
  112. left: -19px;
  113. .floor_row {
  114. border: 1px solid transparent;
  115. width: 86px;
  116. height: 30px;
  117. margin-bottom: 1px;
  118. font-size: 14px;
  119. cursor: pointer;
  120. overflow: hidden;
  121. white-space: nowrap;
  122. background-color: rgba(0, 0, 0, 0.5);
  123. text-align: center;
  124. line-height: 30px;
  125. color: #fff;
  126. &:hover {
  127. background-color: #1d95d0;
  128. }
  129. }
  130. .floor_active {
  131. background-color: #1d95d0;
  132. pointer-events: none;
  133. }
  134. }
  135. }
  136. </style>