SendVerifyCode.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2023 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: this.$t('验证码'),
  15. runTime: undefined
  16. };
  17. },
  18. methods: {
  19. sendCode() {
  20. if (this.disabled) return;
  21. this.disabled = true;
  22. let n = 20;
  23. this.text = this.$t('剩余') + n + "s";
  24. this.runTime = setInterval(() => {
  25. n = n - 1;
  26. if (n < 0) {
  27. clearInterval(this.runTime);
  28. this.disabled = false;
  29. this.text = this.$t('重新获取');
  30. return
  31. }
  32. this.text = this.$t('剩余') + n + "s";
  33. }, 1000);
  34. }
  35. },
  36. onHide() {
  37. clearInterval(this.runTime);
  38. }
  39. };