getTimeDiff(date){let _this =this;let curTime =newDate(date)
_this.countDown(_this.timeFormatConvert(newDate(curTime.setMinutes(curTime.getMinutes()+30))))},timeFormatConvert(e){constY= e.getFullYear();// 年constM=this.prefixZero(e.getMonth()+1);// 月constD=this.prefixZero(e.getDate());// 日constH=this.prefixZero(e.getHours());// 时const Mi =this.prefixZero(e.getMinutes());// 分constS=this.prefixZero(e.getSeconds());// 秒returnY+"-"+M+"-"+D+" "+H+":"+ Mi +":"+S;},prefixZero(num =0, n =2){return(Array(n).join("0")+ num).slice(-n);},/**
* 倒计时
* @param endTime 结束日期+时间
* **/countDown(endTime){var that =this;
that.setData({timer:setInterval(function(){var downTime =parseInt(newDate(endTime.replace(/-/g,"/")).getTime()-newDate().getTime())// 倒计时结束if(downTime <=0){
that.setData({timedjs:"00:00"})//结束周期计时器clearInterval(that.data.timer);return;}//计算距离活动还有多少天、时、分、秒var d =parseInt(downTime /1000/3600/24);var h =parseInt(downTime /1000/3600%24);var m =parseInt(downTime /1000/60%60);var s =parseInt(downTime /1000%60);//统一格式的显示
d <10? d ='0'+ d : d;
h <10? h ='0'+ h : h;
m <10? m ='0'+ m : m;
s <10? s ='0'+ s : s;//同步显示
that.setData({timedjs: m +":"+ s
})},1000)})},