Login.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="login-par">
  3. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
  4. <div class="login-logo">
  5. <img src="../assets/image/login_logo.png" />
  6. </div>
  7. <h3 class="title">云塑网后台管理系统</h3>
  8. <el-form-item class="login-input" prop="account">
  9. <el-input type="text" v-model="ruleForm.account" autocomplete="off" placeholder="账号" clearable prefix-icon="el-icon-user-solid"></el-input>
  10. </el-form-item>
  11. <el-form-item class="login-input" prop="password">
  12. <el-input type="password" v-model="ruleForm.password" @keyup.enter.native="handleSubmit" autocomplete="off" placeholder="密码" show-password prefix-icon="el-icon-lock"></el-input>
  13. </el-form-item>
  14. <!-- <el-checkbox v-model="checked" checked class="remember">记住密码</el-checkbox> -->
  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 class="login-backImg">
  20. <img src="../assets/image/login_center.png" />
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. //import { requestLogin } from '../api/api';
  26. //import NProgress from 'nprogress'
  27. export default {
  28. data() {
  29. return {
  30. logining: false,
  31. // 登录信息
  32. ruleForm: {
  33. account: '',
  34. password: ''
  35. },
  36. rules: {
  37. account: [
  38. { required: true, message: '请输入账号', trigger: 'blur' },
  39. ],
  40. password: [
  41. { required: true, message: '请输入密码', trigger: 'blur' },
  42. ]
  43. }
  44. };
  45. },
  46. methods: {
  47. handleReset2() {
  48. this.$refs.ruleForm.resetFields();
  49. },
  50. handleSubmit(ev) {
  51. this.$refs.ruleForm.validate((valid) => {
  52. if (valid) {
  53. var _this = this;
  54. this.logining = true;
  55. this.http.post(this.port.manage.login, this.ruleForm , res => {
  56. this.logining = false;
  57. if (res.code == "ok") {
  58. sessionStorage.setItem('user', JSON.stringify(res.data));
  59. this.$router.push({ path: '/map' });
  60. } else {
  61. this.$message({
  62. message: res.msg,
  63. type: 'error'
  64. });
  65. }
  66. }, error => {
  67. this.logining = false;
  68. this.$message({
  69. message: error,
  70. type: 'error'
  71. });
  72. })
  73. }
  74. });
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .login-par {
  81. position: relative;
  82. }
  83. .login-logo {
  84. text-align: center;
  85. margin: 0 0 20px 0;
  86. }
  87. .login-container {
  88. /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
  89. -webkit-border-radius: 5px;
  90. border-radius: 5px;
  91. -moz-border-radius: 5px;
  92. background-clip: padding-box;
  93. margin: 180px auto;
  94. // width: 350px;
  95. width: 315px;
  96. height: 345px;
  97. // padding: 35px 35px 15px 35px;
  98. padding: 25px 35px 25px 35px;
  99. background: #fff;
  100. border: 1px solid #eaeaea;
  101. box-shadow: 0 0 25px #cac6c6;
  102. border-top: 10px solid #409EFF;
  103. .title {
  104. font-size: 20px;
  105. margin: 0px auto 40px auto;
  106. text-align: center;
  107. color: #505458;
  108. }
  109. .remember {
  110. margin: 0px 0px 35px 0px;
  111. }
  112. .login-input {
  113. margin: 30px 0 0 0;
  114. }
  115. .login-button {
  116. margin: 30px 0 0 0;
  117. }
  118. .login-button .el-button {
  119. padding: 14px;
  120. }
  121. }
  122. .login-backImg {
  123. position: absolute;
  124. width: 100%;
  125. height: 350px;
  126. background-color: #409EFF;
  127. top: 110px;
  128. z-index: -1;
  129. img {
  130. width: 100%;
  131. height: 100%;
  132. }
  133. }
  134. </style>