index.vue 3.1 KB

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