<template>
  <div class="box">
    <div class="login">
      <p class="text">登录</p>
      <div class="from">
        <el-form ref="form" :model="form">
          <el-form-item label="">
            <el-input v-model="form.account" placeholder="账号"></el-input>
          </el-form-item>
          <el-form-item label="">
            <el-input
              v-model="form.password"
              placeholder="密码"
              show-password
            ></el-input>
          </el-form-item>
        </el-form>
        <el-button v-loading="loading" element-loading-text="登录中..." type="primary" @click="login"
          >立即登录</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { login } from "../../api/login";
export default {
  data() {
    return {
      loading: false,
      form: { account: "", password: "" },
    };
  },
  methods: {
    login() {
      this.loading = true
      login(this.form.account, this.form.password).then((res) => {
        if (res.data.code == 200) {
          // console.log(res);
          // localStorage.setItem("X-Token", res.data.msg);
          localStorage.setItem("areaName",res.data.userInfo.areaENName);
          localStorage.setItem("X-Token", res.data.token);
          this.$message.success("登录成功");
          this.loading = false
          this.$router.push("/layout");
        }
      });
    },
  },
};
</script>

<style scoped>
.box {
  width: 100%;
  height: 100%;
  background-image: url("../../img/bg.png");
  background-size: 100% 100%;
  position: relative;
}
.login {
  box-sizing: border-box;
  width: 470px;
  height: 370px;
  background-image: url("../../img/border.png");
  background-size: 100% 100%;
  position: absolute;
  top: 33%;
  right: 13%;
  padding: 40px 80px;
}
.text {
  color: #2fefff;
  font-size: 24px;
  font-weight: 600;
}
.from {
  margin-top: 20px;
}
::v-deep .from .el-input__inner::placeholder {
  color: #1985b5;
}
::v-deep.from .el-input__inner {
  background-color: transparent !important;
  border: none;
  color: #fff !important;
  border-radius: 0;
  border-bottom: 1px solid #01cfe9;
}
::v-deep.from .el-button--primary {
  width: 100%;
  color: #fff;
  background-color: #00edff;
  border-color: #00edff;
}
</style>