<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">
              <h2>{{ siteInfo.zhTitle }}</h2>
            </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-input>
                </el-form-item>
                <el-form-item prop="password">
                  <el-input placeholder="密码" v-model="form.password" type="password" show-password> </el-input>
                </el-form-item>
                <el-col :span="24">
                  <el-switch v-model="value" active-text="记住密码" active-color="#555" inactive-color="#ccc"> </el-switch>
                </el-col>
                <el-col :span="24" class="btn">
                  <el-form-item class="btn">
                    <el-button type="primary" @click="toLogin('form')">登录</el-button>
                  </el-form-item>
                </el-col>
              </el-form>
            </el-col>
            <el-col :span="24" class="info_3" @click.native="toRegister()">立即注册 </el-col>
          </el-col>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { siteInfo } from '@common/src/layout/site';

import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'login-2',
  props: {},
  components: {},
  data: function () {
    return {
      siteInfo: siteInfo,
      // 背景图片
      backimage: require('@/assets/login/login_4_1.png'),
      form: {},
      rules: {
        account: [{ required: true, message: '账号不能为空', trigger: 'blur' }],
        password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
        code: [{ required: true, message: '验证码不能为空', trigger: 'blur' }],
      },
      value: true,
    };
  },
  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 {
    flex: 0 0 auto;
    width: 33.333333%;
    border-radius: 5px;
    font-size: 14px;
    margin: 15% 30%;
    background: #fff;
    padding: 16px;
    .info_1 {
      border-radius: 5px;
      background: #e32f6e;
      margin: -20% 0 8% 0;
      padding: 16px;
      color: #fff;
      text-align: center;
    }
    .info_2 {
      .btn {
        margin: 5% 0 0 0;
        text-align: center;
        button {
          width: 100%;
          background: #e32f6e;
          border: #e32f6e;
        }
      }
    }
    .info_3 {
      margin: 20px 0 10px 0;
      color: #e32f6e;
      font-size: 14px;
      text-align: center;
    }
    .info_3:hover {
      cursor: pointer;
    }
  }
}
/deep/.el-switch__label {
  color: #7b809a;
}
/deep/.el-switch__label.is-active {
  color: #7b809a;
}
</style>
