https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=012#wechat_redirect
- 授权逻辑代码
通过window.history.pushState({}, 0, jumpURL)
解决问题=,其中jumpURL为授权界面的URL
const h5AppId = '*******************************';
this.loginParamsH5.appId = h5AppId;
let paramsObj = this.$mHelper.getURLParams(window.location.search);
console.log('当前地址的URL参数=====>', paramsObj);
const jumpURL = 'http://*******/mpshop#/pages/public/wechat-auth';
if (!paramsObj.code) {
const redirectUrl = this.$mConstDataConfig.oauth2URL.replace("APPID", h5AppId).replace("REDIRECT_URI", encodeURIComponent(jumpURL));
window.location.href = redirectUrl;
} else {
this.loginParamsH5.code = paramsObj.code;
this.loginParamsH5.state = paramsObj.state || '012';
window.history.pushState({}, 0, jumpURL);
}