BigSwiper.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="swiper" v-if="imagelist">
  3. <el-carousel :interval="5000" arrow="always" height="405px" indicator-class="custom-indicator"
  4. class="custom-carousel" @change="handleIndicatorChange">
  5. <el-carousel-item v-for="(item, index) in imagelist" :key="index">
  6. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`"
  7. :title="item.title">
  8. <img :src="item.imgurl" :alt="item.title">
  9. <span>{{ item.title }}</span>
  10. </NuxtLink>
  11. </el-carousel-item>
  12. <template #indicator="{ index }">
  13. <button :class="{ 'active-indicator': currentIndex === index }">{{ index + 1 }}</button>
  14. </template>
  15. </el-carousel>
  16. </div>
  17. </template>
  18. <script setup>
  19. import { ElCarousel, ElCarouselItem } from 'element-plus'
  20. //获取焦点图数据 start---------------------------------------->
  21. const imagelist = ref("")
  22. async function getModelData1() {
  23. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  24. method: 'GET',
  25. query: {
  26. 'imgnum': 5,
  27. 'textnum': 0,
  28. 'level': 2,
  29. 'placeid': 0,
  30. 'id':''
  31. },
  32. });
  33. if(mkdata.code == 200){
  34. imagelist.value = mkdata.data.img;
  35. }else{
  36. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  37. console.log("错误位置:获取首页轮播图")
  38. console.log("后端错误反馈:",mkdata.message)
  39. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  40. }
  41. }
  42. getModelData1()
  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>