

<script>
import { getCodeImg } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'

export default {
  name: "Login",
  data() {
    return {
      codeUrl: "",
      cookiePassword: "",
      gwToken:"",
      loginForm: {
        username: "demo",
        password: "123456",
        rememberMe: false,
        code: "",
        uuid: ""
      },
      loginRules: {

      },
      loading: false,
      redirect: undefined
    };
  },
  watch: {
    $route: {
      handler: function(route) {
        this.redirect = route.query && route.query.redirect;
      },
      immediate: true
    }
  },
  created() {
     this.tiaozuan();
    // this.getCookie();
    // this.getCode();
  },
  methods: {
    tiaozuan(){
      console.log(this.gwToken)
      if(this.gwToken == "" || this.gwToken ==null){

        var ssa = window.location.host
        setTimeout(function (){
         if(ssa =='localhost:1024'){
           window.location.href='http://sso.jxhh.com/login?redirect=http://'+ssa+'/platformlogin'
         }else{
          window.location.href='http://sso.jxhh.com/login?redirect=http://'+ssa+'/platformlogin'
         }
        }, 1000)
       }
    },
    // getCode() {
    //   getCodeImg().then(res => {
    //     this.codeUrl = res.data.base64stringC;
    //     this.loginForm.uuid = res.data.idKeyC;
    //   });
    // },
    // getCookie() {
    //   this.gwToken=this.$store.state.token
    //   if(this.gwToken == null){
    //     this.tiaozuan();
    //   }
    //   console.log("this.gwToken",this.gwToken)
    // },
    // handleLogin() {
    //   this.$refs.loginForm.validate(valid => {
    //     if (valid) {

    //       this.loading = true;
    //       if (this.loginForm.rememberMe) {
    //         Cookies.set("username", this.loginForm.username, { expires: 30 });
    //         Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
    //         Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
    //       } else {
    //         Cookies.remove("username");
    //         Cookies.remove("password");
    //         Cookies.remove('rememberMe');
    //       }
    //       this.$store
    //         .dispatch("Login", this.loginForm)
    //         .then(() => {
    //           this.$router.push({ path: this.redirect || "/" });
    //         })
    //         .catch(() => {
    //           this.loading = false;
    //           this.getCode();
    //         });
    //     }
    //   });
    // }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../assets/image/login-background.jpg");
  background-size: cover;
}
.title {
  margin: 0px auto 30px auto;
  text-align: center;
  color: #707070;
}

.login-form {
  border-radius: 6px;
  background: #ffffff;
  width: 400px;
  padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.login-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.login-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
    width:120px;
  }
}
.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
</style>
