<style lang="less">
  @import './login.less';
</style>
<template>
  <div class="login">
    <img src="../../assets/images/login-bg.jpg"  alt="null">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
          <p class="error">{{error.name}}</p>
          <p class="error">{{error.password}}</p>
          <p class="login-tip">输入任意用户名和密码即可</p>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
  import LoginForm from '../../components/login-form'
  import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  data(){
    return{
      error:'',
    }
  },

  methods: {
    ...mapActions([
      'handleLogin',
    ]),
    handleSubmit ({ userName, password }) {
      this.handleLogin({ userName, password }).then(res => {
        // this.getUserInfo().then(res => {
          this.$router.push({
            name: this.$config.homeName
          })
        // })
      }).catch( err =>{
        this.error = err
      })
    }
  }
}
</script>
<style>
</style>
