<template>
  <div class="login-container">
    <div class="all" style="">
      <div class="data-all" style="text-align:center;margin-top:50px;">
        <transition name="fade">
          <img
            src="static/images/login300.png"
            v-if="logImage"
            style="margin:48px auto;width:104px;height:104px;"
            alt=""
          />
          <img
            src="static/images/init.gif"
            v-if="!logImage"
            style="margin:0 auto;"
            alt=""
          />
        </transition>
        <div>管理执行难，就用功道云</div>
        <!-- <transition name="fade">
          <el-button class="refresh" type="primary" style="margin-top:10px" @click="LoginBut" v-show="loginButton">{{logButText}}</el-button>
        </transition>
        
        <el-button class="refresh" type="primary" style="margin-top:10px" @click="LoginBut1">123</el-button> -->
      </div>
    </div>
    <pastDue></pastDue>
  </div>
</template>

<script>
import pastDue from "@/views/common/pastDue.vue";
import { getToken, cookGetToken } from "@/utils/auth";
import { wxAuth } from "@/utils/wx-auth-two.js";
export default {
  data() {
    return { 
      logImage: true,
      logButText: "登录",
      loginButton: true
    };
  },
  components: { pastDue },
  watch: {},
  created() {
     console.log('登录页');
     console.log(cookGetToken());
    if (cookGetToken()) {
      this.$store.commit("SET_TOKEN", cookGetToken());
      localStorage.setItem(
        "Experience_data",
        JSON.stringify({ if: false, name: "" })
      );
      console.log(cookGetToken());
      this.detalext(1)
    }else{
      console.log('无Token')
      // window.location.href = process.env.BASE_API;//重新授权
    }
  },
  mounted() {},
  methods: {
    detalext(add){
      this.$http("get", process.env.BASE_API + "/api/employee/detail").then(
        res => {
          if (res.data.code == 1) {
            if(res.data.data.user.is_official == 0){
              this.$router.push({
                path: '/noAccess',
                query: {
                  msg: '当前用户未授权进入系统，请联系管理员为您【启用积分管理】，<br/>如需咨询客服，请到您企业专属的功道云服务群咨询'
                }
              })
            }else if(add == 1){
              localStorage.removeItem('SET_EMPLOYEE_MAP')
              localStorage.removeItem('dept_tree')
              localStorage.removeItem('site_info')
              wxAuth(true);
            }
          }
        }
      );
    },
  },
  destroyed() {
    localStorage.setItem("login_code", "0");
  }
};
</script>

<style rel="stylesheet/css" type="text/css" scoped>
.all {
  /* width: 1000px; */
  /* height: 675px; */
  margin: 0 auto;
  position: relative;
  top: 50%;
  margin-top: -325px;
}
</style>
