前端先发起请求
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/jweixin-1.6.0.js"></script>
<script src="js/jquery.js"></script>
<title>微信获取openid</title>
</head>
<body>
<script>
let APPID = "wx1239d9ad87f2ae81";
let REDIRECT_URI = "wwww.baidu.com"
window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+APPID+"&redirect_uri="+REDIRECT_URI+"&response_type=code&scope=SCOPE&state=STATE#wechat_redirect "
</script>
</body>
</html>
jweixin-1.6.0.js 下载