Login.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="login">
  3. <div class="login-par">
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
  5. <div class="login-logo">
  6. <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
  7. </div>
  8. <h3 class="title">工时管家</h3>
  9. <el-form-item class="login-input" prop="username">
  10. <el-input type="text" v-model="ruleForm.username" autocomplete="off" placeholder="账号" clearable prefix-icon="el-icon-user-solid"></el-input>
  11. </el-form-item>
  12. <el-form-item class="login-input" prop="password">
  13. <el-input type="password" v-model="ruleForm.password" @keyup.enter.native="handleSubmit" autocomplete="off" placeholder="密码" show-password prefix-icon="el-icon-lock"></el-input>
  14. </el-form-item>
  15. <el-form-item class="login-button" style="width:100%;">
  16. <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">登录</el-button>
  17. </el-form-item>
  18. </el-form>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. logining: false,
  27. // 登录信息
  28. ruleForm: {
  29. username: '',
  30. password: ''
  31. },
  32. rules: {
  33. username: [{ required: true, message: '请输入账号', trigger: 'blur' },],
  34. password: [{ required: true, message: '请输入密码', trigger: 'blur' },]
  35. }
  36. };
  37. },
  38. methods: {
  39. handleReset2() {
  40. this.$refs.ruleForm.resetFields();
  41. },
  42. handleSubmit(ev) {
  43. this.$refs.ruleForm.validate((valid) => {
  44. if (valid) {
  45. var _this = this;
  46. this.logining = true;
  47. this.http.post(this.port.manage.login, this.ruleForm , res => {
  48. this.logining = false;
  49. if (res.code == "ok") {
  50. sessionStorage.setItem('user', JSON.stringify(res.data));
  51. this.$router.push({ path: '/desktop' });
  52. } else {
  53. this.$message({
  54. message: res.msg,
  55. type: 'error'
  56. });
  57. }
  58. }, error => {
  59. this.logining = false;
  60. this.$message({
  61. message: error,
  62. type: 'error'
  63. });
  64. })
  65. }
  66. });
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .login {
  73. height: 100%;
  74. .login-par {
  75. width: 100%;
  76. min-height: 100%;
  77. background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
  78. background-size: 100%;
  79. padding: 110px 0 144px;
  80. position: relative;
  81. box-sizing: border-box;
  82. .login-logo {
  83. text-align: center;
  84. margin: 0 0 20px 0;
  85. }
  86. .login-container {
  87. -webkit-border-radius: 5px;
  88. border-radius: 5px;
  89. -moz-border-radius: 5px;
  90. background-clip: padding-box;
  91. width: 315px;
  92. height: 365px;
  93. padding: 25px 35px 25px 35px;
  94. background: #fff;
  95. border: 1px solid #eaeaea;
  96. box-shadow: 0 0 5px #cac6c6;
  97. border-top: 10px solid #20a0ff;
  98. margin:auto;
  99. .title {
  100. font-size: 20px;
  101. margin: 0px auto 40px auto;
  102. text-align: center;
  103. color: #505458;
  104. }
  105. .remember {
  106. margin: 0px 0px 35px 0px;
  107. }
  108. .login-input {
  109. margin: 30px 0 0 0;
  110. }
  111. .login-button {
  112. margin: 30px 0 0 0;
  113. }
  114. .login-button .el-button {
  115. padding: 14px;
  116. }
  117. }
  118. }
  119. }
  120. </style>