index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. methods: {
  56. stopChange(){
  57. if(this.advData.value.length == 1){
  58. return false
  59. }
  60. },
  61. timer() {
  62. var t = this.advData.time || 5
  63. this.timecount = setInterval(() => {
  64. t--
  65. this.time = t
  66. if (t <= 0) {
  67. clearInterval(this.timecount)
  68. this.launchFlag()
  69. }
  70. }, 1000)
  71. },
  72. launchFlag() {
  73. clearInterval(this.timecount)
  74. uni.switchTab({
  75. url: '/pages/index/index'
  76. });
  77. },
  78. jump(url) {
  79. if(url){
  80. clearInterval(this.timecount)
  81. this.$util.JumpPath(url);
  82. }
  83. },
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. page,
  89. .content {
  90. width: 100%;
  91. height: 100%;
  92. background-size: 100% auto;
  93. padding: 0;
  94. }
  95. .swiper {
  96. width: 100%;
  97. height: 100vh;
  98. background: #FFFFFF;
  99. &.on{
  100. position: relative;
  101. &:after {
  102. content: '';
  103. position: absolute;
  104. top: 0;
  105. left: 0;
  106. right: 0;
  107. bottom: 0;
  108. z-index: 2;
  109. }
  110. }
  111. }
  112. .swiper-item {
  113. width: 100%;
  114. height: 100%;
  115. text-align: center;
  116. position: relative;
  117. display: flex;
  118. /* justify-content: center; */
  119. align-items: flex-end;
  120. flex-direction: column-reverse
  121. }
  122. .swiper-item-img {
  123. width: 100vw;
  124. height: 100vh;
  125. margin: 0 auto;
  126. }
  127. .swiper-item-img image {
  128. width: 100%;
  129. height: 100%;
  130. }
  131. .jump-over {
  132. position: absolute;
  133. height: 45rpx;
  134. line-height: 45rpx;
  135. padding: 0 15rpx;
  136. border-radius: 30rpx;
  137. font-size: 24rpx;
  138. color: #b09e9a;
  139. border: 1px solid #b09e9a;
  140. z-index: 999;
  141. right: 30rpx;
  142. }
  143. .video-box {
  144. width: 100vw;
  145. height: 100vh;
  146. .vid {
  147. width: 100%;
  148. height: 100%;
  149. }
  150. }
  151. </style>