Commit 909cfbfbd93f14080b0686c3f4f53eb75a6a3871
1 parent
ca554740
登录模块提交
Showing
4 changed files
with
41 additions
and
12 deletions
index/index.html
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | <header> |
23 | 23 | <div class="nav-bar-wrap"> |
24 | 24 | <div class="float-left login-name"> |
25 | - <span id="">张志涛</span> <span class="cursorpointer">退出</span> | |
25 | + <span id="loginName">张志涛</span> <span class="cursorpointer" id="logoutId">退出</span> | |
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <nav class="float-right"> |
... | ... | @@ -52,6 +52,7 @@ |
52 | 52 | <script src="../resource/lib/jqueryform/jquery.form.js"></script> |
53 | 53 | |
54 | 54 | <script src="../topages/topagesTmp.js?a=1"></script> |
55 | +<script src="../resource/js/unit.js?a=1"></script> | |
55 | 56 | <!--<script src="../topages/workquery/workquery.js"></script>--> |
56 | 57 | </body> |
57 | 58 | </html> |
58 | 59 | \ No newline at end of file | ... | ... |
resource/js/unit.js
... | ... | @@ -36,6 +36,9 @@ dataUrl.util = { |
36 | 36 | login: function () { |
37 | 37 | return parkcloudbaseUrl + 'oauth/login'; |
38 | 38 | }, |
39 | + getLoginOut:function(){ | |
40 | + return parkcloudbaseUrl + 'oauth/loginout'; | |
41 | + } | |
39 | 42 | |
40 | 43 | |
41 | 44 | |
... | ... | @@ -104,16 +107,33 @@ var fn ={ |
104 | 107 | }, |
105 | 108 | //登出系统 |
106 | 109 | loginOut: function () { |
107 | - sessionStorage.clear() | |
110 | + debugger; | |
111 | + | |
108 | 112 | var token = fn.getToken(); |
109 | - fn.setToken(''); | |
110 | - if (StrUtil.isNotEmpty()) { | |
111 | - var req = {'token': token, 'url': dataUrl.util.getLoginOut()} | |
112 | - sysAjax(req); | |
113 | + | |
114 | + if (token != "" && token != null) { | |
115 | + | |
116 | + var opt = { | |
117 | + method: "post", | |
118 | + url: dataUrl.util.getLoginOut(), | |
119 | + success: function(res){ | |
120 | + sessionStorage.clear() | |
121 | + fn.setToken(''); | |
122 | + fn.toLoginPage(); | |
123 | + | |
124 | + } | |
125 | + }; | |
126 | + sysAjax(opt); | |
127 | + | |
113 | 128 | |
114 | 129 | } |
115 | - fn.toLoginPage(); | |
116 | - } | |
130 | + | |
131 | + }, | |
132 | + //跳转到登录界面 | |
133 | + toLoginPage: function () { | |
134 | + sessionStorage.setItem("sys_parkLot", ''); | |
135 | + window.location.href = '../login/login.html' | |
136 | + }, | |
117 | 137 | }; |
118 | 138 | |
119 | 139 | DateUtil = { |
... | ... | @@ -270,8 +290,8 @@ function sysAjax(opts) { |
270 | 290 | beforeSend: function (xhr) { |
271 | 291 | //设置请求头 |
272 | 292 | //xhr.setRequestHeader("User-Agent", "headertest"); |
273 | - //console.log(JSON.stringify(sysComm)); | |
274 | - xhr.setRequestHeader("x-auth-token", fn.getToken()); | |
293 | + console.log(fn.getToken()); | |
294 | + xhr.setRequestHeader("X-Auth-Token", fn.getToken()); | |
275 | 295 | }, |
276 | 296 | success: function (res, status, xhr) { |
277 | 297 | //console.log('获取header:'+xhr.getAllResponseHeaders()); | ... | ... |
topages/login/login.js
topages/workfill/workfill.js
... | ... | @@ -5,7 +5,8 @@ var weekOfday = Number(moment().format('E'));//计算今天是这周第几天 |
5 | 5 | var clicknum = 0;//定义上下周点击次数 |
6 | 6 | var fun = { |
7 | 7 | init:function () { |
8 | - | |
8 | + debugger; | |
9 | + $("#loginName").text(fn.getUserName()); | |
9 | 10 | //初始化项目 |
10 | 11 | $('.work-projectName').selectpicker('render'); |
11 | 12 | //获取本周时间 |
... | ... | @@ -13,6 +14,8 @@ var fun = { |
13 | 14 | // 获取今天时间 |
14 | 15 | var todaytime = moment().subtract('days', 0).format('YYYY/MM/DD'); |
15 | 16 | $('#time-opr-nowtime').text(todaytime); |
17 | + // | |
18 | + fun.logout(); | |
16 | 19 | }, |
17 | 20 | timeoprprevbtn:function () { |
18 | 21 | $('#time-opr-nextbtn').removeClass('display-none'); |
... | ... | @@ -37,6 +40,12 @@ var fun = { |
37 | 40 | |
38 | 41 | |
39 | 42 | }, |
43 | + //退出 | |
44 | + logout:function(){ | |
45 | + $(document).on('click','#logoutId',function(){ | |
46 | + fn.loginOut(); | |
47 | + }); | |
48 | + } | |
40 | 49 | }; |
41 | 50 | fun.init(); |
42 | 51 | // 上一周点击time-opr-prevbtn | ... | ... |