<template> <div id="backlogin"> <div class="content"> <div class="page-content"> <div class="page-title"> <p>中国国家博物馆建党百年展</p> <p>点播院线服务平台</p> </div> <el-form id="form" :model="form" :rules="rules" ref="loginForm"> <el-form-item prop="username"> <el-input v-model="form.username" type="text" placeholder="请输入用户名" autofocus clearable > <i class="icon-username icon-prefix" slot="prefix"> </i> </el-input> </el-form-item> <el-form-item prop="password"> <el-input v-model="form.password" type="password" placeholder="请输入密码" autofocus clearable > <i class="icon-pwd icon-prefix" slot="prefix"> </i> </el-input> </el-form-item> <el-form-item> <el-button class="login" :disabled="flag" type="submit" @click="submitForm" > 登录 </el-button> </el-form-item> </el-form> </div> </div> </div> </template> <script> import { loginOut } from "@/config/loginOut"; export default { data() { return { form: { username: "", password: "", }, rules: { username: [ { required: true, message: "请输入用户名", trigger: "blur,change" }, ], password: [ { required: true, message: "请输入密码", trigger: "blur,change" }, ], }, flag: false, }; }, mounted() { loginOut(); }, methods: { submitForm() { let _this = this; this.$refs.loginForm.validate((valid) => { if (valid) { _this.flag = true; let requestParams = {}; requestParams.username = _this.form.username; requestParams.password = _this.form.password; let params = this.$qs.stringify(requestParams); _this .$https( { method: "post", url: "ajaxLogin", }, params ) .then((res) => { _this.flag = false; if (res.status == 200) { let resData = res.data; if (resData.resultCode == 200) { _this.$message({ type: "success", message: resData.message, }); localStorage.setItem("userType",resData.user.type) localStorage.setItem("user", resData.user.userName); localStorage.setItem("userId",resData.user.id) localStorage.setItem("backToken", resData.token); localStorage.setItem("roleList",resData.user.roleList) localStorage.setItem( "menuList", JSON.stringify(resData.menuList) ); if(_this.$route.query.redirect){ _this.$router.push(_this.$route.query.redirect); }else{ _this.$router.push("index"); } } else { _this.$message.error(res.data.message); } } else { _this.$message.error(res.data.message); } }) .catch((error) => { _this.$message.error(error.message); }); } else { this.flag = false; return false; } }); }, }, }; </script> <style lang="less" scoped> #backlogin { position: absolute; left: 0; top: 0; width: 100vw; height: 100vh; background: #9b1f23 url("~@/assets/login/login_bg.png") no-repeat center/ 100% 100%; .content { width: 33.33%; height: 100vh; background-color: @party-white; position: absolute; right: 13.5%; box-shadow: 0 0 20px 8px rgba(0, 0, 0, 0.2); &:before, &::after { display: inline-block; content: ""; width: 100%; height: auto; } &:before { height: 100px; background: url("~@/assets/login/login_top01.png") no-repeat center/ 100% 100%; } &:after { height: 130px; position: absolute; bottom: 0; left: 0; background: url("~@/assets/login/login_bt01.png") no-repeat center/ 100% 100%; } .page-content { position: absolute; top: 50%; left: 50%; margin-top: -50%; margin-left: -50%; width: 100%; } .page-title { width: 100%; margin-bottom: 60px; p { text-align: center; font-weight: bold; font-size: 44px; color: @font-color; letter-spacing: 0; text-align: center; line-height: 66px; margin: 0; padding: 0; } } .icon-prefix { display: inline-block; width: 24px; height: 24px; } .icon-username { background: url("~@/assets/login/user.png") no-repeat center/ 100%; } .icon-pwd { background: url("~@/assets/login/pwd.png") no-repeat center/ 100%; } /deep/.el-form { width: 100%; text-align: center; .el-form-item { margin-bottom: 60px; } .el-input { width: 320px; height: 48px; .el-input__inner { height: 48px; line-height: 48px; background-color: @party-bg-gray; border-color: @party-bg-gray; padding-left: 68px; font-size: 18px; } .el-input__prefix { left: 20px; padding-top: 12px; } } .el-form-item__error { left: calc(50% - 160px); } .el-button.login { width: 320px; height: 48px; background: #a4151d; border-radius: 4px; color: @party-white; margin-top: 20px; span { font-size: 18px; font-weight: bold; } &:hover { opacity: 0.8; } } } } } @media (min-width: 1301px) and (max-width: 1600px) { #backlogin .content { .page-title { margin-bottom: 50px; p { font-size: 30px; } } } } @media screen and (max-width: 1300px) { #backlogin .content { .page-title { margin-bottom: 30px; p { font-size: 24px; } } } } </style>