index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: true,
  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. this.$util.JumpPath(url);
  73. }
  74. },
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. page,
  80. .content {
  81. width: 100%;
  82. height: 100%;
  83. background-size: 100% auto;
  84. padding: 0;
  85. }
  86. .swiper {
  87. width: 100%;
  88. height: 100vh;
  89. background: #FFFFFF;
  90. }
  91. .swiper-item {
  92. width: 100%;
  93. height: 100%;
  94. text-align: center;
  95. position: relative;
  96. display: flex;
  97. /* justify-content: center; */
  98. align-items: flex-end;
  99. flex-direction: column-reverse
  100. }
  101. .swiper-item-img {
  102. width: 100%;
  103. height: 100vh;
  104. margin: 0 auto;
  105. }
  106. .swiper-item-img image {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. .jump-over {
  111. position: absolute;
  112. height: 45rpx;
  113. line-height: 45rpx;
  114. padding: 0 15rpx;
  115. border-radius: 30rpx;
  116. font-size: 24rpx;
  117. color: #b09e9a;
  118. border: 1px solid #b09e9a;
  119. z-index: 999;
  120. }
  121. .jump-over {
  122. right: 30rpx;
  123. top: 80rpx;
  124. }
  125. .video-box {
  126. width: 100vw;
  127. height: 100vh;
  128. .vid {
  129. width: 100%;
  130. height: 100%;
  131. }
  132. }
  133. </style>