menu.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <ul class="menu" :class="currentid">
  3. <li :class="{active:currentid == item.id}" @click="onclick(item)" v-for="(item, i) in list" :key="i">
  4. <img :src="
  5. require(`@/assets/images/icon/${item.id+(currentid==item.id?'_active':'')}.png`)
  6. " alt="" />
  7. <p>{{item.name}}</p>
  8. </li>
  9. </ul>
  10. </template>
  11. <script>
  12. export default {
  13. props: ["canMove", "canControls"],
  14. data() {
  15. return {
  16. currentid: "info",
  17. list: [
  18. {
  19. id: "history",
  20. name: "考古",
  21. },
  22. {
  23. id: "info",
  24. name: "简介",
  25. },
  26. {
  27. id: "pic",
  28. name: "纹饰",
  29. },
  30. {
  31. id: "collection",
  32. name: "关联文物",
  33. }
  34. ],
  35. };
  36. },
  37. methods: {
  38. onclick(item) {
  39. if (this.currentid == item.id) {
  40. return
  41. }
  42. if (item.id == 'history' || item.id == 'collection') {
  43. this.$emit("notFinish");
  44. return
  45. }
  46. this.$emit("clickItem", item);
  47. this.currentid = item.id;
  48. },
  49. },
  50. mounted() {
  51. this.$bus.$on("resetcurrent", () => {
  52. this.currentid = "";
  53. });
  54. },
  55. };
  56. </script>
  57. <style lang="less" scoped>
  58. .menu {
  59. position: fixed;
  60. left: 42px;
  61. bottom: 20px;
  62. z-index: 9999;
  63. display: flex;
  64. justify-content: center;
  65. transition: 0.3s ease all;
  66. >li {
  67. list-style: none;
  68. position: relative;
  69. width: 80px;
  70. display: inline-block;
  71. margin: 0 10px;
  72. text-align: center;
  73. cursor: pointer;
  74. color: #fff;
  75. opacity: 0.7;
  76. >p {
  77. font-size: 14px;
  78. }
  79. &.active,
  80. &:hover {
  81. opacity: 1;
  82. }
  83. }
  84. }
  85. @media screen and (max-width: 1000px) {
  86. .menu {
  87. left: 6%;
  88. pointer-events: auto;
  89. transition: 0s ease all;
  90. >li {
  91. width: 6vw;
  92. margin: 0 5px;
  93. pointer-events: auto;
  94. >img {
  95. width: 100%;
  96. }
  97. }
  98. }
  99. .ming,
  100. .sheng,
  101. .yue,
  102. .zhi {
  103. top: 50%;
  104. flex-direction: column;
  105. margin: 5px 0;
  106. left: 6%;
  107. >li {
  108. margin: 5px 0;
  109. }
  110. }
  111. }
  112. @keyframes fadeIn {
  113. 0% {
  114. opacity: 0;
  115. }
  116. 100% {
  117. opacity: 1;
  118. pointer-events: auto;
  119. }
  120. }
  121. @keyframes fadeInOut {
  122. 0% {
  123. opacity: 0;
  124. }
  125. 50% {
  126. opacity: 1;
  127. }
  128. 100% {
  129. opacity: 0;
  130. pointer-events: none;
  131. }
  132. }
  133. </style>