|
|
@@ -1,65 +1,78 @@
|
|
|
<template>
|
|
|
- <main>
|
|
|
- <section class='login-section'>
|
|
|
- <header>用户登录</header>
|
|
|
- <section>
|
|
|
- <label for='username' class="label-bold">账号</label>
|
|
|
- <a-input id='username' placeholder='请输入账号' v-model='username' />
|
|
|
- </section>
|
|
|
- <section>
|
|
|
- <label for='password' class="label-bold">密码</label>
|
|
|
- <a-input-password id='password' placeholder='请输入密码' />
|
|
|
- </section>
|
|
|
- <div class='login-button' @click='register'>登录</div>
|
|
|
- </section>
|
|
|
- </main>
|
|
|
+ <section class="login-form-container">
|
|
|
+ <header>用户登录</header>
|
|
|
+ <a-form ref="ref_form" :model="form" :rules="rules" layout="vertical" @submit-success="handleSubmit">
|
|
|
+ <a-form-item label="邮箱" field="email" hide-asterisk="true">
|
|
|
+ <a-input v-model="form.email" placeholder="请输入邮箱">
|
|
|
+ <template #prefix> <icon-user /> </template>
|
|
|
+ </a-input>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="密码" field="password" hide-asterisk="true">
|
|
|
+ <a-input-password placeholder="请输入密码" v-model="form.password">
|
|
|
+ <template #prefix> <icon-lock /> </template>
|
|
|
+ </a-input-password>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item><a-button class="login-button" html-type="submit">登录</a-button></a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </section>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref } from 'vue';
|
|
|
+import { ref, reactive } from 'vue';
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
+import { encrypt } from '../../utils/jsencrypt';
|
|
|
+import { useCurrentUserStore } from '../../base/store/use-current-user';
|
|
|
+import { getLoginFormRules } from './auth';
|
|
|
+import { Message } from '../../3rd-libs/arco-vue-libs';
|
|
|
|
|
|
-const username = ref('');
|
|
|
+const router = useRouter();
|
|
|
+const userStore = useCurrentUserStore();
|
|
|
|
|
|
-function register() {
|
|
|
- console.log('登录');
|
|
|
-}
|
|
|
+const ref_form = ref();
|
|
|
+const form = reactive({
|
|
|
+ email: 'xyh@basic.com',
|
|
|
+ password: 'Xyh741852'
|
|
|
+});
|
|
|
+const rules = getLoginFormRules();
|
|
|
+
|
|
|
+const handleSubmit = (data) => {
|
|
|
+ console.log('data222222222222222222', data);
|
|
|
+ userStore
|
|
|
+ .toLogin({ email: data.email, password: data.password })
|
|
|
+ .then(async (res) => {
|
|
|
+ Message.success(res);
|
|
|
+
|
|
|
+ // // 登录成功后,获取路由列表
|
|
|
+ // await userStore.getRoutesList();
|
|
|
+ // // 登录成功后,获取用户权限
|
|
|
+ // await userStore.getUserInfo();
|
|
|
+
|
|
|
+ router.replace({ path: '/' });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ Message.error('登录失败,请检查您的邮箱和密码');
|
|
|
+ });
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-main {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- width: 65%;
|
|
|
-}
|
|
|
-
|
|
|
-.login-section {
|
|
|
+.login-form-container {
|
|
|
padding: 40px;
|
|
|
background-color: #fff;
|
|
|
border-radius: 12px;
|
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
|
|
- width: 100%;
|
|
|
+ width: 55%;
|
|
|
}
|
|
|
|
|
|
-.login-section header {
|
|
|
+.login-form-container header {
|
|
|
font-size: 32px;
|
|
|
font-weight: 600;
|
|
|
margin-bottom: 30px;
|
|
|
text-align: center;
|
|
|
}
|
|
|
|
|
|
-.login-section section {
|
|
|
- margin-bottom: 30px;
|
|
|
-}
|
|
|
-
|
|
|
-.login-section label {
|
|
|
- display: block;
|
|
|
- margin-bottom: 10px;
|
|
|
- font-size: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.login-section .a-input,
|
|
|
-.login-section .a-input-password {
|
|
|
+.login-form-container .a-input,
|
|
|
+.login-form-container .a-input-password {
|
|
|
width: 100%;
|
|
|
height: 48px;
|
|
|
border: 1px solid #ccc;
|