新增日志页面嵌套监控的公共方法,后续根据需求合入公共代码
Showing
2 changed files
with
25 additions
and
29 deletions
1 | -layui.define(['sessions', 'form', 'common'],function (exports) { | 1 | +layui.define(['sessions', 'form', 'common'], function (exports) { |
2 | //登录相关模块,对外暴露的接口 | 2 | //登录相关模块,对外暴露的接口 |
3 | exports('pageLog', function () { | 3 | exports('pageLog', function () { |
4 | 4 | ||
@@ -34,12 +34,12 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | @@ -34,12 +34,12 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | ||
34 | 34 | ||
35 | try { | 35 | try { |
36 | logPage(); | 36 | logPage(); |
37 | - }catch (e) { | 37 | + } catch (e) { |
38 | err() | 38 | err() |
39 | } | 39 | } |
40 | 40 | ||
41 | 41 | ||
42 | - function err(){ | 42 | + function err() { |
43 | layer.msg('没有权限!', {icon: 5, time: 500}); | 43 | layer.msg('没有权限!', {icon: 5, time: 500}); |
44 | $('#text').text("没有权限!") | 44 | $('#text').text("没有权限!") |
45 | layer.closeAll(); | 45 | layer.closeAll(); |
@@ -52,14 +52,14 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | @@ -52,14 +52,14 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | ||
52 | * http://xxxxxx:8088/?show=0&Authorization=token&url=alarm/activewarning#/page/forward | 52 | * http://xxxxxx:8088/?show=0&Authorization=token&url=alarm/activewarning#/page/forward |
53 | * @constructor | 53 | * @constructor |
54 | */ | 54 | */ |
55 | - function logPage(){ | 55 | + function logPage() { |
56 | var index = layer.load(2); //加载层 | 56 | var index = layer.load(2); //加载层 |
57 | // 日志token | 57 | // 日志token |
58 | - var tokenStr = getUrlParam("Authorization").replace('Bearer%20','').replace('Bearer ',''); | 58 | + var tokenStr = getUrlParam("Authorization").replace('Bearer%20', '').replace('Bearer ', ''); |
59 | // 跳转地址 | 59 | // 跳转地址 |
60 | var url = getUrlParam("url").split('#/')[0]; | 60 | var url = getUrlParam("url").split('#/')[0]; |
61 | - if(url.indexOf('(')!=-1 && url.indexOf(')')!=-1 ){ | ||
62 | - url = url.replace('(','?').replace(':','=').replace(',','&').replace(')',''); | 61 | + if (url.indexOf('(') != -1 && url.indexOf(')') != -1) { |
62 | + url = url.replace('(', '?').replace(':', '=').replace(',', '&').replace(')', ''); | ||
63 | } | 63 | } |
64 | 64 | ||
65 | // 日志地址 | 65 | // 日志地址 |
@@ -72,32 +72,32 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | @@ -72,32 +72,32 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | ||
72 | async: false, | 72 | async: false, |
73 | success(response) { | 73 | success(response) { |
74 | //debugger | 74 | //debugger |
75 | - if(response.gateway){ | 75 | + if (response.gateway) { |
76 | //logApi = response.gateway; | 76 | //logApi = response.gateway; |
77 | } | 77 | } |
78 | } | 78 | } |
79 | }); | 79 | }); |
80 | 80 | ||
81 | var api = logApi + "/api-user/users/getUserByToken"; | 81 | var api = logApi + "/api-user/users/getUserByToken"; |
82 | - $.ajax(api,{ | ||
83 | - data:{ | 82 | + $.ajax(api, { |
83 | + data: { | ||
84 | "access_token": tokenStr | 84 | "access_token": tokenStr |
85 | }, | 85 | }, |
86 | headers: { | 86 | headers: { |
87 | - 'authorization': 'Bearer '+tokenStr, | 87 | + 'authorization': 'Bearer ' + tokenStr, |
88 | }, | 88 | }, |
89 | //dataType:'json',//服务器返回json格式数据 | 89 | //dataType:'json',//服务器返回json格式数据 |
90 | - type:'get',//HTTP请求类型 | ||
91 | - timeout:30000,//超时时间设置为30秒; | 90 | + type: 'get',//HTTP请求类型 |
91 | + timeout: 30000,//超时时间设置为30秒; | ||
92 | //contentType: 'application/x-www-form-urlencoded', | 92 | //contentType: 'application/x-www-form-urlencoded', |
93 | - success:function(rsp){ | ||
94 | - if(rsp.code == 0){ | 93 | + success: function (rsp) { |
94 | + if (rsp.code == 0) { | ||
95 | var name = rsp.object.username; | 95 | var name = rsp.object.username; |
96 | try { | 96 | try { |
97 | - var SubtleCrypto=new SubtleCrypto(); | 97 | + var SubtleCrypto = new SubtleCrypto(); |
98 | var pwd = SubtleCrypto.decrypt(rsp.object.password); | 98 | var pwd = SubtleCrypto.decrypt(rsp.object.password); |
99 | console.log(pwd); | 99 | console.log(pwd); |
100 | - }catch (e) { | 100 | + } catch (e) { |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
@@ -113,7 +113,7 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | @@ -113,7 +113,7 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | ||
113 | 113 | ||
114 | 114 | ||
115 | $.ajax({ | 115 | $.ajax({ |
116 | - url: common.domainName + '/api-auth/oauth/token', | 116 | + url: common.domainName + '/api-auth/oauth/token', |
117 | data: field, | 117 | data: field, |
118 | type: 'POST', | 118 | type: 'POST', |
119 | dataType: 'JSON', | 119 | dataType: 'JSON', |
@@ -135,13 +135,11 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | @@ -135,13 +135,11 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | ||
135 | localStorage.setItem("loginUrl", location.href); | 135 | localStorage.setItem("loginUrl", location.href); |
136 | 136 | ||
137 | //登入成功的提示与跳转 | 137 | //登入成功的提示与跳转 |
138 | - if(url.indexOf("ajConfig")!=-1){ | ||
139 | - if(url.indexOf("ajConfig/view")!=-1){ | ||
140 | - window.location = window.location.origin + '/vue3/index.html#/' + url; | ||
141 | - }else { | ||
142 | - window.location = window.location.origin + '/vue3/index.html?show=0&access_token=' + data.access_token + '#/' + url; | ||
143 | - } | ||
144 | - }else { | 138 | + if (url.indexOf("ajConfig") != -1 && url.indexOf("ajConfig/view") != -1) { |
139 | + | ||
140 | + window.location = window.location.origin + '/vue3/index.html#/' + url; | ||
141 | + | ||
142 | + } else { | ||
145 | window.location = window.location.origin + '/start/index.html?show=0&access_token=' + data.access_token + '#/' + url; | 143 | window.location = window.location.origin + '/start/index.html?show=0&access_token=' + data.access_token + '#/' + url; |
146 | } | 144 | } |
147 | 145 | ||
@@ -155,7 +153,7 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | @@ -155,7 +153,7 @@ layui.define(['sessions', 'form', 'common'],function (exports) { | ||
155 | }); | 153 | }); |
156 | } | 154 | } |
157 | }, | 155 | }, |
158 | - error:function(xhr,type,errorThrown){ | 156 | + error: function (xhr, type, errorThrown) { |
159 | err(); | 157 | err(); |
160 | } | 158 | } |
161 | }); | 159 | }); |
@@ -6,15 +6,13 @@ | @@ -6,15 +6,13 @@ | ||
6 | 6 | ||
7 | 7 | ||
8 | var global = {}; | 8 | var global = {}; |
9 | -console.log(window.parent); | ||
10 | -if (window.parent.frames[0] != window.self) { | 9 | +if (window.parent!= window.top) { |
11 | global.layui = window.parent.layui; | 10 | global.layui = window.parent.layui; |
12 | global.layer = window.parent.layer; | 11 | global.layer = window.parent.layer; |
13 | }else { | 12 | }else { |
14 | global.layui = undefined; | 13 | global.layui = undefined; |
15 | global.layer = undefined; | 14 | global.layer = undefined; |
16 | } | 15 | } |
17 | - | ||
18 | global.common = { | 16 | global.common = { |
19 | getUserName : function (){ | 17 | getUserName : function (){ |
20 | return localStorage.getItem('lgn'); | 18 | return localStorage.getItem('lgn'); |
-
Please register or login to post a comment