<template></template>

<script>
export default {
  name: 'WxCallback',
  mounted() {
    const url = new URL(window.location.href)
    const code = url.searchParams.get('code')
    const inviteCode = url.searchParams.get('RecommendCode') || url.searchParams.get('invite') || localStorage.getItem('recommend')

    if (code) {
      sessionStorage.setItem('wx_callback_code', code)
      // 带上 invite 参数一起跳转，Login mounted 时读取
      this.$router.replace('/Login' + (inviteCode ? `?RecommendCode=${inviteCode}` : ''))
    } else {
      this.$router.replace('/')
    }
  }
}
</script>