LoginPage.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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: 'super_admin',
  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. if (this.password == 'habook') {
  75. this.$router.push({ path: '/main' });
  76. } else {
  77. this.$router.push({ path: '/main' });
  78. }
  79. }
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .login {
  87. background-image: url('../../assets/image/login_bg.jpg');
  88. width: 100%;
  89. height: 100%;
  90. background-size: cover;
  91. display: flex;
  92. flex-direction: row;
  93. align-items: center;
  94. justify-content: center;
  95. }
  96. .login:after {
  97. content: "";
  98. width: 100%;
  99. height: 100%;
  100. position: absolute;
  101. left: 0;
  102. top: 0;
  103. background: inherit;
  104. filter: blur(4px);
  105. z-index: 1;
  106. }
  107. .drag {
  108. position: absolute;
  109. text-align: center;
  110. z-index: 11;
  111. border-radius: 5px;
  112. box-shadow: 0 0 10px 6px rgba(0,0,0,.5);
  113. width: 90%;
  114. max-width: 350px;
  115. }
  116. .login-tip {
  117. color: white;
  118. }
  119. .drag >>> .ivu-card-head p span {
  120. color: white;
  121. font-size: 18px;
  122. }
  123. .login-card {
  124. background: none;
  125. color: white;
  126. width: 100%;
  127. }
  128. </style>