SwiperSnsc.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="swiper">
  3. <el-carousel :interval="5000" height="405px" indicator-class="custom-indicator" @change="handleIndicatorChange">
  4. <el-carousel-item v-for="item in imagelist" :key="item">
  5. <NuxtLink
  6. :to="`/${item.pinyin}/${item.id}.html`"
  7. :title="item.title">
  8. <img :src="item.imgurl" :alt="item.title">
  9. <span class="swiper_dot1 dot1">{{ item.title }}</span>
  10. </NuxtLink>
  11. </el-carousel-item>
  12. </el-carousel>
  13. </div>
  14. </template>
  15. <script setup>
  16. import { ElCarousel, ElCarouselItem } from 'element-plus'
  17. //获取焦点图数据 start---------------------------------------->
  18. const imagelist = ref("")
  19. async function getModelData1() {
  20. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  21. method: 'GET',
  22. query: {
  23. 'imgnum': 5,
  24. 'textnum': 0,
  25. 'level': 2,
  26. 'placeid': 0,
  27. 'id':''
  28. },
  29. });
  30. if(mkdata.code == 200){
  31. imagelist.value = mkdata.data.img;
  32. }else{
  33. console.log("错误位置错误:获取首页轮播图",mkdata.message)
  34. }
  35. }
  36. getModelData1()
  37. let currentIndex = ref(0)
  38. let handleIndicatorChange = (val) => {
  39. currentIndex.value = val
  40. }
  41. //获取焦点图数据 end---------------------------------------->
  42. </script>
  43. <style lang="less" scoped>
  44. .dot1 {
  45. display: block;
  46. word-break: keep-all;
  47. white-space: nowrap;
  48. overflow: hidden;
  49. text-overflow: ellipsis;
  50. }
  51. .swiper {
  52. width: 100%;
  53. height: 405px;
  54. position: relative;
  55. img {
  56. width: 100%;
  57. height: 405px;
  58. }
  59. .swiper_dot1 {
  60. display: block;
  61. width: 100%;
  62. line-height: 60px;
  63. height: 60px;
  64. color: #fff;
  65. font-size: 24px;
  66. text-indent: 20px;
  67. position: absolute;
  68. bottom: 0;
  69. left: 0;
  70. z-index: 10;
  71. box-sizing: border-box;
  72. padding-right: 244px;
  73. background:linear-gradient(0deg,rgba(0,0,0,0.5) 33%,rgba(0,0,0,0) 100%);
  74. }
  75. }
  76. .el-carousel {
  77. /deep/.el-carousel__arrow i {
  78. font-size: 30px !important;
  79. }
  80. /deep/.el-carousel__arrow--left {
  81. left: 16px;
  82. width: 35px;
  83. height: 57px;
  84. color: #616358;
  85. background: #dcdedc;
  86. position: absolute;
  87. left: 0px;
  88. border: none;
  89. border-radius: 0;
  90. }
  91. /deep/.el-carousel__arrow--right {
  92. right: 16px;
  93. width: 35px;
  94. height: 57px;
  95. color: #616358;
  96. background: #dcdedc;
  97. position: absolute;
  98. right: 0;
  99. border: none;
  100. border-radius: 0;
  101. }
  102. /deep/ .el-carousel__indicators {
  103. // 指示器
  104. left: unset;
  105. transform: unset;
  106. right: 10px;
  107. bottom: 11px;
  108. }
  109. /deep/ .el-carousel__button {
  110. // 指示器按钮
  111. width: 10px;
  112. height: 10px;
  113. border: none;
  114. border-radius: 5px;
  115. background: #fff;
  116. opacity: 1;
  117. }
  118. /deep/ .is-active .el-carousel__button {
  119. // 指示器激活按钮
  120. background: #255590;
  121. width: 25px;
  122. opacity: 1;
  123. }
  124. /deep/ .el-carousel__container {
  125. height: 100%;
  126. }
  127. }
  128. .custom-indicator button {
  129. background-color: #fff;
  130. opacity: 1;
  131. width: 8px;
  132. height: 8px;
  133. }
  134. .custom-indicator button.is-active {
  135. background-color: #DD7D18;
  136. width: 58px;
  137. opacity: 1;
  138. }
  139. </style>