SmallSwiper1.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="swiper">
  3. <!-- {{ props.message }} -->
  4. <el-carousel :interval="5000" arrow="always" height="214px" indicator-class="custom-indicator" >
  5. <el-carousel-item v-for="item in boxData1" :key="item">
  6. <NuxtLink :to="`/newsDetail/${item.id}`" :title="item.title">
  7. <img :src="item.imgurl" :alt="item.title">
  8. <span>{{ message }} {{ item.title }} </span>
  9. </NuxtLink>
  10. </el-carousel-item>
  11. </el-carousel>
  12. </div>
  13. </template>
  14. <script setup>
  15. import { ElCarousel, ElCarouselItem } from 'element-plus'
  16. import { onMounted } from 'vue';
  17. const props = defineProps({
  18. message: Number
  19. });
  20. const nuxtApp = useNuxtApp();
  21. const axios = nuxtApp.$axios;
  22. const radio1 = ref('1');
  23. let index = ref(0)
  24. //获取导航一的栏目
  25. const navigation1 = ref("");
  26. const navigateList = async () => {
  27. try {
  28. const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${1}&pid=${0}&num=${24}`);
  29. console.log('一级导航', response.data);
  30. navigation1.value = response.data;
  31. console.log('111111111111111111111111111', navigation1[0]?.value.category_id);
  32. } catch (error) {
  33. console.error(error);
  34. }
  35. }
  36. //获取模块中的数据 getWebsiteModelArticles
  37. //14
  38. const boxData1 = ref("");
  39. const getWebsiteModelArticles = async () => {
  40. try {
  41. const response = await axios.get(`/web/getWebsiteModelArticles?catid=${props.message}&level=${2}&pagesize=${4}`);
  42. console.log('boxData111111111111111111', response.data);
  43. boxData1.value = response.data;
  44. } catch (error) {
  45. console.error(error);
  46. }
  47. }
  48. onMounted(() => {
  49. navigateList();
  50. getWebsiteModelArticles();
  51. })
  52. </script>
  53. <style lang="less" scoped>
  54. a {
  55. color: #fff;
  56. }
  57. .swiper {
  58. width: 380px;
  59. height: 214px;
  60. position: relative;
  61. img {
  62. width: 380px;
  63. height: 214px;
  64. }
  65. span {
  66. display: inline-block;
  67. width: 380px;
  68. height: 30px;
  69. line-height: 30px;
  70. padding-left: 13px;
  71. position: absolute;
  72. top: 0;
  73. left: 0;
  74. font-family: PingFang SC, PingFang SC;
  75. font-weight: 500;
  76. font-size: 20px;
  77. color: #FFFFFF;
  78. background-color: rgba(0, 0, 0, 0.5);
  79. white-space: nowrap;
  80. /* 禁止换行 */
  81. overflow: hidden;
  82. /* 隐藏超出部分 */
  83. text-overflow: ellipsis;
  84. /* 超出部分显示省略号 */
  85. }
  86. }
  87. .el-carousel {
  88. /deep/.el-carousel__arrow i {
  89. font-size: 30px !important;
  90. }
  91. /deep/.el-carousel__arrow--left {
  92. left: 16px;
  93. width: 35px;
  94. height: 57px;
  95. color: #616358;
  96. background: #dcdedc;
  97. position: absolute;
  98. left: 0px;
  99. border: none;
  100. border-radius: 0;
  101. }
  102. /deep/.el-carousel__arrow--right {
  103. right: 16px;
  104. width: 35px;
  105. height: 57px;
  106. color: #616358;
  107. background: #dcdedc;
  108. position: absolute;
  109. right: 0;
  110. border: none;
  111. border-radius: 0;
  112. }
  113. /deep/ .el-carousel__indicators {
  114. // 指示器
  115. left: unset;
  116. transform: unset;
  117. right: 41%;
  118. }
  119. /deep/ .el-carousel__button {
  120. // 指示器按钮
  121. width: 10px;
  122. height: 10px;
  123. border: none;
  124. border-radius: 50%;
  125. border: 1px solid #fff;
  126. background-color: transparent;
  127. }
  128. /deep/ .is-active .el-carousel__button {
  129. // 指示器激活按钮
  130. background: #fff;
  131. }
  132. /deep/ .el-carousel__container {
  133. height: 100%;
  134. }
  135. }
  136. .custom-indicator button {
  137. background-color: #fff;
  138. border: 1px solid #ccc;
  139. opacity: 0.7;
  140. }
  141. .custom-indicator button.is-active {
  142. background-color: #333;
  143. border-color: #333;
  144. opacity: 1;
  145. }
  146. </style>