index.vue 2.9 KB

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