From 1de0a28ba763285004a0725986779fc79646de0f Mon Sep 17 00:00:00 2001 From: suwings Date: Sun, 22 Apr 2018 23:23:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20-=20=E7=A6=81=E6=AD=A2?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E6=88=96=E9=87=8D=E5=A4=8D=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/common/js/login.js | 11 +++++++++++ route/user.js | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/public/common/js/login.js b/public/common/js/login.js index 8416304e..1f362697 100644 --- a/public/common/js/login.js +++ b/public/common/js/login.js @@ -30,11 +30,22 @@ MCSERVER.login = function (username, password, rand, loginSuccess, loginError, e }, success: function (data, textStatus) { var obj = JSON.parse(data); + //后端指令操作 + if (typeof obj['ResponseValue'] == 'number') { + var commande = Number.parseInt(obj['ResponseValue']); + if (commande == 302) { + alert("您已登录,不可重复或覆盖原先登录,我们将为你跳转网页...."); + window.location.href = '../'; + } + return; + } + //后端警告操作 if (typeof obj['ResponseValue'] == 'string') { alert(obj['ResponseValue']); loginError && loginError(); return; } + //后端正常操作,判断密码与账户 if (obj['ResponseValue']) { loginSuccess && loginSuccess(); } else { diff --git a/route/user.js b/route/user.js index 99f5feac..9189072f 100644 --- a/route/user.js +++ b/route/user.js @@ -76,6 +76,12 @@ router.post('/login', function (req, res) { return; } + //如果已经登录,则直接跳转 + if (req.session['login'] || req.session['username']) { + response.returnMsg(res, 'login/check', 302); + return; + } + //登陆次数加一 counter.plus('login');