floorSelect.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 = window.location.href.replace(this.urlNum, url);
  43. setTimeout(() => {
  44. location.reload(true);
  45. }, 200);
  46. },
  47. },
  48. created() {
  49. const num = window.number;
  50. const arr = ["1194", "1195", "1196", "1197"];
  51. if (arr.includes(num)) {
  52. // 隐藏原本的楼层选择
  53. setTimeout(() => {
  54. const dom = document.querySelector(".gui-floor");
  55. if (dom) {
  56. dom.style.display = "none";
  57. }
  58. }, 200);
  59. this.urlNum = num;
  60. this.numTxt =
  61. num == 1194 ? "1" : num == 1195 ? "2" : num == 1196 ? "3" : "4";
  62. }
  63. },
  64. mounted() {},
  65. beforeCreate() {}, //生命周期 - 创建之前
  66. beforeMount() {}, //生命周期 - 挂载之前
  67. beforeUpdate() {}, //生命周期 - 更新之前
  68. updated() {}, //生命周期 - 更新之后
  69. beforeDestroy() {}, //生命周期 - 销毁之前
  70. destroyed() {}, //生命周期 - 销毁完成
  71. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  72. };
  73. </script>
  74. <style lang='less' scoped>
  75. .floorSelect {
  76. width: 48px;
  77. margin-right: 10px;
  78. height: 48px;
  79. color: #fff;
  80. font-size: 11px;
  81. border-radius: 10px;
  82. background: rgba(0, 0, 0, 0.2);
  83. position: relative;
  84. .floor_Box {
  85. cursor: pointer;
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 100%;
  90. height: 100%;
  91. .floor_icon {
  92. width: 32px;
  93. height: 29px;
  94. background: url("../../../assets/img/floor-icon.png") left top no-repeat;
  95. background-size: 98%;
  96. }
  97. }
  98. .floor_num {
  99. pointer-events: none;
  100. position: absolute;
  101. top: 2px;
  102. left: 50%;
  103. transform: translateX(-50%);
  104. }
  105. .floor_show {
  106. width: 86px;
  107. position: absolute;
  108. bottom: 50px;
  109. transition: all 0.3s;
  110. z-index: 100;
  111. left: -19px;
  112. .floor_row {
  113. border: 1px solid transparent;
  114. width: 86px;
  115. height: 30px;
  116. margin-bottom: 1px;
  117. font-size: 14px;
  118. cursor: pointer;
  119. overflow: hidden;
  120. white-space: nowrap;
  121. background-color: rgba(0, 0, 0, 0.5);
  122. text-align: center;
  123. line-height: 30px;
  124. color: #fff;
  125. &:hover {
  126. background-color: #1d95d0;
  127. }
  128. }
  129. .floor_active {
  130. background-color: #1d95d0;
  131. pointer-events: none;
  132. }
  133. }
  134. }
  135. </style>