<template>
</template>

<script>
  export default {
    data() {
      return {
      }
    },
    methods: {
      //获取登录方式
      ssoLogin:function(){
        var formData = new FormData();
        let uas_st = this.$util.getUrlKey("uas_st",window.location.href);
        console.log(uas_st);
        formData.append("uas_st", uas_st);
        this.$fetch.ssoLogin(formData).then((resp) => {
          console.log(resp);
          if (resp.data.returnCode == "0") {
              var menus = resp.data.data.menuTree,
                children = (menus && menus.children) || [],
                path = "";
              this.$store.commit("menus", menus);
              sessionStorage.setItem("menus", JSON.stringify(resp.data.data.menuTree));
              sessionStorage.setItem("userName", resp.data.data.userName);
              sessionStorage.setItem("depart", JSON.stringify(resp.data.data.depart));
              sessionStorage.setItem("userId", JSON.stringify(resp.data.data.userId));
              sessionStorage.setItem("ruleCodes",JSON.stringify(resp.data.data.buttonAuth));
              sessionStorage.setItem("loginSource",JSON.stringify(resp.data.data.loginSource));
              this.$fetch.setAuthorization(resp.data.data.authorization);

              if(children.length){
                path = children[0].children[0].route
                this.$router.push({
                  path: path
                })
              }else{
                sessionStorage.setItem("authorization","");
                this.$message.warning("没有权限访问其它页面！ 请联系管理员");
              }
            }
      }, (error) => {
          this.$message.error("登录类型获取失败：" + error);
        });
      },
    },
    
    created: function() {
      this.ssoLogin();
    },
  }
</script>

