floorList.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. *@author:Guoxiaohuan
  3. *@date:2020.06.02
  4. *@info:楼层列表
  5. */
  6. <template>
  7. <div class='floor-box'>
  8. <div class='floor-list'>
  9. <i class='el-icon-caret-top icon-top' v-if='showT' @click='removeTop'></i>
  10. <i class='el-icon-caret-top icon-top' v-else style='color:#ccc'></i>
  11. <div class='floor-out'>
  12. <div class='floor-center'>
  13. <div
  14. class='floor-item'
  15. :class='item==floorId?"isActive":""'
  16. @click='tabFloor(item)'
  17. v-for='(item,index) in floorsArr'
  18. :key='index'
  19. >{{item}}</div>
  20. </div>
  21. </div>
  22. <i class='el-icon-caret-bottom icon-bottom' v-if='showB' @click='removeBottom'></i>
  23. <i class='el-icon-caret-bottom icon-bottom' v-else style='color:#ccc'></i>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { animate } from '@/utils/animate.js'
  29. import { mapGetters } from 'vuex'
  30. export default {
  31. data() {
  32. return {
  33. floorId: '',
  34. showT: true,
  35. showB: true,
  36. num: 0
  37. }
  38. },
  39. mounted() {
  40. this.tabFloor('1F')
  41. },
  42. computed: {
  43. ...mapGetters(['floorsArr'])
  44. },
  45. methods: {
  46. tabFloor(item) {
  47. this.showT = true
  48. this.showB = true
  49. this.$cookie.set('floorNow', item, 3)
  50. this.floorId = this.$cookie.get('floorNow') || item
  51. },
  52. removeTop() {
  53. var inner = document.querySelectorAll('.floor-item')
  54. var innerbox = document.querySelector('.floor-center')
  55. if (this.num < 0) {
  56. this.num++
  57. } else {
  58. this.num = 0
  59. this.showT = false
  60. }
  61. if (this.num <= 0) {
  62. animate(innerbox, { marginTop: 28 * this.num }, 500, function() {})
  63. }
  64. },
  65. removeBottom() {
  66. var inner = document.querySelectorAll('.floor-item')
  67. var innerbox = document.querySelector('.floor-center')
  68. if (this.num > -(inner.length - 4)) {
  69. this.num--
  70. } else {
  71. this.num = -(inner.length - 4)
  72. this.showB = false
  73. }
  74. if (this.num > -(inner.length - 4)) {
  75. animate(innerbox, { marginTop: 28 * this.num }, 500, function() {})
  76. }
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="less" scoped>
  82. .floor-box {
  83. position: fixed;
  84. right: 32px;
  85. top: 196px;
  86. .floor-list {
  87. width: 44px;
  88. height: 212px;
  89. background: rgba(255, 255, 255, 1);
  90. box-shadow: 0px 2px 15px 0px rgba(31, 36, 41, 0.08);
  91. border-radius: 2px;
  92. position: relative;
  93. padding: 28px 4px;
  94. text-align: center;
  95. .floor-out {
  96. height: 160px;
  97. overflow: hidden;
  98. overflow-y: auto;
  99. position: relative;
  100. &::-webkit-scrollbar {
  101. display: none;
  102. }
  103. .floor-center {
  104. .floor-item {
  105. width: 36px;
  106. height: 28px;
  107. margin: 3px 0;
  108. cursor: pointer;
  109. }
  110. }
  111. }
  112. .icon-top {
  113. text-align: center;
  114. font-size: 18px;
  115. margin: 0 auto;
  116. display: flex;
  117. justify-content: center;
  118. position: absolute;
  119. top: 0;
  120. right: 0;
  121. width: 100%;
  122. cursor: pointer;
  123. margin-top: 5px;
  124. }
  125. .icon-bottom {
  126. text-align: center;
  127. font-size: 18px;
  128. margin: 0 auto;
  129. display: flex;
  130. justify-content: center;
  131. position: absolute;
  132. bottom: 0;
  133. right: 0;
  134. width: 100%;
  135. margin-bottom: 5px;
  136. cursor: pointer;
  137. line-height: 28px;
  138. }
  139. .isActive {
  140. border-radius: 4px;
  141. color: #025baa;
  142. background: #e1f2ff;
  143. line-height: 28px;
  144. }
  145. }
  146. }
  147. </style>