解决了吗?我也遇到了。。。。
微信网页授权时,已经跳转到redirect uri页面了,但是为什么就是获取不到code?if (!openId) { // 内存内没有openid let locationUrl = window.location.href // 检测是否参数内有code,若有则跳接口获取openid,若没有则跳授权页 if (locationUrl.indexOf('code') >= 0) { // 链接里有code let url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' + appid + '&secret=' + secret + '&code=' + code + '&grant_type=authorization_code' let result = JSON.parse(window.location.href = url) openId = result.openId if (openId) { localStorage.setItem('openId', openId) getUserInfoByOpenId(openId) } } else { // 链接里没有code let codeUri = encodeURIComponent(href) let url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' + codeUri + '&response_type=code&scope=' + scope + '&state=123#wechat_redirect' window.location.href = url }
09-25