<template>
  <div></div>
</template>

<script>
  export default {
    name: "NoPwdLogin",
    data() {
      return {

        loginRules: {

        },
        loading: false,
        // 验证码开关
        captchaOnOff: true,
        // 注册开关
        register: false,
        redirect: undefined,
        userNoPswInfo:{
          loginid:"",
          token:""
        }
      };
    },
    watch: {
      $route: {
        handler: function(route) {
          console.log("路由："+route)
          this.redirect = route.query && route.query.redirect;
        },
        immediate: true
      }
    },
    created() {
      //平台单独的登录
      this.getLoginByNameAndTokenJ();
    },
    methods: {
      /**
       * 三方平台单点登陆
       * 只传递token
       */
      getLoginByNameAndTokenJ() {
        //获取地址栏中的用户名和密码  这里使用了地址传参，需要在oa系统那里自己配置
        var loginid = this.$route.query.loginid;
        var token = this.$route.query.token;

        //调用登录的接口
        if (loginid == '' || loginid == undefined || loginid == null || token == '' || token == undefined || token == null) {
          this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
        } else {
          this.loading = true;//开启过渡动画
          console.log("开启过渡动画")
          this.userNoPswInfo  = {
            loginid: loginid,
            token: token
          };

          this.$store.dispatch("NoPwdLogin", this.userNoPswInfo).then(() => {
            this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
          }).catch(() => {
            this.loading = false;
            this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
          });
        }
      }
    }
  };
</script>
<style rel="stylesheet/scss" lang="scss">

</style>
