<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false" style="border-radius:0px">
           <p slot="title" @click.prevent="ispasslogin=true">
            <a href="#" >密码登录</a>
        </p>
        <p   slot="extra" @click.prevent="ispasslogin=false">
            <a href="#"> 验证码登录</a>
        </p>
        <div class="form-con">
          <login-form    v-if="ispasslogin" @on-success-valid="handleSubmit"></login-form>
          <MobileForm v-if="!ispasslogin" @on-success-valid="handleSubmit"></MobileForm>
          <p class="login-tip">注册</p>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import MobileForm from '_c/phone-form'
import { mapActions } from 'vuex'
export default {
  data(){
    return{
      ispasslogin:true
    }
  },
  components: {
    LoginForm,
    MobileForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ userName, password }) {
      this.handleLogin({ userName, password }).then(res => {
         this.$router.push({
            name: this.$config.homeName
        })
      }).catch(err=>{
            this.$Notice.error({
                    title: '系统通知',
                    desc:  '账号或密码有误！'
                });
      })
    }
  }
}
</script>

<style>

</style>
