BigSwiper.vue 4.0 KB

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