LoginPage.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="login">
  3. <div class="drag">
  4. <div style="background:rgba(255,255,255,0.1); border-radius:5px;">
  5. <Card icon="log-in" title="欢迎登录" :bordered="false" class="login-card">
  6. <div class="form-con">
  7. <Form ref="loginForm" :model="form" :rules="rules" @keydown.enter.native="handleSubmit">
  8. <FormItem prop="userName">
  9. <Input v-model="form.userName" placeholder="请输入用户名">
  10. <span slot="prepend">
  11. <Icon :size="16" type="ios-person"></Icon>
  12. </span>
  13. </Input>
  14. </FormItem>
  15. <FormItem prop="password">
  16. <Input type="password" v-model="form.password" placeholder="请输入密码">
  17. <span slot="prepend">
  18. <Icon :size="14" type="md-lock"></Icon>
  19. </span>
  20. </Input>
  21. </FormItem>
  22. <FormItem>
  23. <Button @click="handleSubmit" type="primary" long>登录</Button>
  24. </FormItem>
  25. </Form>
  26. <!--<p class="login-tip">输入任意用户名和密码即可</p>-->
  27. </div>
  28. </Card>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'LoginForm',
  36. props: {
  37. userNameRules: {
  38. type: Array,
  39. default: () => {
  40. return [
  41. { required: true, message: '账号不能为空', trigger: 'blur' }
  42. ]
  43. }
  44. },
  45. passwordRules: {
  46. type: Array,
  47. default: () => {
  48. return [
  49. { required: true, message: '密码不能为空', trigger: 'blur' }
  50. ]
  51. }
  52. }
  53. },
  54. data() {
  55. return {
  56. form: {
  57. userName: '',
  58. password: ''
  59. }
  60. }
  61. },
  62. computed: {
  63. rules() {
  64. return {
  65. userName: this.userNameRules,
  66. password: this.passwordRules
  67. }
  68. }
  69. },
  70. methods: {
  71. handleSubmit() {
  72. this.$refs.loginForm.validate((valid) => {
  73. if (valid) {
  74. localStorage.setItem("userName", this.form.userName);
  75. localStorage.setItem("isLogin", 1);
  76. if (this.password == 'habook') {
  77. this.$router.push({ path: '/main' });
  78. } else {
  79. this.$router.push({ path: '/main' });
  80. }
  81. }
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped>
  88. .login {
  89. background-image: url('../../assets/image/login_bg.jpg');
  90. width: 100%;
  91. height: 100%;
  92. background-size: cover;
  93. display: flex;
  94. flex-direction: row;
  95. align-items: center;
  96. justify-content: center;
  97. }
  98. .login:after {
  99. content: "";
  100. width: 100%;
  101. height: 100%;
  102. position: absolute;
  103. left: 0;
  104. top: 0;
  105. background: inherit;
  106. filter: blur(4px);
  107. z-index: 1;
  108. }
  109. .drag {
  110. position: absolute;
  111. text-align: center;
  112. z-index: 11;
  113. border-radius: 5px;
  114. box-shadow: 0 0 10px 6px rgba(0,0,0,.5);
  115. width: 90%;
  116. max-width: 350px;
  117. }
  118. .login-tip {
  119. color: white;
  120. }
  121. .drag >>> .ivu-card-head p span {
  122. color: white;
  123. font-size: 18px;
  124. }
  125. .login-card {
  126. background: none;
  127. color: white;
  128. width: 100%;
  129. }
  130. </style>