微信小程序 30分钟倒计时功能

ps:凑个数
getTimeDiff(date) {
    let _this = this;
    let curTime = new Date(date)
    _this.countDown(_this.timeFormatConvert(new Date(curTime.setMinutes(curTime.getMinutes() + 30))))
  },
  timeFormatConvert(e) {
    const Y = e.getFullYear(); // 年
    const M = this.prefixZero(e.getMonth() + 1); // 月
    const D = this.prefixZero(e.getDate()); // 日
    const H = this.prefixZero(e.getHours()); // 时
    const Mi = this.prefixZero(e.getMinutes()); // 分
    const S = this.prefixZero(e.getSeconds()); // 秒
    return Y + "-" + 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(new Date(endTime.replace(/-/g, "/")).getTime() - new Date().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)
    })
  },