首先你得是个服务号
然后添加如图所示的域名
然后图中有个下载文件,把那个下载的文件放到你填写的域名文件根目录下,直接放进去就行,让后传到服务器上。
到这里好像就可以了
如果是vue打包的项目:
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
appid=${appId}&redirect_uri=${encodeURIComponent(window.location.href.split('#')
[0])}&response_type=code&scope=snsapi_userinfo&state=${0}#wechat_redirect`;
不是的话就
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
appid=${appId}&redirect_uri=${encodeURIComponent(window.location.href)}&
response_type=code&scope=snsapi_userinfo&state=${0}#wechat_redirect`;
复制的时候注意一下 我换行了
if (is_weixn()) {
console.log('微信环境')
const code = GetQueryValue('code')
let appId = '你服务号的appid';
if (!code) {
(async () => {
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
appid=${appId}&redirect_uri=${encodeURIComponent(window.location.href.split('#')
[0])}&response_type=code&scope=snsapi_userinfo&state=${0}#wechat_redirect`;
console.log("url", url);
window.location.href = url
return
})()
}
} else {
console.log('非微信环境')
}
这样应该就完事了~~ 我第一次写授权 应该还差点东西 你们看了 记得提醒我一下,