<template>
  <div id="login-2">
    <el-row>
      <el-col :span="24" class="main" :style="{ 'background-image': `url('${backimage}')` }">
        <div class="w_1200">
          <el-col :span="24" class="info">
            <el-col :span="24" class="info_1"> 欢迎登陆 </el-col>
            <el-col :span="24" class="info_2">
              <el-form :model="form" :rules="rules" ref="form">
                <el-form-item prop="account">
                  <el-input placeholder="请输入账号" v-model="form.account">
                    <el-button slot="prepend" icon="el-icon-user-solid"></el-button>
                  </el-input>
                </el-form-item>
                <el-form-item prop="password">
                  <el-input placeholder="密码" v-model="form.password" type="password">
                    <el-button slot="prepend" icon="el-icon-user-solid"></el-button>
                  </el-input>
                </el-form-item>
                <el-form-item class="btn">
                  <el-button type="primary" @click="toLogin('form')">登录</el-button>
                </el-form-item>
              </el-form>
              <el-col :span="24" class="info_3"> 输入任意用户名和密码即可 </el-col>
            </el-col>
          </el-col>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'login-2',
  props: {},
  components: {},
  data: function () {
    return {
      // 背景图片
      backimage: require('@/assets/login/login_3_1.png'),
      form: {},
      rules: {
        account: [{ required: true, message: '账号不能为空', trigger: 'blur' }],
        password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
        code: [{ required: true, message: '验证码不能为空', trigger: 'blur' }],
      },
    };
  },
  created() {},
  methods: {
    toLogin(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.$emit('toLogin', { data: this.form, formName: formName });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    toRegister() {
      this.$emit('toRegister');
    },
    toCode() {
      this.$emit('toCode');
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  background-size: 100% 100%;
  height: 100vh;
  background-repeat: no-repeat;
  overflow: hidden;

  .info {
    width: 300px;
    border-radius: 5px;
    background: #fff;
    font-size: 14px;
    margin: 20% 0 0 70%;
    .info_1 {
      border-bottom: 1px solid #e8eaec;
      padding: 14px 16px;
      line-height: 1;
    }
    .info_2 {
      padding: 16px;
      .btn {
        margin: 5% 0 0 0;
        text-align: center;
        button {
          width: 100%;
        }
      }
      .info_3 {
        font-size: 10px;
        text-align: center;
        color: #c3c3c3;
        margin: 16px 0 0 0;
      }
    }
  }
}
.el-input-group__append button.el-button,
.el-input-group__append div.el-select .el-input__inner,
.el-input-group__append div.el-select:hover .el-input__inner,
.el-input-group__prepend button.el-button,
.el-input-group__prepend div.el-select .el-input__inner,
.el-input-group__prepend div.el-select:hover .el-input__inner {
  border-color: transparent;
  background-color: transparent;
  color: inherit;
  border-top: 0;
  border-bottom: 0;
  width: 15px;
  padding: 0 13px;
}
</style>
