<style lang="less">
  @import './login.less';
</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>
          <!-- <p class="login-tip">输入任意用户名和密码即可</p> -->
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
import { $http } from '@/libs/http'
import { setToken } from '@/libs/util'
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ username, password }) {
      $http
        .postParams('/manager/login', {
          account: username,
          pwd: password
        })
        .then(data => {
          console.log(data)
          if (data.status === 200) {
            let token = data.data
            setToken(token)
            this.$Message.success('登录成功')
            this.$router.push({
              name: this.$config.homeName
            })
          } else {
            this.errorMsg = data.msg
          }
        })
        .catch(() => { })
    }
  }
}
</script>

<style>

</style>
