RegisterForm.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <Form class="p-4" :model="formData" :rules="getFormRules" ref="formRef">
  3. <FormItem name="account" class="enter-x">
  4. <Input size="large" v-model:value="formData.account" :placeholder="t('sys.login.userName')" />
  5. </FormItem>
  6. <FormItem name="mobile" class="enter-x">
  7. <Input size="large" v-model:value="formData.mobile" :placeholder="t('sys.login.mobile')" />
  8. </FormItem>
  9. <FormItem name="sms" class="enter-x">
  10. <CountdownInput
  11. size="large"
  12. v-model:value="formData.sms"
  13. :placeholder="t('sys.login.smsCode')"
  14. />
  15. </FormItem>
  16. <FormItem name="password" class="enter-x">
  17. <StrengthMeter
  18. size="large"
  19. v-model:value="formData.password"
  20. :placeholder="t('sys.login.password')"
  21. />
  22. </FormItem>
  23. <FormItem name="confirmPassword" class="enter-x">
  24. <InputPassword
  25. size="large"
  26. visibilityToggle
  27. v-model:value="formData.confirmPassword"
  28. :placeholder="t('sys.login.confirmPassword')"
  29. />
  30. </FormItem>
  31. <FormItem class="enter-x" name="policy">
  32. <!-- No logic, you need to deal with it yourself -->
  33. <Checkbox v-model:checked="formData.policy" size="small">
  34. {{ t('sys.login.policy') }}
  35. </Checkbox>
  36. </FormItem>
  37. <Button
  38. type="primary"
  39. size="large"
  40. block
  41. @click="handleReset"
  42. :loading="loading"
  43. class="enter-x"
  44. >
  45. {{ t('sys.login.registerButton') }}
  46. </Button>
  47. <Button size="large" block class="mt-4 enter-x" @click="handleBackLogin">
  48. {{ t('sys.login.backSignIn') }}
  49. </Button>
  50. </Form>
  51. </template>
  52. <script lang="ts">
  53. import { defineComponent, reactive, ref } from 'vue';
  54. import { Form, Input, Button, Divider, Checkbox } from 'ant-design-vue';
  55. import { StrengthMeter } from '/@/components/StrengthMeter';
  56. import { CountdownInput } from '/@/components/CountDown';
  57. import { useI18n } from '/@/hooks/web/useI18n';
  58. import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin';
  59. export default defineComponent({
  60. name: 'RegisterPasswordForm',
  61. components: {
  62. Button,
  63. Form,
  64. FormItem: Form.Item,
  65. Input,
  66. Divider,
  67. InputPassword: Input.Password,
  68. Checkbox,
  69. StrengthMeter,
  70. CountdownInput,
  71. },
  72. setup() {
  73. const { t } = useI18n();
  74. const { setLoginState } = useLoginState();
  75. const formRef = ref<any>(null);
  76. const loading = ref(false);
  77. const formData = reactive({
  78. account: '',
  79. password: '',
  80. confirmPassword: '',
  81. mobile: '',
  82. sms: '',
  83. policy: false,
  84. });
  85. const { getFormRules } = useFormRules(formData);
  86. const { validForm } = useFormValid(formRef);
  87. async function handleReset() {
  88. const data = await validForm();
  89. if (!data) return;
  90. console.log(data);
  91. }
  92. function handleBackLogin() {
  93. setLoginState(LoginStateEnum.LOGIN);
  94. }
  95. return {
  96. t,
  97. formRef,
  98. formData,
  99. getFormRules,
  100. handleReset,
  101. loading,
  102. handleBackLogin,
  103. };
  104. },
  105. });
  106. </script>