GetEmailCode.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="email-code">
  3. <span class="email-code-icon">
  4. <img src="/register/mail_success.png" alt="" />
  5. </span>
  6. <input
  7. type="text"
  8. v-model="emailCode"
  9. :placeholder="L['请输入验证码']"
  10. class="input"
  11. autocomplete="off"
  12. />
  13. <span class="email-code-accept">
  14. <el-button
  15. @click="getVerifyCode"
  16. :disabled="countDownNumer"
  17. :loading="getVerifyCodeLoading"
  18. >
  19. <span>{{ codeText }}</span>
  20. <span v-if="countDownNumer">{{ `(${countDownNumer})` }}</span>
  21. </el-button>
  22. </span>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { getCurLanguage } from "@/composables/common.js";
  27. const L = getCurLanguage();
  28. const emits = defineEmits(["success"]);
  29. const props = defineProps({
  30. beforeAction: {
  31. type: Function | Promise,
  32. default: () => {},
  33. },
  34. afterAction: {
  35. type: Function | Promise,
  36. default: () => {},
  37. },
  38. });
  39. const emailCode = ref(""); // 邮箱验证码
  40. // 倒计时展示
  41. const countDownNumer = ref(0);
  42. const getVerifyCodeLoading = ref(false);
  43. // 重新获取验证码标识
  44. const isReacquireCode = ref(false);
  45. // 获取验证码的文案
  46. const codeText = computed(() => {
  47. return isReacquireCode.value
  48. ? L["register"]["重新获取"]
  49. : L["register"]["获取验证码"];
  50. });
  51. const getVerifyCode = async () => {
  52. if (typeof beforeAction === "function") {
  53. beforeAction();
  54. }
  55. if (beforeAction instanceof Promise) {
  56. await beforeAction();
  57. }
  58. };
  59. </script>
  60. <style lang="scss" scoped>
  61. .email-code {
  62. display: flex;
  63. width: 100%;
  64. &-icon {
  65. width: 50px;
  66. display: flex;
  67. justify-content: center;
  68. align-items: center;
  69. border: 1px solid #e8e8e8;
  70. border-right: none;
  71. background: #f8f8f8;
  72. img {
  73. width: 20px;
  74. }
  75. }
  76. input {
  77. border: 1px solid #e8e8e8;
  78. border-left: none;
  79. border-right: none;
  80. height: 40px;
  81. padding: 0 0 0 10px;
  82. width: 190px;
  83. }
  84. &-accept {
  85. display: flex;
  86. justify-content: center;
  87. align-items: center;
  88. width: 90px;
  89. .el-button {
  90. width: 100%;
  91. height: 100%;
  92. color: #666;
  93. background: #f8f8f8;
  94. border-left: none;
  95. border-radius: 0;
  96. font-size: 12px;
  97. &:hover {
  98. border-color: #e8e8e8;
  99. color: $colorMain;
  100. }
  101. }
  102. }
  103. }
  104. </style>