<template>
  <div id="login">
    <el-row>
      <el-col :span="24" class="login" :style="'background: url(' + loginBei + ')no-repeat center center;'">
        <el-col :span="12" class="info">
          <el-col :span="24" class="topTitle">
            <p>吉企银通管理后台</p>
<!--            <p>综合服务管理平台</p>-->
          </el-col>
          <el-col :span="24" class="kuang" :style="'background: url(' + kuang + ')no-repeat center center;'">
            <el-form ref="form" :model="form">
              <el-form-item>
                <el-input placeholder="请输入手机号" prefix-icon="el-icon-user" v-model="form.phone"> </el-input>
              </el-form-item>
              <el-form-item>
                <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="form.passwd" show-password> </el-input>
              </el-form-item>
              <el-row class="btn">
                <el-button @click="onSubmit">登录</el-button>
              </el-row>
            </el-form>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: login } = createNamespacedHelpers('login');
const jwt = require('jsonwebtoken');
export default {
  name: 'login',
  props: {},
  components: {},
  data: () => ({
    loginBei: require('@/assets/back.png'),
    kuang: require('@/assets/框.png'),
    form: {},
  }),
  created() {},
  computed: {},
  methods: {
    ...login(['create']),
    async onSubmit() {
      this.form.type = '0';
      let data = this.form;
      console.log(data);
      const result = await this.create(data);
      this.$message({
        type: `${result.errcode}` === '0' ? 'success' : 'error',
        message: `${result.errcode}` === '0' ? '登录成功' : result.errmsg,
      });
      if (`${result.errcode}` === '0') {
        sessionStorage.setItem('token', result.data);
        this.$router.push({ path: '/' });
      }
    },
  },
};
</script>

<style lang="less" scoped>
p {
  padding: 0;
  margin: 0;
}
.login {
  height: 100vh;
}
.topTitle {
  position: absolute;
  top: 340px;
}
.topTitle p {
  text-align: center;
  font-size: 30px;
  font-family: Source Han Sans CN;
  font-weight: bold;
  color: rgba(255, 255, 255, 1);
}
.kuang {
  width: 411px;
  height: 290px;
  position: absolute;
  top: 420px;
  left: 39%;
  padding: 77px 56px;
}
/deep/.el-input__inner {
  border-radius: 20px;
}
.btn .el-button {
  width: 300px;
  height: 40px;
  background: rgba(233, 2, 29, 1);
  border-radius: 20px;
  border: none;
  color: #fff;
}
</style>
