case-swiper.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!-- 案例轮播 -->
  2. <template>
  3. <div id="case-swiper">
  4. <div class="case-swiper-imgbox" v-if="list.length > 0">
  5. <el-carousel trigger="click" arrow="never" :autoplay="true" @change="change" ref="carousel">
  6. <el-carousel-item v-for="(item, index) in list" :key="index">
  7. <img :class="[item.pc_temp_img_src? 'hoverClass':'']" :src="item.pc_temp_img_src" @click="toLink(item.id)">
  8. </el-carousel-item>
  9. </el-carousel>
  10. </div>
  11. <div class="case-swiper-index">
  12. <div class="item" :class="{'active-item': activeIndex == i,'active-item-last': activeIndex == i+1}" @click="toLink(item.id)" @mousemove="mousemove(i)" v-for="(item,i) in list" :key="item.id">
  13. <img class="icon" v-if="item.img_src" :src="item.img_src" alt="">
  14. <div class="text">{{item.case_name}}</div>
  15. </div>
  16. <!-- <div class="item" v-for="(item,index) in surplus" :key="index"></div> -->
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. props:{
  23. datas: {
  24. type: Object,
  25. default: () => ({})
  26. },
  27. },
  28. data () {
  29. return {
  30. activeIndex: 0,
  31. list: [],
  32. surplus:0
  33. };
  34. },
  35. activated() {},
  36. components: {},
  37. computed: {},
  38. mounted() {
  39. this.list = this.datas.data;
  40. this.surplus = 6 - this.list.length;
  41. },
  42. methods: {
  43. mousemove(index){
  44. if(this.activeIndex != index){
  45. this.activeIndex = index
  46. this.$refs.carousel.setActiveItem(index)
  47. // this.$nextTick(()=>{
  48. // this.activeIndex = null;
  49. // })
  50. }
  51. },
  52. change(index){
  53. this.activeIndex = index;
  54. },
  55. toLink(Id){
  56. window.location.href = this.fun.toRealURl(`case_library_detail/${Id}`);
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang='scss' rel='stylesheet/scss' scoped>
  62. #case-swiper{
  63. width: 100%;
  64. border-radius: 5px;
  65. .case-swiper-imgbox{
  66. width: 100%;
  67. z-index: 1;
  68. img{
  69. width: 100%;
  70. height: 100%;
  71. &:hover{
  72. cursor:pointer;
  73. }
  74. }
  75. }
  76. .case-swiper-index{
  77. height: 100px;
  78. // display: grid;
  79. // grid-template-columns: repeat(6, 1fr);
  80. display: flex;
  81. .item{
  82. flex: 1;
  83. background: #fff;
  84. // position: relative;
  85. border:1px solid #c9c9c9 ;
  86. border-left: none;
  87. display: flex;
  88. justify-content: center;
  89. padding: 0 8px;
  90. box-sizing: border-box;
  91. align-items: center;
  92. overflow: hidden;
  93. .icon{
  94. width: 25px;
  95. height: 25px;
  96. margin-right: 6px;
  97. }
  98. .text{
  99. font-size: 20px;
  100. color: #404040;
  101. // flex: 1;
  102. overflow: hidden;/*超出部分隐藏*/
  103. text-overflow:ellipsis;/* 超出部分显示省略号 */
  104. white-space: nowrap;/*规定段落中的文本不进行换行 */
  105. }
  106. &:nth-child(1){
  107. border-left:1px solid #c9c9c9 ;
  108. }
  109. &:hover{
  110. cursor:pointer;
  111. width: 220px;
  112. background: #fff;
  113. z-index: 9999;
  114. box-shadow: 0px 4px 14px 2px rgba(4, 0, 0, 0.15);
  115. border-radius: 5px;
  116. transform: translate(0px,-10px);
  117. transition-delay: 0s !important;
  118. border:1px solid #c9c9c9 ;
  119. }
  120. // &::before{
  121. // content: '';
  122. // position: absolute;
  123. // right: 0;
  124. // top: 30px;
  125. // bottom: 30px;
  126. // left: auto;
  127. // width: 1px;
  128. // background: #000;
  129. // }
  130. }
  131. .active-item{
  132. width: 220px;
  133. background: #fff;
  134. z-index: 9999;
  135. box-shadow: 0px 4px 14px 2px rgba(4, 0, 0, 0.15);
  136. border-radius: 5px;
  137. transform: translate(0px,-10px);
  138. transition-delay: 0s !important;
  139. border:1px solid #c9c9c9 ;
  140. z-index: 3;
  141. }
  142. .active-item-last{
  143. border-right: none;
  144. }
  145. }
  146. }
  147. </style>