From a67ef1ea9215d52bbdef49061639f91cae5a972b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 10 七月 2020 10:26:19 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/pdaCe/login.html |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/main/webapp/views/pdaCe/login.html b/src/main/webapp/views/pdaCe/login.html
index ae52528..7b4c54e 100644
--- a/src/main/webapp/views/pdaCe/login.html
+++ b/src/main/webapp/views/pdaCe/login.html
@@ -26,7 +26,7 @@
             <input type="password" id="password" value="xltys1995">
         </div>
         <div>
-            <button onclick="login()">鐧诲綍</button>
+            <button id="login" onclick="login()">鐧诲綍</button>
         </div>
 
     </div>
@@ -34,14 +34,7 @@
 <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
 <script type="text/javascript" src="../../static/js/tools/md5.js"></script>
 <script type="text/javascript">
-    document.onkeydown = function(e) {
-        //鎹曟崏鍥炶溅浜嬩欢
-        var ev = (typeof event!= 'undefined') ? window.event : e;
-        if(ev.keyCode === 13 && document.activeElement.id === "key") {
-            login()
-        }
-    }
-    document.onkeyup = function (e) {
+    document.onkeydown = function (e) {
         if (window.event)//濡傛灉window.event瀵硅薄瀛樺湪锛屽氨浠ユ浜嬩欢瀵硅薄涓哄噯
             e = window.event;
         var code = e.charCode || e.keyCode;
@@ -59,6 +52,9 @@
             }
         }, function (res) {
             if (res.code === 200) {
+                // localStorage.setItem("token", res.data.token);
+                // localStorage.setItem("username", res.data.username);
+                setCookie("token", res.data.token);
                 window.location.href = "index.html";
             } else {
                 alert(res.msg);
@@ -67,6 +63,19 @@
         })
     }
 
+    // 璁剧疆cookie
+    function setCookie(objName, objValue){//娣诲姞cookie
+        var str = objName + "=" + encodeURIComponent(objValue);
+        // if (objHours > 0) {//涓�0鏃朵笉璁惧畾杩囨湡鏃堕棿锛屾祻瑙堝櫒鍏抽棴鏃禼ookie鑷姩娑堝け
+        //     var date = new Date();
+        //     var ms = objHours * 3600 * 1000;
+        //     date.setTime(date.getTime() + ms);
+        //     str += "; expires=" + date.toUTCString();
+        // }
+        str += "; path=/";
+        document.cookie = str;
+    }
+
     function httpRequest(paramObj,fun,errFun) {
         var xmlhttp = null;
         /*鍒涘缓XMLHttpRequest瀵硅薄锛�

--
Gitblit v1.9.1