You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/views/Login.vue

146 lines
3.8 KiB
Vue

2 years ago
<template>
<div class="login-wrap">
<div class="ms-login">
2 years ago
<div class="ms-title">
<img src="../assets/img/logo.png" alt="欣影" />
<h3>可视化智能管控系统</h3>
</div>
<el-form
2 years ago
:model="userInfo"
:rules="rules"
2 years ago
ref="loginForm"
label-width="0px"
class="ms-content"
2 years ago
size="medium"
>
<el-form-item prop="username">
2 years ago
<el-input v-model="userInfo.username" placeholder="用户名">
<el-button slot="prepend" icon="el-icon-user"></el-button>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
type="password"
2 years ago
placeholder="密码"
show-password
v-model="userInfo.password"
@keyup.enter.native="submitForm()"
>
2 years ago
<el-button slot="prepend" icon="el-icon-lock"></el-button>
</el-input>
</el-form-item>
<div class="login-btn">
<el-button type="primary" @click="submitForm()"></el-button>
2 years ago
</div>
2 years ago
<!-- <p class="login-tips">Tips : 用户名和密码随便填</p> -->
</el-form>
2 years ago
</div>
</div>
2 years ago
</template>
<script>
import { mapMutations } from "vuex";
2 years ago
import { login } from "@/utils/api/index";
2 years ago
export default {
data: function () {
return {
2 years ago
userInfo: {
username: "xytest",
password: "123456",
},
rules: {
username: [
{ required: true, message: "请输入用户名", trigger: "blur" },
],
password: [{ required: true, message: "请输入密码", trigger: "blur" }],
},
2 years ago
token: "",
};
},
computed: {
2 years ago
...mapMutations(["setColorTheme"]),
},
methods: {
submitForm() {
2 years ago
this.$refs.loginForm.validate((valid) => {
if (valid) {
2 years ago
console.log(valid);
//this.userInfo.password = this.$md5(this.userInfo.password); //密码加密
this.token = this.$md5(this.userInfo.password); //获取token
this.$store.commit("SET_TOKEN", this.token); //将token保存在vuex中
this.$store.commit("SET_USERINFO", this.userInfo.username); //将用户信息保存在vuex中
this.$router.push("/");
2 years ago
this.$message.success("登录成功");
} else {
this.$message.error("请输入账号和密码");
console.log("error submit!!");
return false;
2 years ago
}
});
2 years ago
},
getLogin() {},
},
2 years ago
created() {},
2 years ago
};
</script>
<style lang="less">
2 years ago
.login-wrap {
position: relative;
width: 100%;
height: 100%;
2 years ago
background: url(../assets/img/loginbg.jpeg) no-repeat center center;
background-size: cover;
.ms-login {
2 years ago
position: absolute;
2 years ago
width: 420px;
height: 454px;
2 years ago
left: 50%;
top: 50%;
2 years ago
transform: translate(-50%;-50%);
2 years ago
border-radius: 5px;
2 years ago
background: url(../assets/img/loginBackImage.8b77ab2c.png) no-repeat;
// -webkit-backdrop-filter: blur(5px);
// backdrop-filter: blur(15px);
2 years ago
overflow: hidden;
2 years ago
background-size: 100%;
.ms-title {
text-align: center;
border-bottom: 1px solid @border-color-base;
2 years ago
padding: 40px 16px;
img {
margin-bottom: 8px;
width: 160px;
}
h3 {
font-size: 30px;
background: linear-gradient(0deg, #86b7ff, #4293fd 99.46289%);
background-clip: text;
-webkit-text-fill-color: transparent;
// font-weight: normal;
}
}
.ms-content {
2 years ago
padding: 40px 40px;
.el-form-item {
margin-bottom: 30px;
}
.login-btn {
text-align: center;
button {
width: 100%;
height: 36px;
margin-bottom: 10px;
}
}
}
2 years ago
// .login-tips {
// font-size: 12px;
// line-height: 30px;
// color: @color-white;
// }
}
2 years ago
}
</style>