|
@@ -3,35 +3,80 @@
|
|
|
<div class="login-form">
|
|
<div class="login-form">
|
|
|
<img :src="exitIcon" alt="关闭" class="exit-icon" @click="emit('close')" />
|
|
<img :src="exitIcon" alt="关闭" class="exit-icon" @click="emit('close')" />
|
|
|
<header class="login-form__header">
|
|
<header class="login-form__header">
|
|
|
- <span>登录</span>
|
|
|
|
|
|
|
+ <span>{{ type !== 'modifyPassword' ? '登录' : '修改密码' }}</span>
|
|
|
</header>
|
|
</header>
|
|
|
<main class="login-form__main">
|
|
<main class="login-form__main">
|
|
|
- <el-input v-model="username" placeholder="请输入您的账号" class="el-input--default" />
|
|
|
|
|
- <el-input
|
|
|
|
|
- v-model="password"
|
|
|
|
|
- placeholder="请输入您的密码"
|
|
|
|
|
- type="password"
|
|
|
|
|
- show-password
|
|
|
|
|
- class="el-input--default"
|
|
|
|
|
- />
|
|
|
|
|
- <div class="login-form__code">
|
|
|
|
|
- <el-input v-model="code" placeholder="验证码" class="el-input--default" />
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <el-form ref="formRef" :model="login" label-width="auto" class="login-form__form">
|
|
|
|
|
+ <el-form-item prop="username" :rules="[{ required: true, message: '账号不能为空' }]">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ placeholder="请输入您的账号"
|
|
|
|
|
+ v-model="login.username"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ autocomplete="off"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ class="el-input--default"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item prop="password" :rules="[{ required: true, message: '密码不能为空' }]">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ placeholder="请输入您的密码"
|
|
|
|
|
+ v-model="login.password"
|
|
|
|
|
+ type="password"
|
|
|
|
|
+ autocomplete="off"
|
|
|
|
|
+ show-password
|
|
|
|
|
+ clearable
|
|
|
|
|
+ class="el-input--default"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ prop="code"
|
|
|
|
|
+ :rules="[{ required: true, message: '验证码不能为空' }]"
|
|
|
|
|
+ v-if="type !== 'modifyPassword'"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-input placeholder="验证码" v-model="login.code" clearable class="el-input--default" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
</main>
|
|
</main>
|
|
|
<footer class="login-form__footer">
|
|
<footer class="login-form__footer">
|
|
|
- <el-button class="login-form__button" @click="emit('close')">登录</el-button>
|
|
|
|
|
|
|
+ <el-button class="login-form__button" @click="handleLogin">
|
|
|
|
|
+ {{ type !== 'modifyPassword' ? '登录' : '修改密码' }}
|
|
|
|
|
+ </el-button>
|
|
|
</footer>
|
|
</footer>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
- import { ref } from 'vue';
|
|
|
|
|
|
|
+ import { ref, reactive } from 'vue';
|
|
|
import exitIcon from 'assets/svg/exit.svg';
|
|
import exitIcon from 'assets/svg/exit.svg';
|
|
|
- const username = ref('');
|
|
|
|
|
- const password = ref('');
|
|
|
|
|
- const code = ref('');
|
|
|
|
|
|
|
+ import type { FormInstance } from 'element-plus';
|
|
|
|
|
+ import { ElMessage } from 'element-plus';
|
|
|
|
|
+ import useMockUserStore from '@/store/modules/mockUser';
|
|
|
|
|
+ import { storeToRefs } from 'pinia';
|
|
|
|
|
+ const mockUserStore = useMockUserStore();
|
|
|
|
|
+ const { userInfo } = storeToRefs(mockUserStore);
|
|
|
|
|
+ const props = defineProps<{
|
|
|
|
|
+ type: 'login' | 'switchAccount' | 'modifyPassword';
|
|
|
|
|
+ }>();
|
|
|
|
|
+ const login = reactive({
|
|
|
|
|
+ username: '',
|
|
|
|
|
+ password: '',
|
|
|
|
|
+ code: '',
|
|
|
|
|
+ });
|
|
|
const emit = defineEmits(['close']);
|
|
const emit = defineEmits(['close']);
|
|
|
|
|
+ const formRef = ref<FormInstance>();
|
|
|
|
|
+ const handleLogin = () => {
|
|
|
|
|
+ if (!formRef.value) return;
|
|
|
|
|
+ formRef.value.validate((valid: boolean) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ userInfo.value = login.username;
|
|
|
|
|
+ const message =
|
|
|
|
|
+ props.type === 'login' ? '登录成功' : props.type === 'switchAccount' ? '切换账号成功' : '修改密码成功';
|
|
|
|
|
+ ElMessage.success(message);
|
|
|
|
|
+ emit('close');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -48,7 +93,6 @@
|
|
|
.login-form {
|
|
.login-form {
|
|
|
position: relative;
|
|
position: relative;
|
|
|
width: 700cpx;
|
|
width: 700cpx;
|
|
|
- height: 514cpx;
|
|
|
|
|
padding: 0 33cpx;
|
|
padding: 0 33cpx;
|
|
|
background: $white-color;
|
|
background: $white-color;
|
|
|
border-radius: 24cpx;
|
|
border-radius: 24cpx;
|
|
@@ -79,7 +123,7 @@
|
|
|
&__footer {
|
|
&__footer {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
height: 100cpx;
|
|
height: 100cpx;
|
|
|
- margin-top: 36cpx;
|
|
|
|
|
|
|
+ margin-top: 18cpx;
|
|
|
.login-form__button {
|
|
.login-form__button {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
height: 74cpx;
|
|
height: 74cpx;
|
|
@@ -99,6 +143,12 @@
|
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ .login-form__form {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ gap: 2cpx;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ }
|
|
|
.el-input--default {
|
|
.el-input--default {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
height: 72cpx;
|
|
height: 72cpx;
|
|
@@ -107,8 +157,4 @@
|
|
|
color: #999;
|
|
color: #999;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- :deep(.el-icon svg) {
|
|
|
|
|
- width: 30cpx;
|
|
|
|
|
- height: 30cpx;
|
|
|
|
|
- }
|
|
|
|
|
</style>
|
|
</style>
|