//倒计时 leftTimer: function (time) { var that = this; var leftTime = new Date(time) - (new Date()); //计算剩余的毫秒数 var hours = that.data.hours; var minutes = that.data.minutes; hours = parseInt(leftTime / 1000 / 60 / 60 % 24, 10); //计算剩余的小时 minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟 hours = that.checkTime(hours); minutes = that.checkTime(minutes); that.setData({ hours: hours, minutes:minutes }) }, //将0-9的数字前面加上0,例1变为01 checkTime: function (i) { if (i < 10) { i = "0" + i; } return i; },