Closed xccjk closed 1 year ago
// 代码1 redirectWXAuth = () => { const { goToPage } = this.state const redirectUrl = encodeURIComponent( `${process.env.REDIRECT_HOST}/login?goto_page=${encodeURIComponent(goToPage)}&bindCode=1` ) const wechatAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${process.env.WXAPPID}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect` window.location.replace(wechatAuthUrl) }
// 代码2 // 重定向前 https://h5.abc.com/?v=1592878502327#/home // 经过重定向后 https://h5.abc.com/?v=1592878502327# // 处理方式 - 对要重定向地址中的#剪切 redirectWXAuth = () => { const { goToPage } = this.state const url = (goToPage + '').replace('#', '') const redirectUrl = encodeURIComponent( `${process.env.REDIRECT_HOST}/login?goto_page=${encodeURIComponent(url)}&bindCode=1` ) const wechatAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${process.env.WXAPPID}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect` window.location.replace(wechatAuthUrl) } // 处理方式2 - 不使用hash模式路由,由后端配置nginx来解决路由跳转
redirectWXAuth = () => { const { goToPage } = this.state const url = (goToPage + '').replace('#', '') const redirectUrl = encodeURIComponent( `${process.env.REDIRECT_HOST}/login?goto_page=${encodeURIComponent(url)}&bindCode=1` ) const wechatAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${process.env.WXAPPID}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect` window.location.replace(wechatAuthUrl) }
微信H5出现重复授权窗口跳转问题
场景与问题描述
原因分析