You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
7.5 KiB

11 months ago
<template>
<div class="login">
<!-- <NavigationBar :showLeft="false" :showRight="false" /> -->
11 months ago
<el-form
ref="loginForm"
:model="loginForm"
:rules="loginRules"
class="login-form"
>
<h3 class="title">娄东街道人口数据管理平台</h3>
11 months ago
<el-form-item prop="username">
<el-input
v-model="loginForm.username"
type="text"
auto-complete="off"
11 months ago
placeholder="请输入用户名/手机号"
11 months ago
>
11 months ago
<svg-icon
slot="prefix"
icon-class="user"
class="el-input__icon input-icon"
/>
11 months ago
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="loginForm.password"
type="password"
auto-complete="off"
11 months ago
placeholder="请输入用户密码"
11 months ago
@keyup.enter.native="handleLogin"
>
11 months ago
<svg-icon
slot="prefix"
icon-class="password"
class="el-input__icon input-icon"
/>
11 months ago
</el-input>
</el-form-item>
<el-form-item prop="code" v-if="captchaEnabled">
<el-input
v-model="loginForm.code"
auto-complete="off"
11 months ago
placeholder="请输入验证码"
11 months ago
style="width: 63%"
@keyup.enter.native="handleLogin"
>
11 months ago
<!-- <svg-icon
slot="prefix"
icon-class="validCode"
class="el-input__icon input-icon"
/> -->
11 months ago
</el-input>
<div class="login-code">
11 months ago
<img :src="codeUrl" @click="getCode" class="login-code-img" />
11 months ago
</div>
</el-form-item>
<!-- <el-checkbox
11 months ago
class="rememberMe"
v-model="loginForm.rememberMe"
style="margin: 0px 0px 25px 0px"
>记住密码</el-checkbox
> -->
11 months ago
<el-form-item style="width: 100%">
11 months ago
<el-button
11 months ago
class="logo-btn"
11 months ago
:loading="loading"
size="medium"
type="primary"
11 months ago
style="width: 100%"
11 months ago
@click.native.prevent="handleLogin"
>
<span v-if="!loading"> </span>
<span v-else> ...</span>
</el-button>
11 months ago
<div style="float: right" v-if="register">
<router-link class="link-type" :to="'/register'"
>立即注册</router-link
>
11 months ago
</div>
</el-form-item>
</el-form>
<!-- 底部 -->
<div class="el-login-footer">
<!-- <span>Copyright © 2018-2024 ruoyi.vip All Rights Reserved.</span> -->
<span
>Copyright © 2022-{{ year }} 此系统对老版本系统进行优化 简约版</span
>
</div>
11 months ago
</div>
</template>
<script>
// import NavigationBar from "@/components/NavigationBar/index.vue";
11 months ago
import { getCodeImg } from "@/api/login";
import Cookies from "js-cookie";
11 months ago
import { encrypt, decrypt } from "@/utils/jsencrypt";
const moment = require("moment");
11 months ago
export default {
name: "Login",
// components: {
// NavigationBar,
// },
11 months ago
data() {
return {
year: moment().year(),
11 months ago
codeUrl: "",
loginForm: {
username: "admin",
11 months ago
password: "Xingyu@2022",
11 months ago
rememberMe: false,
code: "",
11 months ago
uuid: "",
11 months ago
},
loginRules: {
username: [
11 months ago
{ required: true, trigger: "blur", message: "请输入您的账号" },
11 months ago
],
password: [
11 months ago
{ required: true, trigger: "blur", message: "请输入您的密码" },
11 months ago
],
11 months ago
code: [{ required: true, trigger: "change", message: "请输入验证码" }],
11 months ago
},
loading: false,
// 验证码开关
captchaEnabled: true,
// 注册开关
register: false,
11 months ago
redirect: undefined,
11 months ago
};
},
watch: {
$route: {
11 months ago
handler: function (route) {
11 months ago
this.redirect = route.query && route.query.redirect;
},
11 months ago
immediate: true,
},
11 months ago
},
created() {
this.getCode();
this.getCookie();
},
methods: {
getCode() {
11 months ago
getCodeImg().then((res) => {
this.captchaEnabled =
res.captchaEnabled === undefined ? true : res.captchaEnabled;
11 months ago
if (this.captchaEnabled) {
this.codeUrl = "data:image/gif;base64," + res.img;
this.loginForm.uuid = res.uuid;
}
});
},
getCookie() {
const username = Cookies.get("username");
const password = Cookies.get("password");
11 months ago
const rememberMe = Cookies.get("rememberMe");
11 months ago
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
11 months ago
password:
password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
11 months ago
};
},
handleLogin() {
11 months ago
this.$refs.loginForm.validate((valid) => {
11 months ago
if (valid) {
this.loading = true;
if (this.loginForm.rememberMe) {
Cookies.set("username", this.loginForm.username, { expires: 30 });
11 months ago
Cookies.set("password", encrypt(this.loginForm.password), {
expires: 30,
});
Cookies.set("rememberMe", this.loginForm.rememberMe, {
expires: 30,
});
11 months ago
} else {
Cookies.remove("username");
Cookies.remove("password");
11 months ago
Cookies.remove("rememberMe");
11 months ago
}
11 months ago
this.$store
.dispatch("Login", this.loginForm)
.then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
})
.catch(() => {
this.loading = false;
if (this.captchaEnabled) {
this.getCode();
}
});
11 months ago
}
});
11 months ago
},
},
11 months ago
};
</script>
<style rel="stylesheet/scss" lang="scss">
.login {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
11 months ago
background-image: url("../assets/images/ui/logo_bg.jpg");
background-size: 100% 100%;
11 months ago
}
.title {
margin: 0px auto 30px auto;
text-align: center;
11 months ago
color: #00d8ff;
font-size: 25px;
11 months ago
font-family: "xiniu";
11 months ago
}
.login-form {
border-radius: 6px;
11 months ago
background-image: url("../assets/images/ui/img_frame.png");
background-size: 100% 100%;
width: 420px;
10 months ago
padding: 30px 35px 5px 35px;
11 months ago
.el-input {
height: 45px;
11 months ago
input {
height: 45px;
font-size: 16px;
11 months ago
color: #d8dde6;
font-family: "Alibaba-PuHuiTi-Regular.otf";
background: rgba(9, 27, 52, 0.2);
border-color: #1489cc;
11 months ago
}
10 months ago
input::placeholder {
font-size: 16px;
10 months ago
}
11 months ago
}
10 months ago
11 months ago
.input-icon {
height: 45px;
width: 16px;
11 months ago
margin-left: 2px;
11 months ago
color: #1adcff;
11 months ago
}
}
11 months ago
.rememberMe {
color: #d8dde6;
}
.logo-btn {
height: 45px;
11 months ago
background: linear-gradient(
0deg,
rgba(7, 39, 64, 0.9) 0%,
rgba(0, 132, 255, 0.9) 100%
);
box-shadow: 0px 3px 6px 0px rgba(4, 0, 0, 0.45);
border-radius: 10px;
// border-image: linear-gradient(0deg, #00c0ff, #009cff) 10 10;
}
.logo-btn:hover {
background: linear-gradient(
0deg,
rgba(7, 39, 64, 0.9) 0%,
rgba(0, 132, 255, 0.9) 100%
);
}
11 months ago
.login-tip {
font-size: 13px;
text-align: center;
color: #bfbfbf;
}
11 months ago
11 months ago
.login-code {
width: 33%;
height: 45px;
11 months ago
float: right;
img {
height: 100%;
11 months ago
width: 100%;
11 months ago
cursor: pointer;
vertical-align: middle;
11 months ago
border-radius: 4px;
11 months ago
}
}
.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>