quickZoom.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="flex">
  3. <div class="plusIcon" @click="addStep"></div>
  4. <div style="margin: 10px 0; position: relative">
  5. <el-slider v-model="step" class="slider" :min="1" :max="4" vertical :show-tooltip="false" height="183px" @input="changeStep" />
  6. <div v-show="step === 1" class="tooltip">市</div>
  7. <div v-show="step === 2" class="tooltip" style="bottom: 36px">区/县</div>
  8. <div v-show="step === 3" class="tooltip" style="bottom: 93px; left: -162px">镇/街道</div>
  9. <div v-show="step === 4" class="tooltip" style="bottom: 160px; left: -162px">村/社区</div>
  10. </div>
  11. <div class="minusIcon" @click="reduceStep"></div>
  12. </div>
  13. </template>
  14. <script lang="ts" setup>
  15. const emits = defineEmits(['changeStep']);
  16. interface Props {
  17. zoom: number;
  18. }
  19. const props = withDefaults(defineProps<Props>(), {});
  20. const step = ref(1);
  21. watch(
  22. () => props.zoom,
  23. (zoom) => {
  24. if (zoom <= 7.9) {
  25. step.value = 1;
  26. } else if (zoom > 7.9 && zoom <= 9.21) {
  27. step.value = 2;
  28. } else if (zoom > 9.21 && zoom <= 11.38) {
  29. step.value = 3;
  30. } else if (zoom > 11.38) {
  31. step.value = 4;
  32. }
  33. },
  34. {
  35. immediate: true
  36. }
  37. );
  38. // 发生变化时
  39. const changeStep = (value) => {
  40. emits('changeStep', value);
  41. };
  42. // 增加
  43. const addStep = () => {
  44. step.value = step.value + 1;
  45. changeStep(step.value);
  46. };
  47. // 减少
  48. const reduceStep = () => {
  49. step.value = step.value - 1;
  50. changeStep(step.value);
  51. };
  52. </script>
  53. <style lang="scss" scoped>
  54. .flex {
  55. display: flex;
  56. flex-direction: column;
  57. align-items: center;
  58. }
  59. .plusIcon {
  60. width: 33px;
  61. height: 33px;
  62. background-image: url('@/assets/images/map/plus.png');
  63. cursor: pointer;
  64. background-repeat: no-repeat;
  65. }
  66. .minusIcon {
  67. width: 27px;
  68. height: 27px;
  69. background-image: url('@/assets/images/map/minus.png');
  70. cursor: pointer;
  71. background-repeat: no-repeat;
  72. }
  73. .tooltip {
  74. position: absolute;
  75. left: -126px;
  76. bottom: -23px;
  77. color: #fff;
  78. padding-left: 14px;
  79. font-size: 32px;
  80. min-width: 80px;
  81. height: 63px;
  82. line-height: 63px;
  83. background-color: #3b71eb;
  84. text-align: center;
  85. &::before {
  86. content: '';
  87. width: 0;
  88. height: 0;
  89. border-bottom: 45px solid #3b71eb;
  90. border-left: 45px solid transparent;
  91. position: absolute;
  92. top: 9px;
  93. right: -22px;
  94. transform: rotate(-45deg);
  95. }
  96. }
  97. .slider {
  98. :deep(.el-slider__bar) {
  99. background: #1876be;
  100. }
  101. :deep(.el-slider__runway) {
  102. width: 9.66px;
  103. background: #1876be;
  104. border-radius: 4.5px 4.5px 4.5px 4.5px;
  105. }
  106. :deep(.el-slider__button-wrapper) {
  107. width: 48px;
  108. height: 48px;
  109. left: -20px;
  110. }
  111. :deep(.el-slider__button) {
  112. width: 48px;
  113. height: 48px;
  114. background: url('@/assets/images/map/dot.png') no-repeat;
  115. background-size: 100% 100%;
  116. border: none;
  117. }
  118. }
  119. </style>