index.vue 2.9 KB

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