微信服务号登录

master
3y 3 years ago
parent d00dd79268
commit 128ffd2ca9

@ -56,7 +56,7 @@
type: 'tpl',
inline: false,
className: 'w-full',
tpl: '<div class="flex justify-between"><div></div><div><img id="user_avatar" src="/public/user_avatar.png" width="50px" height="50px"></div></div>'
tpl: '<div class="flex justify-between"><div></div><div><span id="openId">${ls:openId}</span></div></div>'
},
// footer: '<div class="p-2 text-center bg-light">底部区域</div>',
// asideBefore: '<div class="p-2 text-center">菜单前面区域</div>',

@ -0,0 +1,21 @@
```js
// 调用接口前判断是否已登录
var openId = localStorage.getItem("openId");
if (openId != null && openId != 'null' && openId != '' && openId !== undefined) {
alert("已登录你的ID是" + openId);
window.location.href = 'index.html';
return api;
}
// 轮询登录校验返回
if (payload.data != 'NO_LOGIN' && payload.status == '0') {
localStorage.setItem("openId", payload.data.openId);
alert("扫码已登录成功你的ID是" + payload.data.openId);
window.location.href = 'index.html';
}
return payload;
```
Loading…
Cancel
Save