index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <!-- 开屏广告 -->
  3. <view class="content">
  4. <swiper class="swiper" :class="advData.list.length==1?'on':''" :autoplay="autoplay" :interval="interval" :duration="duration" :circular="circular" @change="stopChange"
  5. v-if="advData.list.length">
  6. <swiper-item v-for="(item,index) in advData.list" :key="index" @click.stop="jump(item.url)">
  7. <view class="swiper-item">
  8. <view class="swiper-item-img">
  9. <image :src="item.image" mode="aspectFill"></image>
  10. </view>
  11. </view>
  12. </swiper-item>
  13. </swiper>
  14. <view class="video-box" v-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" @tap="launchFlag()">跳过<text v-if="closeType == 1">{{time}}</text><slot name="bottom"></slot></view>
  19. </view>
  20. </template>
  21. <script>
  22. // +----------------------------------------------------------------------
  23. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  24. // +----------------------------------------------------------------------
  25. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  26. // +----------------------------------------------------------------------
  27. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  28. // +----------------------------------------------------------------------
  29. // | Author: CRMEB Team <admin@crmeb.com>
  30. // +----------------------------------------------------------------------
  31. let app = getApp();
  32. export default {
  33. data() {
  34. return {
  35. autoplay: true,
  36. circular: true,
  37. duration: 500,
  38. interval: 2500,
  39. jumpover: '跳过',
  40. experience: '立即体验',
  41. time: this.advData.config.open_screen_time,
  42. timecount: undefined,
  43. navH: 0
  44. }
  45. },
  46. props: {
  47. advData: {
  48. type: Object,
  49. default: () => {}
  50. },
  51. // 1 倒计时 2 手动关闭(预留)
  52. closeType: {
  53. type: Number,
  54. default: 1
  55. }
  56. },
  57. mounted() {
  58. this.timer()
  59. // #ifdef MP
  60. this.navH = app.globalData.navHeight;
  61. // #endif
  62. // #ifndef MP
  63. this.navH = 80;
  64. // #endif
  65. },
  66. methods: {
  67. stopChange(){
  68. if(this.advData.list.length == 1){
  69. return false
  70. }
  71. },
  72. timer() {
  73. var t = this.advData.config.open_screen_time || 5
  74. this.timecount = setInterval(() => {
  75. t--
  76. this.time = t
  77. if (t <= 0) {
  78. clearInterval(this.timecount)
  79. this.launchFlag()
  80. }
  81. }, 1000)
  82. },
  83. launchFlag() {
  84. clearInterval(this.timecount)
  85. uni.switchTab({
  86. url: '/pages/index/index'
  87. });
  88. },
  89. jump(url) {
  90. if(url){
  91. clearInterval(this.timecount)
  92. if (url.indexOf("http") != -1) {
  93. uni.navigateTo({
  94. url: `/pages/annex/web_view/index?url=${url}`
  95. });
  96. } else {
  97. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index', '/pages/index/index', '/pages/plant_grass/index']
  98. .indexOf(url) == -1) {
  99. uni.navigateTo({
  100. url: url
  101. })
  102. } else {
  103. uni.reLaunch({
  104. url: url
  105. })
  106. }
  107. }
  108. }
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. page,
  115. .content {
  116. width: 100%;
  117. height: 100%;
  118. background-size: 100% auto;
  119. padding: 0;
  120. // position: relative;
  121. }
  122. .swiper {
  123. width: 100%;
  124. height: 100vh;
  125. background: #FFFFFF;
  126. // &.on{
  127. // position: relative;
  128. // &:after {
  129. // content: '';
  130. // position: absolute;
  131. // top: 0;
  132. // left: 0;
  133. // right: 0;
  134. // bottom: 0;
  135. // z-index: 2;
  136. // }
  137. // }
  138. }
  139. .swiper-item {
  140. width: 100%;
  141. height: 100%;
  142. text-align: center;
  143. position: relative;
  144. display: flex;
  145. align-items: flex-end;
  146. flex-direction: column-reverse
  147. }
  148. .swiper-item-img {
  149. width: 100vw;
  150. height: 100vh;
  151. margin: 0 auto;
  152. display: flex;
  153. }
  154. .swiper-item-img image {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. .jump-over {
  159. position: absolute;
  160. height: 45rpx;
  161. line-height: 45rpx;
  162. padding: 0 15rpx;
  163. border-radius: 30rpx;
  164. font-size: 24rpx;
  165. color: #b09e9a;
  166. border: 1px solid #b09e9a;
  167. z-index: 999;
  168. right: 30rpx;
  169. bottom: 150rpx;
  170. }
  171. .video-box {
  172. width: 100vw;
  173. height: 100vh;
  174. .vid {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. }
  179. </style>