<template>
  <div class="login-box-parent">
    <div class="all" style="">
      <div class="data-all" style="text-align:center;margin-top:50px;">
        <transition name="fade"><img src="static/images/init.gif" style="margin:0 auto;" alt="" /></transition>
        <div>管理执行难，就用功道云</div>
      </div>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request';
import { getToken, setToken, cookGetToken } from '@/utils/auth';
import { wxAuth } from '@/utils/wx-auth-two.js';

export default {
  name: 'login',
  data() {
    return {
      logImage: true,
      loginButton: true
    };
  },
  created() {
    console.log('进入登录页');
    if (cookGetToken()) {
      setToken(cookGetToken());
      this.detailAxiox(1);
    } else {
      window.location.href = process.env.BASE_API; //重新授权
    }
  },
  methods: {
    detailAxiox(add) {
      request('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) {
            this.$store.commit('SET_USERINFO', res.data.data.user); // 设置员工信息
            window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']));
            window.sessionStorage.setItem('routers', '/');
            console.log(getToken());
            wxAuth(true);
          }
        }
      });
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.all {
  margin: 0 auto;
  position: relative;
  top: 50%;
  margin-top: -325px;
}
.login-box-parent {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: auto;
  cursor: default;
  /* background-color: #f5f6f9; */
  background-color: #fff;
}
</style>
