<template>
  <!-- Login 代理页面 -->
  <div>
  </div>
</template>
<script>
  export default {
    layout: 'login',
    mounted () {
      this.crossBefore()
    },
    methods: {
      async crossBefore () {
        try {
          let { data } = await this.$http.get('/logout/crossBefore')
          const params = data || {}
          this.proxyLogout(params.askUrl, params.returnUrl, params.logoutUrl)
        } catch (err) {
          this.$router.replace('/')
          console.log(err)
        }
      },
      proxyLogout (askUrl, returnUrl, logoutUrl) {
        this.$jsonp(`${askUrl}`, function (err, data) {
          if (err) throw err
          if (data.error) {
            window.location.href = logoutUrl
          } else {
            window.location.href = returnUrl && returnUrl !== 'null' ? returnUrl : '/'
          }
        })
      }
    }
  }
</script>
