一对一视频聊天APP源码,倒计时编写实现的相关代码
countDownCtrl() {
let that = this
let startTime = new Date().getTime()
let endTime = new Date(that.data.endTime_ * 1000).getTime()
let time = (endTime - startTime) /1000
let day = parseInt(time / (60 * 60 * 24));
let hou = parseInt(time % (60 * 60 * 24) / 3600);
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
if (time>0){
setTimeout(this.countDownCtrl, 1000);
that.setData({
timer : day + "天 " + that.timeFormat(hou) + ":" + that.timeFormat(min) + ":" + that.timeFormat(sec)
})
}
},
//小于10的格式化函数(2变成02)
timeFormat(param) {
return param < 10 ? '0' + param : param;
},
以上就是一对一视频聊天APP源码,倒计时编写实现的相关代码, 更多内容欢迎关注之后的文章