mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-21 11:06:38 +08:00
79 lines
2.3 KiB
Vue
79 lines
2.3 KiB
Vue
<template>
|
|
<n-form ref="formRef" :model="model" :rules="rules" size="large" :show-label="false">
|
|
<n-form-item path="phone">
|
|
<n-input v-model:value="model.phone" :placeholder="$t('page.login.common.phonePlaceholder')" />
|
|
</n-form-item>
|
|
<n-form-item path="code">
|
|
<div class="flex-y-center w-full">
|
|
<n-input v-model:value="model.code" :placeholder="$t('page.login.common.codePlaceholder')" />
|
|
<div class="w-18px"></div>
|
|
<n-button size="large" :disabled="isCounting" :loading="smsLoading" @click="handleSmsCode">
|
|
{{ label }}
|
|
</n-button>
|
|
</div>
|
|
</n-form-item>
|
|
<n-form-item path="imgCode">
|
|
<n-input v-model:value="model.imgCode" :placeholder="$t('page.login.codeLogin.imageCodePlaceholder')" />
|
|
<div class="pl-8px">
|
|
<image-verify v-model:code="imgCode" />
|
|
</div>
|
|
</n-form-item>
|
|
<n-space :vertical="true" :size="18">
|
|
<n-button
|
|
type="primary"
|
|
size="large"
|
|
:block="true"
|
|
:round="true"
|
|
:loading="auth.loginLoading"
|
|
@click="handleSubmit"
|
|
>
|
|
{{ $t('page.login.common.confirm') }}
|
|
</n-button>
|
|
<n-button size="large" :block="true" :round="true" @click="toLoginModule('pwd-login')">
|
|
{{ $t('page.login.common.back') }}
|
|
</n-button>
|
|
</n-space>
|
|
</n-form>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { reactive, ref } from 'vue';
|
|
import type { FormInst } from 'naive-ui';
|
|
import { useAuthStore } from '@/store';
|
|
import { useRouterPush } from '@/composables';
|
|
import { useSmsCode } from '@/hooks';
|
|
import { formRules, getImgCodeRule } from '@/utils';
|
|
import { $t } from '@/locales';
|
|
|
|
const auth = useAuthStore();
|
|
const { toLoginModule } = useRouterPush();
|
|
const { label, isCounting, loading: smsLoading, getSmsCode } = useSmsCode();
|
|
|
|
const formRef = ref<HTMLElement & FormInst>();
|
|
|
|
const model = reactive({
|
|
phone: '',
|
|
code: '',
|
|
imgCode: ''
|
|
});
|
|
|
|
const imgCode = ref('');
|
|
|
|
const rules = {
|
|
phone: formRules.phone,
|
|
code: formRules.code,
|
|
imgCode: getImgCodeRule(imgCode)
|
|
};
|
|
|
|
function handleSmsCode() {
|
|
getSmsCode(model.phone);
|
|
}
|
|
|
|
async function handleSubmit() {
|
|
await formRef.value?.validate();
|
|
window.$message?.success($t('page.login.common.validateSuccess'));
|
|
}
|
|
</script>
|
|
|
|
<style scoped></style>
|