swiper.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="bannar" v-if="(list && list.length > 0) || ((basicSet.slide && basicSet.slide.length > 0) || (basicSet.set && basicSet.set.banner_bg_src))"
  3. :style="{backgroundImage: from === 'supplier' || slide_style == 2 ? '' :`url(${basicSet.set && basicSet.set.banner_bg_src ? basicSet.set.banner_bg_src : ''})`}">
  4. <!--供应商显示-->
  5. <div class="swiper m-auto" :class="{'fill-swiper': slide_style == 2}" v-if="from === 'supplier' && list.length > 0">
  6. <el-carousel trigger="click" arrow="never" :autoplay="true">
  7. <el-carousel-item v-for="(item, index) in list" v-if="item && item.pc_thumb" :key="index">
  8. <img :class="[item.pc_link? 'hoverClass':'']" :src="item.pc_thumb" @click="toLink(item)">
  9. </el-carousel-item>
  10. </el-carousel>
  11. </div>
  12. <!--分类二广告显示-->
  13. <div class="swiper m-auto" :class="{'fill-swiper': slide_style == 2}" v-if="from === 'category' && list.pc_adv_img_src">
  14. <img style="height: 400px;" :class="[list.pc_adv_url? 'hoverClass':'']" @click="toLink(list)" :src="list.pc_adv_img_src" :alt="list.pc_adv_img_src">
  15. </div>
  16. <!--首页显示-->
  17. <div class="swiper m-auto" :class="{'fill-swiper': slide_style == 2}" v-if="(from !== 'supplier' && basicSet.slide.length > 0) && (!list || !list.pc_adv_img_src)">
  18. <el-carousel trigger="click" arrow="never" :autoplay="true">
  19. <el-carousel-item v-for="(item, index) in basicSet.slide" :key="index">
  20. <img :class="[item.url? 'hoverClass':'']" :src="item.img_src" @click="toLink(item)">
  21. </el-carousel-item>
  22. </el-carousel>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import {mapState} from 'vuex'
  28. export default {
  29. props: ['list','from'],
  30. data() {
  31. return {
  32. slide_style: 1
  33. };
  34. },
  35. computed: {
  36. ...mapState(['basicSet', 'basic_info'])
  37. },
  38. mounted() {
  39. this.slide_style = this.basicSet.set.slide_style || 1;
  40. },
  41. methods: {
  42. toLink(item) {
  43. if(item.url) {
  44. window.open(item.url, "_blank");
  45. }else if(item.pc_link) {
  46. window.open(item.pc_link, "_blank");
  47. }else if(item.pc_adv_url) {
  48. window.open(item.pc_adv_url, "_blank");
  49. }
  50. }
  51. }
  52. };
  53. </script>
  54. <style lang="scss" scoped>
  55. .bannar {
  56. height: 400px;
  57. width: 100%;
  58. /*background-image: url("");*/
  59. background-repeat: no-repeat;
  60. background-size: 100% 100%;
  61. margin-bottom: 80px;
  62. .swiper {
  63. padding-top: 30px;
  64. width: 1200px;
  65. :deep(.el-carousel__container) {
  66. height: 428px;
  67. }
  68. :deep(.el-carousel__button) {
  69. width: 16px;
  70. height: 6px;
  71. background-color: #fff;
  72. border-radius: 3px;
  73. opacity: 1;
  74. }
  75. :deep(.el-carousel__indicator.is-active) button {
  76. background-color: var(--color);
  77. }
  78. img {
  79. width:100%;
  80. height:100%;
  81. /*border-radius: 10px;*/
  82. }
  83. }
  84. .swiper.fill-swiper {
  85. padding-top: 0;
  86. width: 100%;
  87. :deep(.el-carousel__container) {
  88. height: 458px;
  89. }
  90. }
  91. .hoverClass {
  92. cursor: pointer;
  93. }
  94. }
  95. </style>