BigSwiper.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <!-- 首页大的轮播图 -->
  3. <div class="swiper" v-if="imagelist">
  4. <el-carousel height="400px" v-if="imagelist">
  5. <el-carousel-item v-for="(item, index) in imagelist" :key="index">
  6. <NuxtLink :href="getLinkPathDetail(item)">
  7. <img :src="item.imgurl">
  8. <div class="text">
  9. <span>{{ item.title }}</span>
  10. </div>
  11. </NuxtLink>
  12. </el-carousel-item>
  13. </el-carousel>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ElCarousel, ElCarouselItem } from 'element-plus'
  18. //获取焦点图数据 start---------------------------------------->
  19. const imagelist = ref("")
  20. async function getModelData1() {
  21. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  22. method: 'GET',
  23. query: {
  24. 'imgnum': 5,
  25. 'textnum': 0,
  26. 'level': 2,
  27. 'placeid': 0,
  28. 'id':''
  29. },
  30. });
  31. if(mkdata.code == 200){
  32. imagelist.value = mkdata.data.img;
  33. }else{
  34. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  35. console.log("错误位置:获取首页轮播图")
  36. console.log("后端错误反馈:",mkdata.message)
  37. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  38. }
  39. }
  40. getModelData1()
  41. let currentIndex = ref(0)
  42. let handleIndicatorChange = (val) => {
  43. currentIndex.value = val
  44. }
  45. </script>
  46. <style lang="less" scoped>
  47. .swiper {
  48. width: 720px;
  49. height: 405px;
  50. position: relative;
  51. img {
  52. width: 790px;
  53. height: 405px;
  54. }
  55. .text {
  56. display: inline-block;
  57. width: 790px;
  58. height: 60px;
  59. line-height: 60px;
  60. padding-left: 23px;
  61. box-sizing: border-box;
  62. position: absolute;
  63. bottom: 0;
  64. left: 0;
  65. font-family: Microsoft YaHei, Microsoft YaHei;
  66. font-weight: 400;
  67. font-size: 18px;
  68. color: #FFFFFF;
  69. // background-color: #eee;
  70. span {
  71. display: inline-block;
  72. width: 460px;
  73. height: 60px;
  74. white-space: nowrap;
  75. overflow: hidden;
  76. text-overflow: ellipsis;
  77. font-size: 24px;
  78. position: absolute;
  79. z-index: 50;
  80. }
  81. }
  82. .text:after {
  83. background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
  84. bottom: 0;
  85. content: "";
  86. display: block;
  87. height: 68px;
  88. left: 0;
  89. position: absolute;
  90. width: 100%;
  91. z-index: 44;
  92. }
  93. }
  94. .el-carousel {
  95. // 指示器位置
  96. ::v-deep .el-carousel__indicators {
  97. left: unset;
  98. transform: unset;
  99. right: 1%;
  100. }
  101. // 未选中的指示器样式,设置为小圆圈
  102. ::v-deep .el-carousel__indicator:not(.is-active) button {
  103. width: 10px;
  104. height: 10px;
  105. border-radius: 50%;
  106. background-color: #fff;
  107. }
  108. // 选中的指示器样式,设置为长条状
  109. ::v-deep .el-carousel__indicator.is-active button {
  110. width: 10px;
  111. height: 10px;
  112. border-radius: 50%;
  113. background-color: #dd7d18;
  114. }
  115. }
  116. </style>