commission--yt-commit
This commit is contained in:
88
pages/course/courseOrderList/courseOrderList.js
Normal file
88
pages/course/courseOrderList/courseOrderList.js
Normal file
@ -0,0 +1,88 @@
|
||||
// pages/course/courseOrderList/courseOrderList.js
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
items: [null, null, null],
|
||||
countDown: 30 * 60 , // 初始倒计时
|
||||
countDownStr: '' // 用于在视图中渲染的倒计时文本
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.startCountDown();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
clearInterval(this.intervalId);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
clearInterval(this.intervalId);
|
||||
},
|
||||
|
||||
/**
|
||||
* 启动倒计时
|
||||
*/
|
||||
startCountDown() {
|
||||
this.updateCountDownStr();
|
||||
this.intervalId = setInterval(() => {
|
||||
let cd = this.data.countDown;
|
||||
if (cd <= 1) {
|
||||
clearInterval(this.intervalId);
|
||||
this.setData({
|
||||
countDown: 0,
|
||||
countDownStr: '00分00秒'
|
||||
});
|
||||
} else {
|
||||
cd--;
|
||||
this.setData({ countDown: cd });
|
||||
this.updateCountDownStr();
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新倒计时显示字符串
|
||||
*/
|
||||
updateCountDownStr() {
|
||||
const minutes = Math.floor(this.data.countDown / 60);
|
||||
const seconds = this.data.countDown % 60;
|
||||
const str = `${minutes}分${seconds < 10 ? '0' + seconds : seconds}秒`;
|
||||
this.setData({ countDownStr: str });
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {}
|
||||
});
|
Reference in New Issue
Block a user