// 微信认证并设置跳转链接
let url = encodeURIComponent(`xxxxx?xx=${xx}&xxx=${xxx}`);
window.location.href =
'授权链接' +
queryStringify({
appid: environment.wechat.appId,
redirect_uri: encodeURIComponent(environment.wechat.authApi),
scope: 'snsapi_userinfo',
response_type: 'code',
state: `fromUrl:${this.router.routerState.snapshot.url}` + '#wechat_redirect'
});
解码:
let state = decodeURIComponent(getQueryVariable('state')).split(';');
let stateMap = {};
state.forEach((item) => {
item = item.split(':');
stateMap[item[0]] = item[1];
});
stateMap.fromUrl
网友评论