BigSwiper.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="swiper" v-if="imagelist">
  3. <el-carousel :interval="2222" :touchable="true" arrow="always"
  4. indicator-class="custom-indicator"
  5. class="custom-carousel roll_in" @change="handleIndicatorChange">
  6. <el-carousel-item v-for="(item, index) in imagelist" :key="index">
  7. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`"
  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. 'imgnum': 5,
  28. 'textnum': 0,
  29. 'level': 2,
  30. 'placeid': 0,
  31. 'id':''
  32. },
  33. });
  34. if(mkdata.code == 200){
  35. imagelist.value = mkdata.data.img;
  36. }else{
  37. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  38. // console.log("错误位置:获取首页轮播图")
  39. // console.log("后端错误反馈:",mkdata.message)
  40. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  41. }
  42. }
  43. getModelData1()
  44. let currentIndex = ref(0)
  45. let handleIndicatorChange = (val) => {
  46. currentIndex.value = val
  47. }
  48. </script>
  49. <style lang="less" scoped>
  50. .swiper {
  51. width: 720px;
  52. height: 405px;
  53. position: relative;
  54. img {
  55. width: 720px;
  56. height: 405px;
  57. }
  58. span {
  59. display: inline-block;
  60. width: 720px;
  61. height: 118px;
  62. padding-top: 20px;
  63. padding-left: 23px;
  64. box-sizing: border-box;
  65. position: absolute;
  66. top: 0;
  67. left: 0;
  68. font-family: Source Han Sans, Source Han Sans;
  69. font-weight: 800;
  70. font-size: 24px;
  71. color: #FFFFFF;
  72. background: linear-gradient(to bottom, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
  73. }
  74. }
  75. .roll_in{height:405px;}
  76. .el-carousel {
  77. // 左右箭头按钮
  78. .el-carousel__arrow--right :deep(.class-name),
  79. .el-carousel__arrow--left :deep(.class-name) {
  80. width: 68px;
  81. height: 68px;
  82. }
  83. //左右箭头图片
  84. /deep/.el-icon svg {
  85. height: 1em;
  86. width: 1em;
  87. background-color: transparent;
  88. }
  89. /deep/.el-carousel__arrow {
  90. border-radius: 0;
  91. background-color: transparent;
  92. }
  93. /deep/.el-carousel__arrow i {
  94. font-size: 68px !important;
  95. }
  96. /deep/ .el-carousel__indicators {
  97. // 指示器
  98. left: unset;
  99. transform: unset;
  100. right: 41%;
  101. }
  102. /deep/ .el-carousel__button {
  103. // 指示器按钮
  104. width: 20px;
  105. height: 20px;
  106. border-radius: 50%;
  107. border: none;
  108. opacity: 1;
  109. background-color: #FFFFFF;
  110. }
  111. /deep/ .is-active .el-carousel__button {
  112. // 指示器激活按钮
  113. background: #46D333;
  114. }
  115. /deep/ .el-carousel__container {
  116. height: 100%;
  117. }
  118. /deep/.custom-indicators {
  119. position: absolute;
  120. bottom: 10px;
  121. left: 50%;
  122. transform: translateX(-50%);
  123. }
  124. // 将指示器的所有样式都不显示
  125. // /deep/.el-carousel__indicators {
  126. // display: none;
  127. // }
  128. }
  129. </style>
  130. <style lang="less" scoped>
  131. @media screen and (max-width:800px){/*ipad_phone*/
  132. .swiper span{width:100%;line-height:22px;max-height:54px;font-size:16px;
  133. padding:10px 10px 0;top:0px;}
  134. .swiper /deep/ul.el-carousel__indicators{width:100%; right:0px;text-align:center;}
  135. .swiper img{width:100%;height:100%;}
  136. .roll_in{height:55vw;}
  137. .el-carousel /deep/.el-icon svg{width:.4em;display:none;}
  138. .el-carousel /deep/.el-carousel__button{width:8px;height:8px;margin:0px 2px;}
  139. }
  140. </style>