SmallSwiperNmg.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="swiper" v-if="imagelist.length>0">
  3. <el-carousel
  4. :interval="5000"
  5. class="roll_in"
  6. indicator-class="custom-indicator"
  7. @change="handleIndicatorChange">
  8. <el-carousel-item v-for="item in imagelist" :key="item">
  9. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" :title="item.title">
  10. <img :src="item.imgurl" :alt="item.title">
  11. <span class="swiper_dot1 dot1 roll_phone_none">
  12. {{ item.title }}
  13. </span>
  14. <span class="roll_dot2 roll_pc_none">
  15. {{ item.title }}
  16. </span>
  17. </NuxtLink>
  18. </el-carousel-item>
  19. </el-carousel>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { ElCarousel, ElCarouselItem } from 'element-plus'
  24. //获取焦点图数据 start---------------------------------------->
  25. const imagelist = ref("")
  26. async function getModelData1() {
  27. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  28. method: 'GET',
  29. query: {
  30. 'imgnum': 5,
  31. 'textnum': 0,
  32. 'level': 2,
  33. 'placeid': 0,
  34. 'id': ''
  35. },
  36. });
  37. if (mkdata.code == 200) {
  38. imagelist.value = mkdata.data.img;
  39. } else {
  40. console.log("错误位置错误:获取首页轮播图", mkdata.message)
  41. }
  42. }
  43. getModelData1()
  44. let currentIndex = ref(0)
  45. let handleIndicatorChange = (val) => {
  46. currentIndex.value = val
  47. }
  48. //获取焦点图数据 end---------------------------------------->
  49. </script>
  50. <style lang="less" scoped>
  51. .dot1 {
  52. display: block;
  53. word-break: keep-all;
  54. white-space: nowrap;
  55. overflow: hidden;
  56. text-overflow: ellipsis;
  57. }
  58. .swiper {
  59. width: 100%;
  60. height: 405px;
  61. position: relative;
  62. img {
  63. width: 100%;
  64. height: 405px;
  65. }
  66. .swiper_dot1 {
  67. display: block;
  68. width: 100%;
  69. line-height: 60px;
  70. height: 60px;
  71. color: #fff;
  72. font-size: 24px;
  73. text-indent: 20px;
  74. position: absolute;
  75. bottom: 0;
  76. left: 0;
  77. z-index: 10;
  78. box-sizing: border-box;
  79. padding-right: 244px;
  80. background: rgba(0, 0, 0, .5);
  81. }
  82. }
  83. .el-carousel {
  84. /deep/.el-carousel__arrow i {
  85. font-size: 30px !important;
  86. }
  87. /deep/.el-carousel__arrow--left {
  88. left: 16px;
  89. width: 35px;
  90. height: 57px;
  91. color: #616358;
  92. background: #dcdedc;
  93. position: absolute;
  94. left: 0px;
  95. border: none;
  96. border-radius: 0;
  97. }
  98. /deep/.el-carousel__arrow--right {
  99. right: 16px;
  100. width: 35px;
  101. height: 57px;
  102. color: #616358;
  103. background: #dcdedc;
  104. position: absolute;
  105. right: 0;
  106. border: none;
  107. border-radius: 0;
  108. }
  109. /deep/ .el-carousel__indicators {
  110. // 指示器
  111. left: unset;
  112. transform: unset;
  113. right: 10px;
  114. bottom: 11px;
  115. }
  116. /deep/ .el-carousel__button {
  117. // 指示器按钮
  118. width: 10px;
  119. height: 10px;
  120. border: none;
  121. border-radius: 5px;
  122. background: #ccc;
  123. opacity: 1;
  124. }
  125. /deep/ .is-active .el-carousel__button {
  126. // 指示器激活按钮
  127. background: #fff;
  128. width: 58px;
  129. opacity: 1;
  130. }
  131. /deep/ .el-carousel__container {
  132. height: 100%;
  133. }
  134. }
  135. .custom-indicator button {
  136. background-color: #fff;
  137. opacity: 1;
  138. width: 8px;
  139. height: 8px;
  140. }
  141. .custom-indicator button.is-active {
  142. background-color: #DD7D18;
  143. width: 58px;
  144. opacity: 1;
  145. }
  146. </style>
  147. <style lang="less" scoped>
  148. @media screen and (min-width:801px){/*pc*/
  149. .roll_in{height:405px;}
  150. .swiper /deep/.el-carousel__indicators{display:none;}
  151. .roll_pc_none{display:none!important;}
  152. .pc_none{display:none;}
  153. }
  154. @media screen and (max-width:800px){/*ipad_phone*/
  155. .swiper{height:100%;}
  156. .swiper /deep/ul.el-carousel__indicators{width:100%; right:0px;text-align:center;}
  157. .swiper img{width:100%;height:100%;}
  158. .roll_in{height:55vw;}
  159. .el-carousel /deep/.el-icon svg{width:.4em;display:none;}
  160. .el-carousel /deep/.el-carousel__button{width:10px;height:10px;margin:0px 4px;}
  161. .roll_dot2{
  162. width:100%;line-height:22px; height:54px;font-size:16px;
  163. padding:10px 10px 0;top:0px;
  164. display: inline-block;
  165. box-sizing: border-box;
  166. position: absolute;
  167. left: 0;
  168. font-family: Source Han Sans, Source Han Sans;
  169. font-weight: 800;
  170. color: #FFFFFF;
  171. background: linear-gradient(to bottom, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
  172. overflow:hidden;display:-webkit-box!important;-webkit-box-orient:vertical;-webkit-line-clamp:2;
  173. }
  174. /deep/.el-carousel .el-carousel__button{width:10px!important;}
  175. /deep/.el-carousel .el-carousel__indicators{bottom:0px;}
  176. /deep/.el-carousel .is-active .el-carousel__button{background:#489d97;}
  177. .roll_in /deep/.el-carousel__arrow{display:none;}
  178. .roll_phone_none{display:none!important;}
  179. .phone_none{display:none;}
  180. }
  181. </style>