moduleBottom.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div v-if="visible" class="module-content">
  3. <div class="left-solt" @click="scrollLeft"></div>
  4. <div class="center-solt">
  5. <div v-for="(item, index) in visibleTabs" :key="index" class="tab-item" :class="{ active: activeIndex === index }" @click="selectTab(index)">
  6. <span class="tab-name">{{ item }}</span>
  7. </div>
  8. </div>
  9. <div class="right-solt" @click="scrollRight"></div>
  10. </div>
  11. </template>
  12. <script lang="ts" setup>
  13. import { ref, computed } from 'vue';
  14. defineProps<{ title: string; visible: boolean }>();
  15. const emit = defineEmits(['close', 'click']);
  16. const tabList = ['Tab标题名称 1', 'Tab标题名称 2', 'Tab标题名称 3', 'Tab标题名称 4', 'Tab标题名称 5', 'Tab标题名称 6'];
  17. const activeIndex = ref(0);
  18. const currentStart = ref(0);
  19. const visibleCount = 4;
  20. const visibleTabs = computed(() => {
  21. return tabList.slice(currentStart.value, currentStart.value + visibleCount);
  22. });
  23. function closeModel() {
  24. emit('close');
  25. }
  26. function clickHandler() {
  27. emit('click');
  28. }
  29. function selectTab(index: number) {
  30. activeIndex.value = index;
  31. }
  32. function scrollLeft() {
  33. if (currentStart.value > 0) {
  34. currentStart.value--;
  35. }
  36. }
  37. function scrollRight() {
  38. if (currentStart.value + visibleCount < tabList.length) {
  39. currentStart.value++;
  40. }
  41. }
  42. </script>
  43. <style lang="less" scoped>
  44. @import '/@/design/theme.less';
  45. .module-content {
  46. color: #fff;
  47. box-sizing: border-box;
  48. position: absolute;
  49. width: 100%;
  50. height: 100%;
  51. display: flex;
  52. align-items: center;
  53. }
  54. .left-solt,
  55. .right-solt {
  56. width: 15%;
  57. height: 60%;
  58. cursor: pointer;
  59. position: relative;
  60. z-index: 1;
  61. }
  62. .left-solt {
  63. background: url('@/assets/images/vent/homeNew/Bottom-left.png') no-repeat;
  64. background-size: 100% 100%;
  65. }
  66. .right-solt {
  67. background: url('@/assets/images/vent/homeNew/Bottom_right.png') no-repeat;
  68. background-size: 100% 100%;
  69. }
  70. .center-solt {
  71. display: flex;
  72. width: 70%;
  73. height: 60%;
  74. justify-content: space-between;
  75. }
  76. .tab-item {
  77. flex: 1;
  78. text-align: center;
  79. line-height: 60px;
  80. cursor: pointer;
  81. background: url('@/assets/images/vent/homeNew/tab-defult.png') no-repeat;
  82. background-size: 100% 100%;
  83. transition: all 0.3s;
  84. margin: 0 5px;
  85. color: #999;
  86. }
  87. .tab-name {
  88. font-size: 14px;
  89. display: inline-block;
  90. float: right;
  91. margin-right: 13px;
  92. }
  93. .tab-item.active {
  94. background: url('@/assets/images/vent/homeNew/tab-active.png') no-repeat;
  95. background-size: 100% 100%;
  96. font-weight: bold;
  97. color: #fff;
  98. transform: translateY(-5px);
  99. }
  100. .module-slot {
  101. height: calc(100% - 33px);
  102. width: calc(100% - 15px);
  103. margin-left: 10px;
  104. }
  105. .v-enter-active,
  106. .v-leave-active {
  107. transition: all 0.3s ease;
  108. }
  109. .v-enter-from,
  110. .v-leave-to {
  111. opacity: 0;
  112. transform: translateY(-33px);
  113. }
  114. </style>