<style>
  .Autologin{
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    /* transform: translate(-50%,-50%); */
    background: url('../assets/img/login/load.gif')no-repeat center;
    background-size: 350px auto;
  }
</style>
<template>
  <div>
    <div class="Autologin">
      
      <div class="gifContent">
       
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        loading: false,
        msg:{},
        userInfo: {
          name: "",
          password: "",
          Domain: ""
        },
        erpOrderObj:{},
        obj:{}
      }
    },
    components: {
      
    },
    mounted() {
    },
    created() {
      if(this.$route.query){
        let param = JSON.parse(this.$route.query.data) ;
        this.obj.token=this.$route.query.token;
        if(param){
          this.obj.parameter=param[0]
          localStorage.erpuserInfo = JSON.stringify(this.obj);
        }
      }
      if(!this.getLocalStorage()){
        this.autoLogin()
      }else{
        var data = JSON.parse(localStorage.erpuserInfo)
        this.$router.push({
          path: data.parameter.path,
          query:{
            erpOrderObj: JSON.stringify(data.parameter),
          }
        });
      }
    },
    methods: {
      autoLogin(){
        this.apipostLogin("/api/AutoLogin/CRMAutoLogin", this.msg, (res) => {
          var jsonData = res.data;
          if (jsonData.resultCode == 1) {
            var userData = jsonData.data;
            var userJson = JSON.stringify(userData);
            localStorage.userInfo = userJson;
            this.loginState = 0;
            var data = JSON.parse(localStorage.erpuserInfo)
            this.$router.push({
              path: data.parameter.path,
              query:{
                erpOrderObj: JSON.stringify(data.parameter),
              }
            });
          } else {
            this.$message({
              message: res.data.message,
              type: "error",
            });
            this.loginState = 0;
          }
        });
      }
    },
    
  }

</script>
