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.

259 lines
6.8 KiB
Vue

<template>
<div class="login">
<div class="loginContain">
<div class="loginMain slideInDown">
<h3>用户登录</h3>
<div class="ms-login">
<el-form
:model="userInfo"
:rules="rules"
ref="loginForm"
label-width="0px"
class="ms-content"
size="medium"
>
<el-form-item prop="name">
<el-input v-model="userInfo.name" placeholder="用户名">
<span slot="prepend" class="el-icon-user"></span>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
type="password"
placeholder="密码"
show-password
v-model="userInfo.password"
@keyup.enter.native="submitForm()"
>
<span slot="prepend" class="el-icon-lock"></span>
</el-input>
</el-form-item>
<div class="login-btn">
<el-button type="primary" @click="submitForm()">登录</el-button>
</div>
</el-form>
</div>
</div>
</div>
<threejs></threejs>
</div>
</template>
<script>
import * as THREE from "three";
import threejs from "./threejs";
import { userloginApi } from "@/utils/api/index";
export default {
components: {
threejs,
},
data: function () {
return {
userInfo: {
name: "",
password: "",
},
rules: {
name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
password: [
{ required: true, message: "请输入密码", trigger: "blur" },
// { min: 6, max: 8, message: "请输入6-8位字符", trigger: "blur" },
],
},
token: "",
};
},
computed: {},
methods: {
submitForm() {
this.$refs.loginForm.validate((valid) => {
if (valid) {
console.log(this.userInfo);
// if (
// (this.userInfo.userName == "admin" &&
// this.userInfo.password == "shxy123456") ||
// (this.userInfo.userName == "cacuser" &&
// this.userInfo.password == "cac123456")
// ) {
// localStorage.setItem("token", "13747c96ff9f434cb09ecf78e4b9a8bc");
// this.$message({
// duration: 1500,
// showClose: true,
// message: "登录成功",
// type: "success",
// });
// this.$router.push("/");
// return;
// } else {
// this.$message({
// duration: 1500,
// showClose: true,
// message: "账号密码错误,请重新输入!",
// type: "warning",
// });
// return;
// }
//注释
userloginApi(this.userInfo)
.then((res) => {
if (res.success) {
console.log(res.data);
//this.$router.push("/weather");
this.$message({
duration: 1500,
showClose: true,
message: "登录成功",
type: "success",
});
this.$router.push("/home");
return;
} else {
this.$message({
duration: 1500,
showClose: true,
message: res.errorMsg,
type: "warning",
});
return;
}
})
.catch((err) => {});
} else {
this.$message.error("请输入账号和密码");
console.log("error submit!!");
return false;
}
});
},
getLogin() {},
},
created() {},
mounted() {},
};
</script>
<style lang="less">
.login {
background: url(../../assets/loginbg.jpg) top #060c41 no-repeat;
width: 100%;
height: 100%;
background-size: inherit;
position: fixed;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: column;
.loginContain {
display: flex;
justify-content: flex-end;
align-items: center;
flex-wrap: nowrap;
flex-direction: column;
margin: auto;
position: relative;
z-index: 1;
.loginMain {
background: url(../../assets/loginmain.png);
width: 35.9375rem /* 575/16 */;
height: 25.5rem /* 408/16 */ /* 490/16 */;
background-size: 100% 100%;
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: nowrap;
flex-direction: column;
visibility: visible;
position: relative;
animation: slideInDown 0.5s;
h3 {
font-size: 1.5rem /* 24/16 */ /* 18/16 */;
color: #fff;
margin-bottom: 1rem /* 16/16 */;
position: absolute;
top: -40px;
}
.ms-login {
height: 100%;
align-items: center;
justify-content: center;
display: flex;
.ms-content {
.el-input-group__append,
.el-input-group__prepend,
.el-input__inner {
border: 0.0625rem /* 1/16 */ solid #1479ad;
background: rgba(255, 255, 255, 0.1);
border-radius: 0.25rem 0 0 0.25rem /* 4/16 */ /* 4/16 */;
color: #fff;
}
.el-input__inner {
border: 0.0625rem /* 1/16 */ solid #1479ad;
background: rgba(255, 255, 255, 0.1);
border-radius: 0rem 00.25rem 0.25rem 0rem /* 4/16 */ /* 4/16 */;
color: #fff;
}
.el-form-item {
margin-bottom: 30px;
}
.login-btn {
text-align: center;
button {
width: 100%;
height: 36px;
margin-bottom: 10px;
}
}
}
}
}
.slideInDown {
animation-name: slideInDown;
}
}
.canvasGLTFBody {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
.canvasGLTF {
position: relative;
width: 100%;
height: 100%;
}
.LoadingInfo {
width: 100%;
height: 100%;
position: absolute;
background: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
color: #fff;
z-index: 1000000;
top: 0;
left: 0;
font-size: 0.10417rem;
display: none;
}
}
@keyframes slideInDown {
0% {
transform: translateY(-100%);
visibility: visible;
}
100% {
transform: translateY(0);
}
}
}
</style>