import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import { __decorate } from "tslib";
import { action, observable, runInAction } from 'mobx';

var CountDown = /*#__PURE__*/function () {
  function CountDown() {
    var _this = this;

    _classCallCheck(this, CountDown);

    runInAction(function () {
      _this.count = 0;
    });
  }

  _createClass(CountDown, [{
    key: "setCount",
    value: function setCount() {
      // 计算时间差
      var millis = Date.now() - this.startTime;
      this.count = 60 - Math.floor(millis / 1000);
    }
  }, {
    key: "start",
    value: function start() {
      var _this2 = this;

      this.startTime = Date.now();
      var timer = setInterval(function () {
        _this2.setCount(); // 倒计时结束


        if (_this2.count <= 0) {
          clearInterval(timer);

          _this2.setVerifyType();
        }
      }, 1000);
    } // 获取验证码时的验证方式

  }, {
    key: "setVerifyType",
    value: function setVerifyType(value) {
      this.verifyType = value || null;
    }
  }]);

  return CountDown;
}();

__decorate([observable], CountDown.prototype, "count", void 0);

__decorate([action], CountDown.prototype, "setCount", null);

export default CountDown;
//# sourceMappingURL=CountDown.js.map
