<style scoped>
.bounce {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: black;
  height: 100%;
  font: normal bold 2rem 'Product Sans', sans-serif;
  white-space: nowrap;
}

.letter {
  animation: bounce 0.75s cubic-bezier(0.05, 0, 0.2, 1) infinite alternate;
  display: inline-block;
  transform: translate3d(0, 0, 0);
  margin-top: 0.5em;
  text-shadow: rgba(255, 255, 255, 0.4) 0 0 0.05em;
  font: normal 500 2rem 'Varela Round', sans-serif;
}
.letter:nth-child(1) {
  animation-delay: 0s;
}
.letter:nth-child(2) {
  animation-delay: 0.1s;
}
.letter:nth-child(3) {
  animation-delay: 0.2s;
}
.letter:nth-child(4) {
  animation-delay: 0.3s;
}
.letter:nth-child(5) {
  animation-delay: 0.4s;
}
.letter:nth-child(6) {
  animation-delay: 0.5s;
}
.letter:nth-child(7) {
  animation-delay: 0.6s;
}
.letter:nth-child(8) {
  animation-delay: 0.7s;
}
.letter:nth-child(9) {
  animation-delay: 0.8s;
}
.letter:nth-child(10) {
  animation-delay: 0.9s;
}

@keyframes bounce {
  0% {
    transform: translate3d(0, 0, 0);
    text-shadow: rgba(255, 255, 255, 0.4) 0 0 0.05em;
  }
  100% {
    transform: translate3d(0, -1em, 0);
    text-shadow: rgba(255, 255, 255, 0.4) 0 1em 0.35em;
  }
}
</style>
<template>
  <div style="margin:100px 0">
    <div style="text-align:center;width:300%;margin-left:-100%;font-size:30px" class="bounce">
      <span class="letter">企</span>
      <span class="letter">业</span>
      <span class="letter">微</span>
      <span class="letter">信</span>
      <span class="letter">登</span>
      <span class="letter">录</span>
      <span class="letter">中</span>
      ,
      <span class="letter">请</span>
      <span class="letter">稍</span>
      <span class="letter">候</span>
    </div>
  </div>
</template>

<script>
import { postAction } from '@/api/manage'
import { mapActions } from 'vuex'
import { timeFix } from '@/utils/util'
import qs from 'qs'
import Vue from 'vue'
export default {
  name: 'transfer',
  components: {},
  data() {
    return {}
  },
  methods: {
    ...mapActions(['Login', 'Logout', 'PhoneLogin', 'wxLogin']),
    login(values) {
      this.wxLogin(values)
      this.loginSuccess()
    },
    departConfirm(res) {
      if (res.success) {
        let multi_depart = res.result.multi_depart
        //0:无部门 1:一个部门 2:多个部门
        if (multi_depart == 0) {
          this.loginSuccess()
          this.$notification.warn({
            message: '提示',
            description: `您尚未归属部门,请确认账号信息`,
            duration: 3
          })
        } else if (multi_depart == 2) {
          this.departVisible = true
          this.currentUsername = this.form.getFieldValue('username')
          this.departList = res.result.departs
        } else {
          this.loginSuccess()
        }
      } else {
        this.requestFailed(res)
        this.Logout()
      }
    },
    requestFailed(err) {
      this.$notification['error']({
        message: '登录失败',
        description: ((err.response || {}).data || {}).message || err.message || '请求出现错误，请稍后再试',
        duration: 4
      })
      this.loginBtn = false
    },
    loginSuccess() {
      this.$router.push({ name: 'dashboard' })
      this.$notification.success({
        message: '欢迎',
        description: `${timeFix()}，欢迎回来`
      })
    }
  },
  mounted() {
    this.$nextTick(() => {
      console.log(window.location.search)
      var data = window.location.search.split('?')[1]
      var arr = data.split('=')
      var json = {}
      json[arr[0]] = arr[1]
      var params = qs.stringify(json)
      postAction('/sys/wxlogin', params).then(res => {
        console.log(res)
        if (res.success) {
          this.login(res)
        } else {
          //   this.$message.error('企业微信登录失败，请选择账户登录')

          this.requestFailed(res)
          this.$router.push({ name: 'login' })
        }
      })
    })
  }
}
</script>

<style scoped></style>
