<template>
  <div class="abc">
    <te-login
    :system="$theia.system"
    :error="error"
    mode="up"
    ref="login"
    @login="login"
  ></te-login>
  </div>

</template>

<script>
export default {
  data() {
    return {
      error: "",
      errs: { 901: "用户名密码错误", 902: "用户已锁定，暂时不能登录" },
    };
  },
  created(){
    this.$theia.system =  this.$theia.env.getSystemInfo();
  },

  mounted() {
    // this.$theia.http.post("/member/logout", {})
  },
  methods: {
    login(u, p) {
      let that = this;
      this.$theia.http
        .post("/member/login", { uname: u, pwd: this.$theia.crypto.md5(p) })
        .then(() => {
          that.$router.push("/#/file");
        })
        .catch((err) => {
          let msg = "";
          if (
            err.response &&
            err.response.data &&
            err.response.data.remain_count
          ) {
            msg = ",剩余" + err.response.data.remain_count + "次数";
          }
          that.$refs.login.error(
            (that.errs[err.response.status] || "用户名密码错误") + msg
          );
        });
    },
  },
};
</script>