Fold.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="fold transition">
  3. <div
  4. class="openFold"
  5. :class="[mapMode.value === 'home' ? 'isno' : 'isyes']"
  6. @click="clickOpen"
  7. >
  8. <span>
  9. {{ mapMode.value === "home" ? "收起面板" : "展开面板" }}
  10. </span>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import { mapGetters } from "vuex";
  16. export default {
  17. props: { positionFold: Object },
  18. data() {
  19. return {
  20. position: {
  21. left: 490,
  22. right: 490,
  23. isopen: true,
  24. issprh: false,
  25. },
  26. };
  27. },
  28. computed: {
  29. ...mapGetters(["mapMode"]),
  30. },
  31. watch: {
  32. mapMode: {
  33. handler(val, oldVal) {
  34. console.log("mapMode", val.value, oldVal.value);
  35. this.updateStyle();
  36. },
  37. deep: true,
  38. },
  39. },
  40. methods: {
  41. updateStyle() {
  42. this.position.isopen = !this.position.isopen;
  43. if (this.mapMode.value === "home") {
  44. let main = document.querySelector(".fold");
  45. main.style.transform = `translateX(0px)`;
  46. main.style.transition = "transform 1s ease";
  47. } else {
  48. let main = document.querySelector(".fold");
  49. main.style.transform = `translateX(470px)`;
  50. main.style.transition = "transform 1s ease";
  51. }
  52. var param = {
  53. isopen: this.position.isopen,
  54. issprh: this.position.issprh,
  55. };
  56. this.$emit("position", param);
  57. },
  58. clickOpen() {
  59. if (this.mapMode) {
  60. if (this.mapMode.value === "home") {
  61. this.$store.dispatch("globalConfig/setMapMode", { value: "3d" });
  62. } else if (this.mapMode.value === "3d") {
  63. this.$store.dispatch("globalConfig/setMapMode", { value: "home" });
  64. }
  65. }
  66. },
  67. },
  68. mounted() {
  69. this.position = this.positionFold;
  70. },
  71. updated() {
  72. this.position = this.positionFold;
  73. },
  74. };
  75. </script>
  76. <style lang="less" scoped>
  77. .fold {
  78. position: absolute;
  79. z-index: 99;
  80. width: 140px;
  81. // height: 200px;
  82. top: 106px;
  83. right: 450px;
  84. // background: #000;
  85. .openFold {
  86. pointer-events: auto;
  87. cursor: pointer;
  88. width: 140px;
  89. height: 45px;
  90. background-repeat: no-repeat;
  91. background-size: cover;
  92. text-align: center;
  93. line-height: 45px;
  94. span {
  95. font-size: 14px;
  96. font-weight: 700;
  97. background-image: linear-gradient(180deg, #ffffff, #419aff);
  98. -webkit-background-clip: text;
  99. background-clip: text;
  100. color: transparent;
  101. }
  102. }
  103. }
  104. .isno {
  105. background-image: url(~@/assets/imgs/fold/button_收起面板_sel.png);
  106. }
  107. .isyes {
  108. background-image: url(~@/assets/imgs/fold/button_收起面板_pre.png);
  109. }
  110. </style>