<style lang="less">
  @import './login.less';
  @media screen and (max-width: 901px) {
    .login{
      position: fixed;
      justify-content:center;
    }
    .login-con {
      width: 100%;
      right:0;
    }
  }
</style>

<template>
  <div class="login">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ userName, password }) {
      this.handleLogin({ userName, password })
        .then(res => {
          if (res === 200) {
            this.getUserInfo().then(res => {
              this.$router.push({
                name: this.$config.homeName
              })
            })
          } else {
            this.$Message.error('用户名或密码错误')
          }
        })
    }
  }
}
</script>

<style>

</style>
