<template>
  <div>

  </div>

</template>

<script>
import network from '@/utils/network'
import tool from '@/utils/tool'
import userInfo from '@/utils/userInfo'
import store from '@/utils/vuexStore'
import baseInfo from '@/utils/baseInfo'

export default {
  name: 'login-by-backend',
  data () {
    return {
      messageBox: null,
    }
  },
  mounted () {
    this.messageBox = this.$message('正在登录，请稍候...')
    this.handleLogin()
  },
  methods: {
    handleLogin () {
      // 清空会员之前的登录信息
      userInfo.clear()
      // 建立新的登录信息
      let params = tool.parseURL(window.location.href).params
      let promise = network.getDaysDiff().then(response => {
        return network.loginGetAccessToken(null, null, `oauth/login-by-backend`, params)
      }).then(response => {
        return network.getUserInfo()
      }).then(response => {
        return network.getBaseInfo()
      }).then(response => {
        this.$router.push('dashboard/index')
      }).catch(error => {
        error = tool.errorHandle(error)
        this.$message.error(error.message)
        this.submitButtonStat = false
      })
      // network.getDaysDiff().then(response=>{
      //     userInfo.updateLoginAllInfo(params);
      //     return network.getUserInfo();
      // }).then(response => {
      //     return network.getBaseInfo();
      // }).then(response => {
      //     this.messageBox.close();
      //     this.$router.push('dashboard/index');
      // }).catch(error => {
      //     error = tool.errorHandle(error);
      //     this.$message.error(error.message);
      // });
    },
  }
}
</script>

<style>
  .login-wrapper {
    background: url(../../static/img/login-register.jpg) center center/cover no-repeat !important;
    width: 100%;
    height: 100%;
    position: fixed;
  }

  .login-box {
    background: #fff;
    width: 400px;
    margin: 10% auto 0;
  }

  .white-box {
    background: #fff;
    padding: 25px;
    margin-bottom: 15px;
  }

  .white-box .white-box-title {
    margin: 0 0 12px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 20px;
    line-height: 30px;
  }
</style>