|
@ -1,5 +1,7 @@ |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
import { getStartupPage } from '../../api/index' |
|
|
import { |
|
|
|
|
|
getStartupPageV2 |
|
|
|
|
|
} from '../../api/index' |
|
|
|
|
|
|
|
|
Page({ |
|
|
Page({ |
|
|
data: { |
|
|
data: { |
|
@ -7,7 +9,11 @@ Page({ |
|
|
countdownNum: 0, |
|
|
countdownNum: 0, |
|
|
bgImage: '', |
|
|
bgImage: '', |
|
|
timer: '', |
|
|
timer: '', |
|
|
scene: '' |
|
|
scene: '', |
|
|
|
|
|
imgList: [], |
|
|
|
|
|
datanum: 0, //第几个数组
|
|
|
|
|
|
datalength: 0, //数组长度
|
|
|
|
|
|
allTime:0,//总时间
|
|
|
}, |
|
|
}, |
|
|
onLoad(options) { |
|
|
onLoad(options) { |
|
|
if (options.scene) { |
|
|
if (options.scene) { |
|
@ -22,12 +28,22 @@ Page({ |
|
|
countDown() { |
|
|
countDown() { |
|
|
this.data.timer = setInterval(() => { |
|
|
this.data.timer = setInterval(() => { |
|
|
if (this.data.countdownNum > 1) { |
|
|
if (this.data.countdownNum > 1) { |
|
|
|
|
|
this.data.allTime-- |
|
|
this.data.countdownNum-- |
|
|
this.data.countdownNum-- |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
countdownNum: this.data.countdownNum |
|
|
countdownNum: this.data.countdownNum, |
|
|
|
|
|
allTime: this.data.allTime |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
this.data.allTime-- |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
datanum: this.data.datanum + 1, |
|
|
|
|
|
allTime: this.data.allTime |
|
|
|
|
|
}) |
|
|
clearInterval(this.data.timer) |
|
|
clearInterval(this.data.timer) |
|
|
|
|
|
if (this.data.datalength != this.data.datanum) { |
|
|
|
|
|
this.getloop() |
|
|
|
|
|
} else { |
|
|
if (this.data.scene) { |
|
|
if (this.data.scene) { |
|
|
wx.reLaunch({ |
|
|
wx.reLaunch({ |
|
|
url: `/pages/indexNew/indexNew?scene=${this.data.scene}` |
|
|
url: `/pages/indexNew/indexNew?scene=${this.data.scene}` |
|
@ -38,6 +54,7 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
}, 1000) |
|
|
}, 1000) |
|
|
}, |
|
|
}, |
|
|
// 立即进入
|
|
|
// 立即进入
|
|
@ -58,15 +75,22 @@ Page({ |
|
|
wx.showLoading({ |
|
|
wx.showLoading({ |
|
|
title: '获取中...' |
|
|
title: '获取中...' |
|
|
}) |
|
|
}) |
|
|
getStartupPage().then(res => { |
|
|
getStartupPageV2().then(res => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
console.log('获取启动页信息', res) |
|
|
console.log('获取启动页信息', res) |
|
|
if (res.data.imgUrl) { |
|
|
if (res.data.length > 0) { |
|
|
|
|
|
|
|
|
|
|
|
res.data.forEach((item, index) => { |
|
|
|
|
|
// this.data.allTime = this.data.allTime + item.duration
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
bgImage: res.data.imgUrl, |
|
|
allTime: this.data.allTime + item.duration |
|
|
countdownNum: res.data.duration |
|
|
|
|
|
}) |
|
|
}) |
|
|
this.countDown() |
|
|
}) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
datalength: res.data.length, |
|
|
|
|
|
imgList: res.data |
|
|
|
|
|
}) |
|
|
|
|
|
this.getloop() |
|
|
} else { |
|
|
} else { |
|
|
this.immeEnter() |
|
|
this.immeEnter() |
|
|
} |
|
|
} |
|
@ -74,5 +98,15 @@ Page({ |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
this.immeEnter() |
|
|
this.immeEnter() |
|
|
}) |
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
//数组循环
|
|
|
|
|
|
getloop() { |
|
|
|
|
|
if (this.data.imgList[this.data.datanum].duration > 0) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
bgImage: this.data.imgList[this.data.datanum].imgUrl, |
|
|
|
|
|
countdownNum: this.data.imgList[this.data.datanum].duration |
|
|
|
|
|
}) |
|
|
|
|
|
this.countDown() |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |