jiangwei小站
33 字
1 分钟
微信公众号页面授权登录
2024-04-22

只需要 appid

if (isWeChat()) {
  console.log(GetUrlParams().code);
  if (GetUrlParams().code) {
    useUserStore().thirdLogin(
      GetUrlParams().code,
      GetUrlParams().inviteCode || ""
    );
    router.replace("/mine");
  } else {
    const REDIRECT_URI = location.origin + "/mobileLogin";
    window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=${encodeURIComponent(
      REDIRECT_URI
    )}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
  }
}