114 lines
4.3 KiB
HTML
114 lines
4.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 - WeChatRobot管理后台</title>
|
|
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
|
|
background-color: #f5f7fa;
|
|
height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
.login-container {
|
|
width: 400px;
|
|
padding: 30px;
|
|
background-color: #fff;
|
|
border-radius: 4px;
|
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
}
|
|
.login-title {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
color: #409EFF;
|
|
}
|
|
.login-form {
|
|
margin-top: 20px;
|
|
}
|
|
.login-button {
|
|
width: 100%;
|
|
margin-top: 20px;
|
|
}
|
|
.error-message {
|
|
color: #F56C6C;
|
|
margin-top: 10px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="app" class="login-container">
|
|
<h2 class="login-title">WeChatRobot管理后台</h2>
|
|
<el-form class="login-form" :model="loginForm" :rules="loginRules" ref="loginForm">
|
|
<el-form-item prop="username">
|
|
<el-input v-model="loginForm.username" placeholder="用户名" prefix-icon="el-icon-user"></el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="password">
|
|
<el-input v-model="loginForm.password" placeholder="密码" prefix-icon="el-icon-lock" show-password></el-input>
|
|
</el-form-item>
|
|
<el-button type="primary" class="login-button" @click="submitForm('loginForm')">登录</el-button>
|
|
<div class="error-message" v-if="errorMessage">{{ errorMessage }}</div>
|
|
</el-form>
|
|
</div>
|
|
|
|
<script src="https://unpkg.com/vue/dist/vue.js"></script>
|
|
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
|
|
<script>
|
|
new Vue({
|
|
el: '#app',
|
|
data() {
|
|
return {
|
|
loginForm: {
|
|
username: '',
|
|
password: ''
|
|
},
|
|
loginRules: {
|
|
username: [
|
|
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
|
],
|
|
password: [
|
|
{ required: true, message: '请输入密码', trigger: 'blur' }
|
|
]
|
|
},
|
|
errorMessage: '{{ error }}'
|
|
};
|
|
},
|
|
methods: {
|
|
submitForm(formName) {
|
|
this.$refs[formName].validate((valid) => {
|
|
if (valid) {
|
|
// 创建表单并提交
|
|
const form = document.createElement('form');
|
|
form.method = 'POST';
|
|
form.action = '/login';
|
|
|
|
const usernameInput = document.createElement('input');
|
|
usernameInput.type = 'hidden';
|
|
usernameInput.name = 'username';
|
|
usernameInput.value = this.loginForm.username;
|
|
form.appendChild(usernameInput);
|
|
|
|
const passwordInput = document.createElement('input');
|
|
passwordInput.type = 'hidden';
|
|
passwordInput.name = 'password';
|
|
passwordInput.value = this.loginForm.password;
|
|
form.appendChild(passwordInput);
|
|
|
|
document.body.appendChild(form);
|
|
form.submit();
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |