123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <div class="login flex justify-center items-center h-full">
- <img class="logo" src="../../assets/imgs/login_logo.png" />
- <div class="login-bg flex justify-center items-center">
- <div class="login-bg-inner-box text-center">
- <img src="../../assets/imgs/login_bg_inner.png" />
- <div class="title1">欢 迎 使 用</div>
- <div class="title2">项目质量控制管理平台</div>
- </div>
- </div>
- <div class="login-box">
- <div class="title1 flex justify-between items-center">
- <span>{{ forgetStatus ? '忘记密码' : '输入信息' }}</span>
- <t-button
- variant="outline"
- theme="primary"
- v-if="forgetStatus"
- @click="forgetStatus = false"
- >
- <template #icon><RollbackIcon /></template>
- 返回登录
- </t-button>
- </div>
- <div class="title2">{{
- `请输入${forgetStatus ? '新的' : ''}账号与密码`
- }}</div>
- <t-form
- v-if="!forgetStatus"
- ref="form"
- :data="formData"
- :label-width="0"
- class="login-form"
- :rules="rules"
- >
- <t-form-item name="loginName">
- <t-input
- v-model="formData.loginName"
- clearable
- placeholder="请输入账号"
- size="large"
- @enter="loginHandle"
- >
- <template #prefix-icon>
- <desktop-icon />
- </template>
- </t-input>
- </t-form-item>
- <t-form-item name="password">
- <t-input
- v-model="formData.password"
- type="password"
- clearable
- placeholder="请输入密码"
- size="large"
- @enter="loginHandle"
- >
- <template #prefix-icon>
- <lock-on-icon />
- </template>
- </t-input>
- </t-form-item>
- <t-link theme="primary" class="m-t-20px" @click="forgetStatus = true"
- >忘记密码</t-link
- >
- <t-button
- block
- class="m-t-30px"
- @click="loginHandle"
- size="large"
- theme="primary"
- >登 录</t-button
- >
- </t-form>
- <ForgetPwd v-else @success="findSuccess" />
- </div>
- </div>
- <!-- <button @click="loginHandle" class="m-t-10px">登录!</button> -->
- </template>
- <script setup name="Login">
- import { ref, reactive, computed, watch } from 'vue';
- import { DesktopIcon, LockOnIcon, RollbackIcon } from 'tdesign-icons-vue-next';
- import { useRoute, useRouter } from 'vue-router';
- import { useUserStore } from '@/store';
- import { MessagePlugin } from 'tdesign-vue-next';
- import { getBase64 } from '@/utils/crypto';
- import ForgetPwd from './forget-pwd.vue';
- const forgetStatus = ref(false);
- const form = ref(null);
- const route = useRoute();
- const router = useRouter();
- const formData = reactive({
- loginName: '',
- password: '',
- });
- const rules = {
- loginName: [
- { required: true, message: '请输入账号', type: 'error', trigger: 'change' },
- ],
- password: [
- { required: true, message: '请输入密码', type: 'error', trigger: 'change' },
- ],
- };
- const userStore = useUserStore();
- const loginHandle = () => {
- form.value.validate().then(async (result) => {
- const redirect = route.query.redirect
- ? route.query.redirect
- : '/my-workbenches';
- if (result === true) {
- await userStore.login({
- loginName: formData.loginName,
- password: getBase64(formData.password),
- type: 'ACCOUNT',
- });
- await userStore.requestUserMenu();
- if (redirect) {
- router.push(redirect);
- } else {
- router.push({ name: userStore.menus[0].name });
- }
- }
- });
- };
- const findSuccess = () => {
- forgetStatus.value = false;
- formData.loginName = '';
- formData.password = '';
- };
- </script>
- <style lang="less" scoped>
- .login {
- background: linear-gradient(180deg, #f4f9ff 0%, #d7eaff 100%);
- position: relative;
- min-height: 550px;
- .logo {
- width: 180px;
- z-index: 100;
- top: 48px;
- left: 48px;
- position: absolute;
- }
- .login-bg {
- position: absolute;
- top: 80px;
- bottom: 80px;
- left: 0;
- width: 70%;
- z-index: 99;
- background: url(../../assets//imgs/login_bg_grid.png) center center
- no-repeat;
- background-size: contain;
- .login-bg-inner-box {
- img {
- height: 260px;
- margin-bottom: 20px;
- }
- .title1 {
- font-size: 32px;
- color: #262626;
- margin-bottom: 15px;
- font-weight: bold;
- line-height: 40px;
- }
- .title2 {
- font-size: 20px;
- color: #8c8c8c;
- line-height: 28px;
- }
- }
- }
- .login-box {
- width: 350px;
- background: #fff;
- box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.08);
- border-radius: 8px;
- border: 1px solid #e5e6eb;
- padding: 24px;
- position: absolute;
- left: 60%;
- z-index: 101;
- .title1 {
- span {
- font-size: 20px;
- font-weight: bold;
- color: #262626;
- line-height: 32px;
- }
- }
- .title2 {
- font-size: 14px;
- color: #8c8c8c;
- line-height: 24px;
- margin-top: 4px;
- margin-bottom: 28px;
- }
- }
- }
- </style>
|