You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.7 KiB
78 lines
1.7 KiB
const app = getApp()
|
|
import { getStartupPage } from '../../api/index'
|
|
|
|
Page({
|
|
data: {
|
|
deviceHeight: 0,
|
|
countdownNum: 0,
|
|
bgImage: '',
|
|
timer: '',
|
|
scene: ''
|
|
},
|
|
onLoad (options) {
|
|
if (options.scene) {
|
|
this.data.scene = options.scene
|
|
}
|
|
this.setData({
|
|
deviceHeight: app.globalData.height
|
|
})
|
|
this.getStartupPage()
|
|
},
|
|
// 倒计时进入
|
|
countDown () {
|
|
this.data.timer = setInterval(() => {
|
|
if (this.data.countdownNum > 1) {
|
|
this.data.countdownNum--
|
|
this.setData({
|
|
countdownNum: this.data.countdownNum
|
|
})
|
|
} else {
|
|
clearInterval(this.data.timer)
|
|
if (this.data.scene) {
|
|
wx.reLaunch({
|
|
url: `/pages/indexNew/indexNew?scene=${this.data.scene}`
|
|
})
|
|
} else {
|
|
wx.reLaunch({
|
|
url: '/pages/indexNew/indexNew'
|
|
})
|
|
}
|
|
}
|
|
}, 1000)
|
|
},
|
|
// 立即进入
|
|
immeEnter () {
|
|
clearInterval(this.data.timer)
|
|
if (this.data.scene) {
|
|
wx.reLaunch({
|
|
url: `/pages/indexNew/indexNew?scene=${this.data.scene}`
|
|
})
|
|
} else {
|
|
wx.reLaunch({
|
|
url: '/pages/indexNew/indexNew'
|
|
})
|
|
}
|
|
},
|
|
// 获取启动页信息
|
|
getStartupPage () {
|
|
wx.showLoading({
|
|
title: '获取中...'
|
|
})
|
|
getStartupPage().then(res => {
|
|
wx.hideLoading()
|
|
console.log('获取启动页信息', res)
|
|
if (res.data.imgUrl) {
|
|
this.setData({
|
|
bgImage: res.data.imgUrl,
|
|
countdownNum: res.data.duration
|
|
})
|
|
this.countDown()
|
|
} else {
|
|
this.immeEnter()
|
|
}
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
this.immeEnter()
|
|
})
|
|
}
|
|
})
|