|
@@ -0,0 +1,332 @@
|
|
|
+<template>
|
|
|
+ <div class="login">
|
|
|
+ <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
|
|
+ <h3 class="title-pass">账号登录</h3>
|
|
|
+ <el-form-item prop="username">
|
|
|
+ <label class="custom-label">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.username"
|
|
|
+ type="text"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="账号"
|
|
|
+ >
|
|
|
+ <!-- <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> -->
|
|
|
+
|
|
|
+ </el-input>
|
|
|
+ </label>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="password">
|
|
|
+ <label class="custom-Pass">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.password"
|
|
|
+ type="password"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="密码"
|
|
|
+ @keyup.enter.native="handleLogin"
|
|
|
+ >
|
|
|
+ <!-- <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> -->
|
|
|
+ </el-input>
|
|
|
+ </label>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox> -->
|
|
|
+ <el-form-item style="width:100%;">
|
|
|
+ <el-button
|
|
|
+ :loading="loading"
|
|
|
+ size="medium"
|
|
|
+ type="primary"
|
|
|
+ style="width:100%;"
|
|
|
+ @click.native.prevent="handleLogin"
|
|
|
+ class="login-submit"
|
|
|
+ >
|
|
|
+ <span v-if="!loading">登 录</span>
|
|
|
+ <span v-else>登 录 中...</span>
|
|
|
+ </el-button>
|
|
|
+ <div style="float: right;" v-if="register">
|
|
|
+ <router-link class="link-type" :to="'/register'">立即注册</router-link>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <!-- 底部 -->
|
|
|
+ <div class="el-login-footer">
|
|
|
+ <!-- <span>Copyright © 2018-2022 All Rights Reserved.</span>-->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ import Cookies from "js-cookie";
|
|
|
+ import { encrypt, decrypt } from '@/utils/jsencrypt'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: "Login",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ codeUrl: "",
|
|
|
+ loginForm: {
|
|
|
+ username: "admin",
|
|
|
+ password: "admin123",
|
|
|
+ rememberMe: false,
|
|
|
+
|
|
|
+ uuid: ""
|
|
|
+ },
|
|
|
+ loginRules: {
|
|
|
+ username: [
|
|
|
+ { required: true, trigger: "blur", message: "请输入您的账号" }
|
|
|
+ ],
|
|
|
+ password: [
|
|
|
+ { required: true, trigger: "blur", message: "请输入您的密码" }
|
|
|
+ ],
|
|
|
+
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+
|
|
|
+ // 注册开关
|
|
|
+ register: false,
|
|
|
+ redirect: undefined
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ $route: {
|
|
|
+ handler: function(route) {
|
|
|
+ this.redirect = route.query && route.query.redirect;
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+
|
|
|
+ this.getCookie();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ getCookie() {
|
|
|
+ const username = Cookies.get("username");
|
|
|
+ const password = Cookies.get("password");
|
|
|
+ const rememberMe = Cookies.get('rememberMe')
|
|
|
+ this.loginForm = {
|
|
|
+ username: username === undefined ? this.loginForm.username : username,
|
|
|
+ password: password === undefined ? this.loginForm.password : decrypt(password),
|
|
|
+ rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
|
|
+ };
|
|
|
+ },
|
|
|
+ handleLogin() {
|
|
|
+ this.$refs.loginForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ // 设置记住密码逻辑
|
|
|
+ if (this.loginForm.rememberMe) {
|
|
|
+ Cookies.set("username", this.loginForm.username, { expires: 30 });
|
|
|
+ Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
|
|
|
+ Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
|
|
|
+ } else {
|
|
|
+ Cookies.remove("username");
|
|
|
+ Cookies.remove("password");
|
|
|
+ Cookies.remove('rememberMe');
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$store.dispatch("Login", this.loginForm)
|
|
|
+ .then(() => {
|
|
|
+ this.$router.push({ path: this.redirect || "/" }).catch(() => {});
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ // 提取具体错误信息
|
|
|
+ let errorMsg;
|
|
|
+ if (error && error.msg) {
|
|
|
+ errorMsg = error.msg;
|
|
|
+ } else if (error && error.message) {
|
|
|
+ errorMsg = error.message;
|
|
|
+ } else {
|
|
|
+ errorMsg = '登录失败';
|
|
|
+ }
|
|
|
+ this.$message.error(errorMsg);
|
|
|
+ // // 刷新验证码
|
|
|
+ // if (this.captchaEnabled) {
|
|
|
+ // try {
|
|
|
+ // this.getCode();
|
|
|
+ // } catch (e) {
|
|
|
+ // console.error('刷新验证码失败:', e);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <style rel="stylesheet/scss" lang="scss">
|
|
|
+ .login {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ height: 100%;
|
|
|
+ background-image: url("../assets/images/login-background.png");
|
|
|
+ background-size: cover;
|
|
|
+ }
|
|
|
+ .title-pass {
|
|
|
+ margin: 0px auto 30px auto;
|
|
|
+ text-align: center;
|
|
|
+ font-family: FZZCHJW--GB1-0;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 30px;
|
|
|
+ color: #A9FFFE;
|
|
|
+ letter-spacing: 4.21px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .login-form {
|
|
|
+ // border-radius: 6px;
|
|
|
+ // background: #ffffff;
|
|
|
+ width: 545px;
|
|
|
+ height: 505px;
|
|
|
+ padding: 100px 100px 20px 100px;
|
|
|
+ background-image: url("../assets/images/passwordBorder.png");
|
|
|
+ background-size: cover;
|
|
|
+ .el-input {
|
|
|
+ height: 38px;
|
|
|
+ input {
|
|
|
+ height: 38px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .input-icon {
|
|
|
+ height: 39px;
|
|
|
+ width: 14px;
|
|
|
+ margin-left: 2px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .login-tip {
|
|
|
+ font-size: 13px;
|
|
|
+ text-align: center;
|
|
|
+ color: #bfbfbf;
|
|
|
+ }
|
|
|
+ .login-code {
|
|
|
+ width: 33%;
|
|
|
+ height: 38px;
|
|
|
+ float: right;
|
|
|
+ img {
|
|
|
+ cursor: pointer;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .login-code-img {
|
|
|
+ height: 38px;
|
|
|
+ border: 2px #009998 solid;
|
|
|
+ }
|
|
|
+ .login-form .el-input input {
|
|
|
+ height: 38px;
|
|
|
+ background: #096C78;
|
|
|
+ border: 2px #009998 solid;
|
|
|
+ color: #A9FFFE;
|
|
|
+ opacity: 0.9;
|
|
|
+ padding-left: 35px;
|
|
|
+ }
|
|
|
+ .el-form-item.is-error .el-input__inner, .el-form-item.is-error .el-input__inner:focus, .el-form-item.is-error .el-textarea__inner, .el-form-item.is-error .el-textarea__inner:focus {
|
|
|
+ border-color: #009998;
|
|
|
+ }
|
|
|
+ .login-submit{
|
|
|
+ font-family: PingFangSC-SNaNpxibold;
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 18px;
|
|
|
+ color: #002230;
|
|
|
+ /* color: #FFFFFF; */
|
|
|
+ background-color: #1890ff;
|
|
|
+ /* border-color: #1890ff; */
|
|
|
+ opacity: 0.85;
|
|
|
+ background: #0DDBDA;
|
|
|
+ border: 1px solid #0FF9F7;
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+ .login-submit:hover{
|
|
|
+ font-family: PingFangSC-SNaNpxibold;
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 18px;
|
|
|
+ color: #002230;
|
|
|
+ /* color: #FFFFFF; */
|
|
|
+ background-color: #1890ff;
|
|
|
+ /* border-color: #1890ff; */
|
|
|
+ opacity: 0.85;
|
|
|
+ background: #0DDBDA;
|
|
|
+ border: 1px solid #0FF9F7;
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+ .login-submit:enabled {
|
|
|
+ font-family: PingFangSC-SNaNpxibold;
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 18px;
|
|
|
+ color: #002230;
|
|
|
+ /* color: #FFFFFF; */
|
|
|
+ background-color: #1890ff;
|
|
|
+ /* border-color: #1890ff; */
|
|
|
+ opacity: 0.85;
|
|
|
+ background: #0DDBDA;
|
|
|
+ border: 1px solid #0FF9F7;
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+ .el-checkbox__input.is-checked + .el-checkbox__label {
|
|
|
+ color: #0FF9F7;
|
|
|
+ }
|
|
|
+ .el-checkbox__input.is-checked .el-checkbox__inner {
|
|
|
+ background-color: #0FF9F7;
|
|
|
+ border-color: #0FF9F7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .custom-label::before {
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ left: 10px;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ width: 18px;
|
|
|
+ height: 18px;
|
|
|
+ background-image: url("../assets/images/passWordUse.png"); /* 替换为你的图片路径 */
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-size: cover;
|
|
|
+ z-index: 99;
|
|
|
+ }
|
|
|
+ .custom-Pass::before{
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ left: 10px;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ width: 18px;
|
|
|
+ height: 18px;
|
|
|
+ background-image: url("../assets/images/suoUse.png"); /* 替换为你的图片路径 */
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-size: cover;
|
|
|
+ z-index: 99;
|
|
|
+ }
|
|
|
+ .custom-yzm::before{
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ left: 10px;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ width: 18px;
|
|
|
+ height: 18px;
|
|
|
+ background-image: url("../assets/images/yanzma.png"); /* 替换为你的图片路径 */
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-size: cover;
|
|
|
+ z-index: 99;
|
|
|
+ }
|
|
|
+ .el-login-footer {
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ position: fixed;
|
|
|
+ bottom: 0;
|
|
|
+ width: 100%;
|
|
|
+ text-align: center;
|
|
|
+ color: #fff;
|
|
|
+ font-family: Arial;
|
|
|
+ font-size: 12px;
|
|
|
+ letter-spacing: 1px;
|
|
|
+ }
|
|
|
+ .login-code-img {
|
|
|
+ height: 38px;
|
|
|
+ }
|
|
|
+ </style>
|