<template>
  <div class="login_content"></div>
</template>

<script>
export default {
  data() {
    return {
      userid: this.$route.query.userid,
      oid: this.$route.query.oid,
      org: this.$route.query.org,
    };
  },
  created() {
    this.login();
  },
  methods: {
    login() {
      let params = [
        {
          uid: this.userid,
          oid: this.oid,
          // sqlpassword: this.sqlPassword,
        },
      ];
      this.ajax
        .post(this.$store.state.api + "loginNewEvenManage", params)
        .then((res) => {
            var _this = this;
            // _this.$message({
            //   message: "登录成功",
            //   type: "success",
            // });

            _this.userInfo = res.data[0][0];
            _this.$cookies.set("tlogin", "1", -1);

            _this.$cookies.set("tuserid", _this.userInfo.userid, -1);
            _this.$cookies.set("teacherInfo", _this.userInfo, -1);
            // window.sessionStorage.setItem("login", true);
            // window.sessionStorage.setItem("userInfo", JSON.stringify(this.userInfo));
            _this.$store.commit("update", ["isLogin", true]);
            _this.$store.commit("update", ["userInfo", _this.userInfo]);
            _this.$router.push("/eventCenter?steps=" + "1");
            // if (res.data[0][0].type == 1 || res.data[0][0].type == 2) {
            //   this.$router.push("/eventCenter?steps=" + "1");
            // }
            //  else if (isU == 2 || isU == 4) {
            //   //市级账号 munAdmin
            //   this.$router.push("/score");
            // } else if (isU == 5 || isU == 6) {
            //   //区县账号 disAdmin
            //   this.$router.push("/score1");
            // } else if (isU == 3) {
            //   //省级账号 proAdmin
            //   this.$router.push("/anliList2");
            // } else if (isU == 0) {
            //   //admin账号
            //   this.$router.push("/eventCenter?steps=" + "1");
            // }
            // console.log(_this.$store.state);
        })
        .catch((err) => {
          // this.$message.error("登录失败");
          console.error(err);
        });

      //   sessionStorage.removeItem("key");
    },
  },
};
</script>

<style scoped>
.login_content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  /* position: absolute; */
  width: 100%;
}
</style>
