最近又在开发 微信公众号平台的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 一起传递了回来
这样 就不会出现 参数丢失的情况了
大家可以参考参考
欢迎大家指正评论
谢谢大家