From e2f154516a141c4e7a05744d29e4c06d922c7f55 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <773861846@qq.com> Date: Mon, 11 Nov 2019 13:15:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=EF=BC=8C=E5=BC=B9=E5=B9=95=E6=89=93=E5=BC=80?= =?UTF-8?q?/=E5=85=B3=E9=97=AD=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/common.js | 56 +++++++++++++------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index 46be523..a6db1ed 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -1,34 +1,36 @@ +Array.prototype.indexOf = function (val) { + for (var i = 0; i < this.length; i++) { + if (this[i] == val) return i; + } + return -1; +}; + +Array.prototype.remove = function (val) { + var index = this.indexOf(val); + if (index > -1) { + this.splice(index, 1); + } +}; + var token = localStorage.getItem("token"); if (token) { - $.get("/user/isLogin", { "token": token}, function (data) { - if(data.code != 1){//未登录 + $.get("/user/isLogin", {"token": token}, function (data) { + if (data.code != 1) {//未登录 localStorage.removeItem("token"); - }}) + } + }) +} + + +function readHistory() { + + var books = localStorage.getItem("historyBooks"); + var bookIds = "-1929"; + if (books) { + bookIds = JSON.parse(localStorage.getItem("historyBooks")).join(","); } - Array.prototype.indexOf = function (val) { - for (var i = 0; i < this.length; i++) { - if (this[i] == val) return i; - } - return -1; - }; - - Array.prototype.remove = function (val) { - var index = this.indexOf(val); - if (index > -1) { - this.splice(index, 1); - } - }; - - - function readHistory() { - - var books = localStorage.getItem("historyBooks"); - var bookIds = "-1929"; - if (books) { - bookIds = JSON.parse(localStorage.getItem("historyBooks")).join(","); - } - window.location.href = "/book/search?historyBookIds=" + bookIds; - }; + window.location.href = "/book/search?historyBookIds=" + bookIds; +};