SendVerifyCode.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. export default {
  11. data() {
  12. return {
  13. disabled: false,
  14. text: "获取验证码",
  15. run: undefined
  16. };
  17. },
  18. methods: {
  19. sendCode() {
  20. if (this.disabled) return;
  21. this.disabled = true;
  22. let n = 60;
  23. this.text = "剩余 " + n + "s";
  24. this.run = setInterval(() => {
  25. n = n - 1;
  26. if (n < 0) {
  27. clearInterval(this.run);
  28. }
  29. this.text = "剩余 " + n + "s";
  30. if (this.text < "剩余 " + 0 + "s") {
  31. this.disabled = false;
  32. this.text = "重新获取";
  33. }
  34. }, 1000);
  35. }
  36. },
  37. beforeDestroy() {
  38. clearInterval(this.run);
  39. },
  40. };