BigSwiper.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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" alt="">
  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. import { onMounted } from 'vue'
  19. //轮播图数据
  20. let imagelist = useState("imageList", () => "")
  21. async function getModelData1() {
  22. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  23. method: 'GET',
  24. query: {
  25. 'imgnum': 5,
  26. 'textnum': 5,
  27. 'level': 2,
  28. 'placeid': 0,
  29. 'id': 0,
  30. },
  31. });
  32. if (mkdata.code == 200) {
  33. imagelist.value = mkdata.data.img;
  34. } else {
  35. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  36. console.log("错误位置:设置大标题")
  37. console.log("后端错误反馈:", mkdata.message)
  38. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  39. }
  40. }
  41. getModelData1()
  42. // 跳转详情页
  43. const getLinkPathDetail = (item) => {
  44. if (item.islink == 1) {
  45. return `${item.linkurl}`;
  46. } else {
  47. return `/${item.pinyin}/${item.id}.html`;
  48. }
  49. }
  50. </script>
  51. <style lang="less" scoped>
  52. .swiper {
  53. width: 720px;
  54. height: 405px;
  55. position: relative;
  56. img {
  57. width: 790px;
  58. height: 405px;
  59. }
  60. .text {
  61. display: inline-block;
  62. width: 790px;
  63. height: 60px;
  64. line-height: 60px;
  65. padding-left: 23px;
  66. box-sizing: border-box;
  67. position: absolute;
  68. bottom: 0;
  69. left: 0;
  70. font-family: Microsoft YaHei, Microsoft YaHei;
  71. font-weight: 400;
  72. font-size: 18px;
  73. color: #FFFFFF;
  74. background-color: rgba(0, 0, 0, 0.5);
  75. span {
  76. display: inline-block;
  77. width: 460px;
  78. height: 60px;
  79. white-space: nowrap;
  80. overflow: hidden;
  81. text-overflow: ellipsis;
  82. }
  83. }
  84. }
  85. .el-carousel {
  86. //指示器位置
  87. ::v-deep .el-carousel__indicators {
  88. left: unset;
  89. transform: unset;
  90. right: 3%;
  91. }
  92. // 未选中的指示器样式,设置为小圆圈
  93. ::v-deep .el-carousel__indicator:not(.is-active) button {
  94. width: 8px;
  95. height: 8px;
  96. border-radius: 50%;
  97. background-color: #ccc;
  98. }
  99. // 选中的指示器样式,设置为长条状
  100. ::v-deep .el-carousel__indicator.is-active button {
  101. width: 50px;
  102. height: 8px;
  103. border-radius: 4px;
  104. background-color: #fff;
  105. }
  106. }
  107. </style>