微信公众号H5 重定向登录 新发现 携带参数

最近又在开发 微信公众号平台的H5 重定向授权登录

现在我需要登录的时候 一个外部传递过来的参数 这个参数 是外部获取的 必须得有 这个程序参能往下进行

//获取code
const getCode = () => {
  // 网络重定向地址
  // let local = `http://xxxxxxxxxxxxxxxx/cdx2.html`; // 获取页面url
  let local = `http://xxxxxxx/cdx2.html?shopId=${Taro.getStorageSync("shopId")}`; // 获取页面url

  // // // // 判断 如果是本地 开发 设置本地重定向地址
  // http://192.168.3.8:10086/
  if (window.location.origin.indexOf("192.168.110.71") !== -1) {
    local = `http://xxxxxxxx/cdx1.html?shopId=${Taro.getStorageSync("shopId")}`; // 获取页面url
    // local = `http://xxxxxxxxxx/cdx1.html`; // 获取页面url
  }
  //  地址转码
  local = encodeURIComponent(local);

  //  获取 code 地址registerCode
  let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid.value}&redirect_uri=${local}&response_type=code&connect_redirect=1&scope=snsapi_base&state=STATE#wechat_redirect`;

  window.location.href = url;
  // Taro.hideLoading();
};

对的 

我之前开发这个 公众号重定向登录是这样写的 

自己写了两个文件 本地和 线上的调试文件 跳转授权

我测试了一下 我发现 这个参数 评到html文件后面 

跟授权的code 一起传递了回来 

这样 就不会出现 参数丢失的情况了 

大家可以参考参考

欢迎大家指正评论 

谢谢大家

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值