微信授权多个参数

2020-08-12  本文已影响0人  信仰永不退色

// 微信认证并设置跳转链接

    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

上一篇 下一篇

猜你喜欢

热点阅读