banner-1.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view style="">
  3. <view class="banner">
  4. <swiper class="swiper" :current="current" previous-margin="192rpx" next-margin="192rpx"
  5. @change="changeCurrent">
  6. <swiper-item v-for="(item, index) in list" :key="index" class="swiper-item"
  7. @click="downLoad(item.link)">
  8. <view class="banner-li" :class="{ 'active-item': current === index }">
  9. <image class="banner-li__img" :src="url+item.imgPath" mode="">
  10. </image>
  11. </view>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'Banner1',
  20. props: {
  21. list: {
  22. type: Array,
  23. default: () => []
  24. },
  25. url: {
  26. type: String,
  27. default: null
  28. }
  29. },
  30. data() {
  31. return {
  32. current: 1, // 当前展示滑块下标
  33. }
  34. },
  35. watch: {
  36. },
  37. created() {
  38. },
  39. methods: {
  40. // 切换
  41. changeCurrent(event) {
  42. this.current = event.detail.current
  43. },
  44. // 打开自定义链接
  45. openCustomLink(link = '') {
  46. console.log(`link: ${link}`)
  47. },
  48. downLoad(item) {
  49. console.log(this.baseURL)
  50. if (item) {
  51. let url = encodeURIComponent(item)
  52. uni.navigateTo({
  53. url: '../../pages/home/myWebView?url=' + url
  54. })
  55. }
  56. },
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .banner {
  62. width: 100%;
  63. height: 226upx;
  64. background-color: #efefef;
  65. padding-top: 10px;
  66. .banner-li {
  67. width: 366upx;
  68. height: 206upx;
  69. border-radius: 8upx;
  70. overflow: hidden;
  71. transform: scaleY(0.85);
  72. transition: all .5s;
  73. &__img {
  74. width: 100%;
  75. height: 100%;
  76. }
  77. }
  78. .swiper-item {
  79. width: 366upx;
  80. height: 206upx;
  81. padding: 0 10upx;
  82. }
  83. .active-item {
  84. transform: scaleY(1);
  85. }
  86. }
  87. </style>