i-banner.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="banner" :style="{marginTop: bannerMarginTop + 'px'}">
  3. <swiper class="banner_box" autoplay circular>
  4. <swiper-item v-for="item in banners" :key="item.id">
  5. <view class="banner_item">
  6. <view class="banner_item_img">
  7. <image :src="item.imgURL" mode=""></image>
  8. </view>
  9. <view class="banner_item_title">
  10. <text>{{item.title}}</text>
  11. </view>
  12. </view>
  13. </swiper-item>
  14. </swiper>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. props:[
  20. "banners"
  21. ],
  22. data() {
  23. return {
  24. bannerMarginTop:0,
  25. };
  26. },
  27. created() {
  28. // 获取手机系统信息
  29. const info = uni.getSystemInfoSync()
  30. // 设置偏移高度
  31. const MarginTop = 90 - info.statusBarHeight
  32. this.bannerMarginTop = - MarginTop
  33. }
  34. }
  35. </script>
  36. <style lang="scss">
  37. .banner{
  38. margin: 0 auto;
  39. margin-top: -90px;
  40. width: 700rpx;
  41. height: 404rpx;
  42. border-radius: 16rpx;
  43. overflow: hidden;
  44. .banner_box{
  45. width: 700rpx;
  46. height: 404rpx;
  47. .banner_item{
  48. position: relative;
  49. .banner_item_img{
  50. width: 700rpx;
  51. height: 404rpx;
  52. image{
  53. width:100%;
  54. height:100%;
  55. }
  56. }
  57. .banner_item_title{
  58. position: absolute;
  59. left: 18rpx;
  60. bottom: 18rpx;
  61. height: 33rpx;
  62. font-size: 25rpx;
  63. font-family: $font-basic;
  64. color: #FFFFFF;
  65. line-height: 33rpx;
  66. }
  67. }
  68. }
  69. }
  70. </style>