Login.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="login-wrap">
  3. <div class="ms-login">
  4. <div class="ms-title">后台管理系统</div>
  5. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="ms-content">
  6. <el-form-item prop="username">
  7. <el-input v-model="ruleForm.username" placeholder="username">
  8. <el-button slot="prepend" icon="el-icon-lx-people"></el-button>
  9. </el-input>
  10. </el-form-item>
  11. <el-form-item prop="password">
  12. <el-input type="password" placeholder="password" v-model="ruleForm.password" @keyup.enter.native="submitForm('ruleForm')">
  13. <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
  14. </el-input>
  15. </el-form-item>
  16. <div class="login-btn">
  17. <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
  18. </div>
  19. <p class="login-tips">Tips : 用户名和密码随便填。</p>
  20. </el-form>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. data: function(){
  27. return {
  28. ruleForm: {
  29. username: 'admin',
  30. password: '123123'
  31. },
  32. rules: {
  33. username: [
  34. { required: true, message: '请输入用户名', trigger: 'blur' }
  35. ],
  36. password: [
  37. { required: true, message: '请输入密码', trigger: 'blur' }
  38. ]
  39. }
  40. }
  41. },
  42. methods: {
  43. submitForm(formName) {
  44. this.$refs[formName].validate((valid) => {
  45. if (valid) {
  46. localStorage.setItem('ms_username',this.ruleForm.username);
  47. this.$router.push('/');
  48. } else {
  49. console.log('error submit!!');
  50. return false;
  51. }
  52. });
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .login-wrap{
  59. position: relative;
  60. width:100%;
  61. height:100%;
  62. background-image: url(../../assets/img/login-bg.jpg);
  63. background-size: 100%;
  64. }
  65. .ms-title{
  66. width:100%;
  67. line-height: 50px;
  68. text-align: center;
  69. font-size:20px;
  70. color: #fff;
  71. border-bottom: 1px solid #ddd;
  72. }
  73. .ms-login{
  74. position: absolute;
  75. left:50%;
  76. top:50%;
  77. width:350px;
  78. margin:-190px 0 0 -175px;
  79. border-radius: 5px;
  80. background: rgba(255,255,255, 0.3);
  81. overflow: hidden;
  82. }
  83. .ms-content{
  84. padding: 30px 30px;
  85. }
  86. .login-btn{
  87. text-align: center;
  88. }
  89. .login-btn button{
  90. width:100%;
  91. height:36px;
  92. margin-bottom: 10px;
  93. }
  94. .login-tips{
  95. font-size:12px;
  96. line-height:30px;
  97. color:#fff;
  98. }
  99. </style>