index.vue 2.9 KB

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