<template>
  <div class="login">
    <div class="login-border">
      <p class="login-text">欢迎登录</p>
      <div class="login-content">
        <p class="login-content-text">登录</p>
        <div class="login-input">
          <input class="input user" type="text" v-model="user" placeholder="请输入用户名"/>
          <input class="input user" type="password" v-model="password" @keyup.enter="login" placeholder="请输入密码"/>
          <button class="button" @click="login">登录</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
    data () {
        return {
            user: '',
            password: ''
        }
    },
    created() {
    },
    mounted(){
    },
    methods: {
        // 登录
        login() {
            if (!this.user || !this.password) {
                this.$message.error('用户名和密码不能为空！');
                return;
            }
            let data = {
                userName: this.user,
                password: this.password
            }
            this.$server.postUserLogin(data).then(res => {
                if (res.data.code === 200) {
                    this.$store.commit('changeUserData', res.data.data);
                    this.$router.push({name: 'XCalliance'})
                } else {
                    this.$message.error(res.data.msg);
                }
            }).catch(err => {
                this.$message.error('用户登录失败');
            })
        }
    },
    components: {
    },
    watch: {
    }
}
</script>
<style scoped>
  .login{
    width: 100%;
    height: 100%;
    background-image: url("./img/login-bg.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    -moz-background-size: 100% 100%;
  }
  .login-border{
    width: 664px;
    height: 531px;
    background-image: url("./img/login-border.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    -moz-background-size: 100% 100%;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -332px;
    margin-top: -265px;
    color: #ffffff;
  }
  .login-text{
    font-size: 24px;
    font-weight: bold;
    position: absolute;
    left: 15%;
    top: 42%;
  }
  .login-content-text{
    color: #333333;
    font-size: 32px;
    font-weight: bold;
  }
  .login-content{
    position: absolute;
    width: 250px;
    text-align: left;
    top: 22%;
    right: 74px;
  }
  .login-input{
    margin-top: 12px;
  }
  .button{
    width: 160px;
    height: 40px;
    background-color: #4877e6;
    border-radius: 4px;
    border: none;
    font-size: 20px;
    color: #ffffff;
    cursor: pointer;
    margin-top: 40px;
  }
  .button:hover{
    background: rgba(72,119,230,.6);
  }
  .input{
    width: 208px;
    height: 36px;
    border: none;
    padding-left: 12px;
    border-bottom: 1px solid #cccccc;
    background-color: rgba(0,0,0,0);
    font-size: 18px;
    margin-top: 32px;
  }
  .login .login-border .login-content>>>.el-input--medium .el-input__inner{
    width: 208px;
  }
  .login .login-border .login-content>>>.el-input{
    margin-top: 32px;
  }
</style>
