splash.wxml

  1. <view style="height: 100%;width: 100%;">
  2. <navigator open-type='switchTab' url='/pages/index/index'>
  3. <view class='tiaoguo'>跳过
  4. <text>{{time}}</text>
  5. </view>
  6. </navigator>
  7. <swiper style="height: 100%;width: 100%;" indicator-dots>
  8. <swiper-item wx:for="{{ subjects }}" wx:key="{{ item.id }}" style="flex: 1;">
  9. <image src="{{ item.images.large }}" mode="aspectFill" style="position: absolute;height:
  10. 100%;width: 100%;opacity: .8;" />
  11. </swiper-item>
  12. </swiper>
  13. </view>

splash.js

  1. Page({
  2. /**
  3. * 页面的初始数据
  4. */
  5. data: {
  6. time:5,
  7. subjects: [],
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function (options) {
  13. var that = this;
  14. const db = wx.cloud.database();
  15. db.collection('coming_soon').get({
  16. success: function (res) {
  17. that.setData({ subjects: res.data[0].subjects })
  18. // 5秒钟后自动进入主页
  19. var timer = setInterval(function(){
  20. if(that.data.time > 0){
  21. that.setData({
  22. time: that.data.time - 1
  23. })
  24. if(that.data.time == 0){
  25. clearInterval(timer);
  26. wx.switchTab({
  27. url: '/pages/index/index',
  28. })
  29. }
  30. }
  31. },1000)
  32. }
  33. })
  34. }
  35. })

splash.wxss

  1. .tiaoguo{
  2. position: absolute;
  3. top: 20rpx;
  4. right: 20rpx;
  5. color: #fff;
  6. z-index: 100;
  7. }