Skip to content

Commit

Permalink
feat(projects): login page: register
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Mar 23, 2024
1 parent c91dd28 commit 1ed33dc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/views/_builtin/login/modules/code-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const rules = computed<Record<keyof FormModel, App.Global.FormRule[]>>(() => {
async function handleSubmit() {
await validate();
// request
window.$message?.success($t('page.login.common.validateSuccess'));
}
</script>
Expand Down
69 changes: 63 additions & 6 deletions src/views/_builtin/login/modules/register.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,81 @@
<script setup lang="ts">
import { computed, reactive } from 'vue';
import { $t } from '@/locales';
import { useRouterPush } from '@/hooks/common/router';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import { useCaptcha } from '@/hooks/business/captcha';
defineOptions({
name: 'CodeLogin'
});
const { toggleLoginModule } = useRouterPush();
const { formRef, validate } = useNaiveForm();
const { label, isCounting, loading, getCaptcha } = useCaptcha();
interface FormModel {
phone: string;
code: string;
password: string;
confirmPassword: string;
}
const model: FormModel = reactive({
phone: '',
code: '',
password: '',
confirmPassword: ''
});
const rules = computed<Record<keyof FormModel, App.Global.FormRule[]>>(() => {
const { formRules, createConfirmPwdRule } = useFormRules();
return {
phone: formRules.phone,
code: formRules.code,
password: formRules.pwd,
confirmPassword: createConfirmPwdRule(model.password)
};
});
async function handleSubmit() {
await validate();
// request to register
window.$message?.success($t('page.login.common.validateSuccess'));
}
</script>

<template>
<NForm size="large" :show-label="false">
<NFormItem>
<NInput :placeholder="$t('page.login.common.phonePlaceholder')" />
<NForm ref="formRef" :model="model" :rules="rules" size="large" :show-label="false">
<NFormItem path="phone">
<NInput v-model:value="model.phone" :placeholder="$t('page.login.common.phonePlaceholder')" />
</NFormItem>
<NFormItem path="code">
<div class="w-full flex-y-center gap-16px">
<NInput v-model:value="model.code" :placeholder="$t('page.login.common.codePlaceholder')" />
<NButton size="large" :disabled="isCounting" :loading="loading" @click="getCaptcha(model.phone)">
{{ label }}
</NButton>
</div>
</NFormItem>
<NFormItem path="password">
<NInput
v-model:value="model.password"
type="password"
show-password-on="click"
:placeholder="$t('page.login.common.passwordPlaceholder')"
/>
</NFormItem>
<NFormItem>
<NInput :placeholder="$t('page.login.common.codePlaceholder')" />
<NFormItem path="confirmPassword">
<NInput
v-model:value="model.confirmPassword"
type="password"
show-password-on="click"
:placeholder="$t('page.login.common.confirmPasswordPlaceholder')"
/>
</NFormItem>
<NSpace vertical :size="18" class="w-full">
<NButton type="primary" size="large" round block>
<NButton type="primary" size="large" round block @click="handleSubmit">
{{ $t('common.confirm') }}
</NButton>
<NButton size="large" round block @click="toggleLoginModule('pwd-login')">
Expand Down
5 changes: 3 additions & 2 deletions src/views/_builtin/login/modules/reset-pwd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const rules = computed<RuleRecord>(() => {
async function handleSubmit() {
await validate();
// request to reset password
window.$message?.success($t('page.login.common.validateSuccess'));
}
</script>

Expand All @@ -55,15 +56,15 @@ async function handleSubmit() {
<NInput
v-model:value="model.password"
type="password"
show-password-on="mousedown"
show-password-on="click"
:placeholder="$t('page.login.common.passwordPlaceholder')"
/>
</NFormItem>
<NFormItem path="confirmPassword">
<NInput
v-model:value="model.confirmPassword"
type="password"
show-password-on="mousedown"
show-password-on="click"
:placeholder="$t('page.login.common.confirmPasswordPlaceholder')"
/>
</NFormItem>
Expand Down

0 comments on commit 1ed33dc

Please sign in to comment.