card-swiper.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view>
  3. <view class="top-swiper">
  4. <view class="box">
  5. <view style="height: 44px;"></view>
  6. <swiper class="swiper" :previous-margin="swiper.margin" :next-margin='swiper.margin' :circular="true"
  7. @change="swiperChange">
  8. <swiper-item v-for="(item,index) in card_menu" :key="index" @click="toUrl(item.url)">
  9. <!-- <image class='le-img' :src='item' :class="{'le-active':swiper.index == index}"></image> -->
  10. <view class="le-img" :class="{'le-active':swiper.index == index}">
  11. <view class="img_box">
  12. <image class="card_img" :src="item.img" mode="aspectFill"></image>
  13. </view>
  14. <view class="detail_box">
  15. <view class="title_box">{{item.title}}</view>
  16. <view class="author_box">By:{{item.author}}</view>
  17. </view>
  18. </view>
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import Common from '../../static/js/common'
  27. export default {
  28. props: {
  29. card_menu: {
  30. type: Array,
  31. default: []
  32. }
  33. },
  34. data() {
  35. return {
  36. swiper: {
  37. margin: "150rpx",
  38. index: 0,
  39. list: [
  40. "/static/images/douyin/0.jpg",
  41. "/static/images/douyin/4.jpg",
  42. "/static/images/douyin/7.jpg",
  43. ]
  44. }
  45. }
  46. },
  47. components: {
  48. },
  49. mounted() {
  50. },
  51. methods: {
  52. //swiper滑动事件
  53. swiperChange: function(e) {
  54. this.swiper.index = e.detail.current;
  55. },
  56. toUrl(url){
  57. Common.navigateTo(url);
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss">
  63. .top-swiper {
  64. margin-bottom: 30rpx;
  65. .box {
  66. padding-top: var(--status-bar-height);
  67. box-sizing: content-box;
  68. position: absolute;
  69. z-index: 5;
  70. top: 0;
  71. left: 0;
  72. width: 100%;
  73. height: auto;
  74. }
  75. .swiper {
  76. height: 600rpx;
  77. margin: 0 20rpx;
  78. .le-img {
  79. width: 100%;
  80. height: 100%;
  81. display: block;
  82. transform: scale(0.9);
  83. transition: transform 0.3s ease-in-out 0s;
  84. border-radius: 10px;
  85. background-color: #fff;
  86. overflow: hidden;
  87. &.le-active {
  88. transform: scale(1);
  89. }
  90. .img_box {
  91. width: 100%;
  92. height: 65%;
  93. overflow: hidden;
  94. .card_img {
  95. height: 100%;
  96. width: 100%;
  97. }
  98. }
  99. .detail_box {
  100. width: 100%;
  101. height: 35%;
  102. overflow: hidden;
  103. .title_box {
  104. width: 100%;
  105. text-align: center;
  106. font-size: 40rpx;
  107. margin: 30rpx 0;
  108. }
  109. .author_box {
  110. width: 100%;
  111. text-align: center;
  112. font-size: 30rpx;
  113. position: relative;
  114. height: 80rpx;
  115. line-height: 80rpx;
  116. &::before {
  117. content: "";
  118. height: 1px;
  119. width: 150rpx;
  120. position: absolute;
  121. transform: translateX(-50%);
  122. left: 50%;
  123. top: 0;
  124. background: #000;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. </style>