SwiperSnsc.vue 3.8 KB

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