guide.vue 2.9 KB

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