From 128ffd2ca9869f49fd5d86b90c32ef6b6d6cb786 Mon Sep 17 00:00:00 2001 From: 3y Date: Wed, 21 Dec 2022 13:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=9C=8D=E5=8A=A1=E5=8F=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- responseHanler.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 responseHanler.md diff --git a/index.html b/index.html index 4d3145f..c0890f5 100644 --- a/index.html +++ b/index.html @@ -56,7 +56,7 @@ type: 'tpl', inline: false, className: 'w-full', - tpl: '
' + tpl: '
${ls:openId}
' }, // footer: '
底部区域
', // asideBefore: '
菜单前面区域
', diff --git a/responseHanler.md b/responseHanler.md new file mode 100644 index 0000000..ec02887 --- /dev/null +++ b/responseHanler.md @@ -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; + +``` \ No newline at end of file