splash.wxml
<view style="height: 100%;width: 100%;">
<navigator open-type='switchTab' url='/pages/index/index'>
<view class='tiaoguo'>跳过
<text>{{time}}</text>
</view>
</navigator>
<swiper style="height: 100%;width: 100%;" indicator-dots>
<swiper-item wx:for="{{ subjects }}" wx:key="{{ item.id }}" style="flex: 1;">
<image src="{{ item.images.large }}" mode="aspectFill" style="position: absolute;height:
100%;width: 100%;opacity: .8;" />
</swiper-item>
</swiper>
</view>
splash.js
Page({
/**
* 页面的初始数据
*/
data: {
time:5,
subjects: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
const db = wx.cloud.database();
db.collection('coming_soon').get({
success: function (res) {
that.setData({ subjects: res.data[0].subjects })
// 5秒钟后自动进入主页
var timer = setInterval(function(){
if(that.data.time > 0){
that.setData({
time: that.data.time - 1
})
if(that.data.time == 0){
clearInterval(timer);
wx.switchTab({
url: '/pages/index/index',
})
}
}
},1000)
}
})
}
})
splash.wxss
.tiaoguo{
position: absolute;
top: 20rpx;
right: 20rpx;
color: #fff;
z-index: 100;
}