BigSwiper.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <!-- 首页大的轮播图 -->
  3. <div class="swiper">
  4. <el-carousel :interval="5000" arrow="always" height="405px" indicator-class="custom-indicator"
  5. class="custom-carousel" @change="handleIndicatorChange">
  6. <el-carousel-item v-for="(item, index) in imagelist" :key="index">
  7. <NuxtLink :to="`/newsDetail/${item.id}`"
  8. target="_blank">
  9. <img :src="item.imgurl" alt="">
  10. <span>{{ item.title }}</span>
  11. </NuxtLink>
  12. </el-carousel-item>
  13. <template #indicator="{ index }">
  14. <button :class="{ 'active-indicator': currentIndex === index }">{{ index + 1 }}</button>
  15. </template>
  16. </el-carousel>
  17. </div>
  18. </template>
  19. <script setup>
  20. import { ElCarousel, ElCarouselItem } from 'element-plus'
  21. //获取焦点图数据 start---------------------------------------->
  22. let imagelist = useState("imageList", () => "")
  23. async function getModelData1() {
  24. const { data: mkdata, error: mkdataError } = requestData('/web/getWebsiteArticlett', {
  25. method: 'GET',
  26. query: {
  27. 'pageSize': 5,
  28. 'level': 2,
  29. 'placeid': 0
  30. },
  31. });
  32. if (mkdataError.value) {
  33. //console.error('模块1数据上部分请求失败!', mkdataError.value);
  34. } else {
  35. if (mkdata.value) {
  36. //console.log('模块1数据上部分请求成功!', mkdata.value.data);
  37. imagelist.value = mkdata.value.data;
  38. }
  39. }
  40. }
  41. getModelData1()
  42. //获取焦点图数据 end---------------------------------------->
  43. let currentIndex = ref(0)
  44. let handleIndicatorChange = (val) => {
  45. currentIndex.value = val
  46. }
  47. </script>
  48. <style lang="less" scoped>
  49. .swiper {
  50. width: 720px;
  51. height: 405px;
  52. position: relative;
  53. img {
  54. width: 720px;
  55. height: 405px;
  56. }
  57. span {
  58. display: inline-block;
  59. width: 720px;
  60. height: 118px;
  61. padding-top: 20px;
  62. padding-left: 23px;
  63. box-sizing: border-box;
  64. position: absolute;
  65. top: 0;
  66. left: 0;
  67. font-family: Source Han Sans, Source Han Sans;
  68. font-weight: 800;
  69. font-size: 24px;
  70. color: #FFFFFF;
  71. background: linear-gradient(to bottom, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
  72. }
  73. }
  74. .el-carousel {
  75. // 左右箭头按钮
  76. .el-carousel__arrow--right :deep(.class-name),
  77. .el-carousel__arrow--left :deep(.class-name) {
  78. width: 68px;
  79. height: 68px;
  80. }
  81. //左右箭头图片
  82. /deep/.el-icon svg {
  83. height: 1em;
  84. width: 1em;
  85. background-color: transparent;
  86. }
  87. /deep/.el-carousel__arrow {
  88. border-radius: 0;
  89. background-color: transparent;
  90. }
  91. /deep/.el-carousel__arrow i {
  92. font-size: 68px !important;
  93. }
  94. /deep/ .el-carousel__indicators {
  95. // 指示器
  96. left: unset;
  97. transform: unset;
  98. right: 41%;
  99. }
  100. /deep/ .el-carousel__button {
  101. // 指示器按钮
  102. width: 20px;
  103. height: 20px;
  104. border-radius: 50%;
  105. border: none;
  106. opacity: 1;
  107. background-color: #FFFFFF;
  108. }
  109. /deep/ .is-active .el-carousel__button {
  110. // 指示器激活按钮
  111. background: #46D333;
  112. }
  113. /deep/ .el-carousel__container {
  114. height: 100%;
  115. }
  116. /deep/.custom-indicators {
  117. position: absolute;
  118. bottom: 10px;
  119. left: 50%;
  120. transform: translateX(-50%);
  121. }
  122. // 将指示器的所有样式都不显示
  123. // /deep/.el-carousel__indicators {
  124. // display: none;
  125. // }
  126. }
  127. </style>