Skip to content

Commit 1ed33dc

Browse files
committed
feat(projects): login page: register
1 parent c91dd28 commit 1ed33dc

File tree

3 files changed

+67
-8
lines changed

3 files changed

+67
-8
lines changed

src/views/_builtin/login/modules/code-login.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const rules = computed<Record<keyof FormModel, App.Global.FormRule[]>>(() => {
3434
3535
async function handleSubmit() {
3636
await validate();
37+
// request
3738
window.$message?.success($t('page.login.common.validateSuccess'));
3839
}
3940
</script>

src/views/_builtin/login/modules/register.vue

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,81 @@
11
<script setup lang="ts">
2+
import { computed, reactive } from 'vue';
23
import { $t } from '@/locales';
34
import { useRouterPush } from '@/hooks/common/router';
5+
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
6+
import { useCaptcha } from '@/hooks/business/captcha';
47
58
defineOptions({
69
name: 'CodeLogin'
710
});
811
912
const { toggleLoginModule } = useRouterPush();
13+
const { formRef, validate } = useNaiveForm();
14+
const { label, isCounting, loading, getCaptcha } = useCaptcha();
15+
16+
interface FormModel {
17+
phone: string;
18+
code: string;
19+
password: string;
20+
confirmPassword: string;
21+
}
22+
23+
const model: FormModel = reactive({
24+
phone: '',
25+
code: '',
26+
password: '',
27+
confirmPassword: ''
28+
});
29+
30+
const rules = computed<Record<keyof FormModel, App.Global.FormRule[]>>(() => {
31+
const { formRules, createConfirmPwdRule } = useFormRules();
32+
33+
return {
34+
phone: formRules.phone,
35+
code: formRules.code,
36+
password: formRules.pwd,
37+
confirmPassword: createConfirmPwdRule(model.password)
38+
};
39+
});
40+
41+
async function handleSubmit() {
42+
await validate();
43+
// request to register
44+
window.$message?.success($t('page.login.common.validateSuccess'));
45+
}
1046
</script>
1147

1248
<template>
13-
<NForm size="large" :show-label="false">
14-
<NFormItem>
15-
<NInput :placeholder="$t('page.login.common.phonePlaceholder')" />
49+
<NForm ref="formRef" :model="model" :rules="rules" size="large" :show-label="false">
50+
<NFormItem path="phone">
51+
<NInput v-model:value="model.phone" :placeholder="$t('page.login.common.phonePlaceholder')" />
52+
</NFormItem>
53+
<NFormItem path="code">
54+
<div class="w-full flex-y-center gap-16px">
55+
<NInput v-model:value="model.code" :placeholder="$t('page.login.common.codePlaceholder')" />
56+
<NButton size="large" :disabled="isCounting" :loading="loading" @click="getCaptcha(model.phone)">
57+
{{ label }}
58+
</NButton>
59+
</div>
60+
</NFormItem>
61+
<NFormItem path="password">
62+
<NInput
63+
v-model:value="model.password"
64+
type="password"
65+
show-password-on="click"
66+
:placeholder="$t('page.login.common.passwordPlaceholder')"
67+
/>
1668
</NFormItem>
17-
<NFormItem>
18-
<NInput :placeholder="$t('page.login.common.codePlaceholder')" />
69+
<NFormItem path="confirmPassword">
70+
<NInput
71+
v-model:value="model.confirmPassword"
72+
type="password"
73+
show-password-on="click"
74+
:placeholder="$t('page.login.common.confirmPasswordPlaceholder')"
75+
/>
1976
</NFormItem>
2077
<NSpace vertical :size="18" class="w-full">
21-
<NButton type="primary" size="large" round block>
78+
<NButton type="primary" size="large" round block @click="handleSubmit">
2279
{{ $t('common.confirm') }}
2380
</NButton>
2481
<NButton size="large" round block @click="toggleLoginModule('pwd-login')">

src/views/_builtin/login/modules/reset-pwd.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const rules = computed<RuleRecord>(() => {
4040
async function handleSubmit() {
4141
await validate();
4242
// request to reset password
43+
window.$message?.success($t('page.login.common.validateSuccess'));
4344
}
4445
</script>
4546

@@ -55,15 +56,15 @@ async function handleSubmit() {
5556
<NInput
5657
v-model:value="model.password"
5758
type="password"
58-
show-password-on="mousedown"
59+
show-password-on="click"
5960
:placeholder="$t('page.login.common.passwordPlaceholder')"
6061
/>
6162
</NFormItem>
6263
<NFormItem path="confirmPassword">
6364
<NInput
6465
v-model:value="model.confirmPassword"
6566
type="password"
66-
show-password-on="mousedown"
67+
show-password-on="click"
6768
:placeholder="$t('page.login.common.confirmPasswordPlaceholder')"
6869
/>
6970
</NFormItem>

0 commit comments

Comments
 (0)