index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="content">
  3. <swiper class="swiper" :autoplay="autoplay" :duration="duration"
  4. v-if="advData.type == 'pic' && advData.value.length">
  5. <swiper-item v-for="(item,index) in advData" :key="index">
  6. <view class="swiper-item">
  7. <view class="swiper-item-img">
  8. <image :src="item" mode="aspectFit"></image>
  9. </view>
  10. </view>
  11. </swiper-item>
  12. </swiper>
  13. <view class="video-box" v-else-if="advData.type == 'video' && advData.video_link">
  14. <video class="vid" :src="advData.video_link" :autoplay="true" :loop="true" :muted="true"
  15. :controls="false"></video>
  16. </view>
  17. <view class="jump-over" @tap="launchFlag()">跳过<text v-if="closeType == 1">{{time}}</text></view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. autoplay: false,
  25. duration: 500,
  26. jumpover: '跳过',
  27. experience: '立即体验',
  28. time: 5,
  29. timecount: undefined
  30. }
  31. },
  32. props: {
  33. advData: {
  34. type: Object,
  35. default: () => {}
  36. },
  37. // 1 倒计时 2 手动关闭(预留)
  38. closeType: {
  39. type: Number,
  40. default: 1
  41. }
  42. },
  43. mounted() {
  44. console.log(this.advData)
  45. this.timer()
  46. },
  47. methods: {
  48. timer() {
  49. var t = ßthis.advData.time || 5
  50. this.timecount = setInterval(() => {
  51. t--
  52. this.time = t
  53. if (t <= 0) {
  54. clearInterval(this.timecount)
  55. this.launchFlag()
  56. }
  57. }, 1000)
  58. },
  59. launchFlag() {
  60. clearInterval(this.timecount)
  61. uni.switchTab({
  62. url: '/pages/index/index'
  63. });
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. page,
  70. .content {
  71. width: 100%;
  72. height: 100%;
  73. background-size: 100% auto;
  74. padding: 0;
  75. }
  76. .swiper {
  77. width: 100%;
  78. height: 100vh;
  79. background: #FFFFFF;
  80. }
  81. .swiper-item {
  82. width: 100%;
  83. height: 100%;
  84. text-align: center;
  85. position: relative;
  86. display: flex;
  87. /* justify-content: center; */
  88. align-items: flex-end;
  89. flex-direction: column-reverse
  90. }
  91. .swiper-item-img {
  92. width: 100%;
  93. height: 100vh;
  94. margin: 0 auto;
  95. }
  96. .swiper-item-img image {
  97. width: 100%;
  98. height: 100%;
  99. }
  100. .uniapp-img {
  101. height: 50%;
  102. background: #FFFFFF;
  103. display: flex;
  104. justify-content: center;
  105. align-items: center;
  106. overflow: hidden;
  107. }
  108. .uniapp-img image {
  109. width: 40%;
  110. }
  111. .jump-over,
  112. .experience {
  113. position: absolute;
  114. height: 45rpx;
  115. line-height: 45rpx;
  116. padding: 0 15rpx;
  117. border-radius: 30rpx;
  118. font-size: 24rpx;
  119. color: #b09e9a;
  120. border: 1px solid #b09e9a;
  121. z-index: 999;
  122. }
  123. .jump-over {
  124. right: 30rpx;
  125. top: 80rpx;
  126. }
  127. .experience {
  128. right: 50%;
  129. margin-right: -105upx;
  130. bottom: 80rpx;
  131. }
  132. .video-box {
  133. width: 100vw;
  134. height: 100vh;
  135. .vid {
  136. width: 100%;
  137. height: 100%;
  138. }
  139. }
  140. </style>