This commit is contained in:
cwchen 2024-04-03 13:52:23 +08:00
parent a3fbe4fdc8
commit 1220d5c800
5 changed files with 47 additions and 22 deletions

View File

@ -1,5 +1,5 @@
let aqEnnable = true // 参数加密开关
const commonUrl = "http://10.40.92.105:18080/zhgd/";
let aqEnnable = false // 参数加密开关
const commonUrl = "http://10.40.92.33:18080/zhgd/";
/* 登录相关 */
const login_url = commonUrl + "auth/login"; // 登录url
const login_out = commonUrl + "auth/logout"; // 登出url
@ -10,7 +10,7 @@ const login_sg_index = "http://10.40.92.33:8100/pages/home/navigation.html" //
const login_sc_index = "http://10.40.92.33:8101/pages/web/index.html" // 省侧大屏首页
/* POST 请求 */
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType,isAes) {
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType, isAes) {
$.ajax({
url: url,
type: type,
@ -33,7 +33,8 @@ function ajaxRequest2(url, type, token, successFn, errorFn) {
url: url,
type: type,
headers: {
"authorization": token
"authorization": token,
"decrypt": 'decrypt'
},
success: successFn,
error: errorFn
@ -66,9 +67,9 @@ function ajaxRequestGetExport(url, type, async, beforeFn, successFn, errorFn, is
"authorization": sessionStorage.getItem("zhgd_token"),
"decrypt": isAes ? '' : 'decrypt'
},
xhrFields: {
responseType: 'blob' // 告诉 xhr 我们期望返回的数据类型是 blob
},
xhrFields: {
responseType: 'blob' // 告诉 xhr 我们期望返回的数据类型是 blob
},
async: async,
beforeSend: beforeFn,
success: successFn,

View File

@ -18,8 +18,8 @@ layui.use(function () {
}
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(login_url, "POST", encryptStr, true, function () {
$('.layui-btn-fluid').empty().append('<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>登录中,请稍后...').attr("disabled", true);
}, function (result) {
console.log(result);
if (result.code === 200) {
top.layer.msg(result.msg, { icon: 1, time: 500 }, function () {
sessionStorage.setItem("zhgd_token", result.data.access_token);
@ -37,6 +37,7 @@ layui.use(function () {
}
}, function (xhr, status, error) {
error(xhr, status, error)
}, "application/json",aqEnnable);
$('.layui-btn-fluid').empty().append('登 录');
}, "application/json", aqEnnable);
});
});

View File

@ -7,6 +7,7 @@ layui.use(['layer', 'element'], function () {
const bidCodeParam = GetQueryString('bidCode');
const tokenParam = GetQueryString('token');
if (bidCodeParam && tokenParam) {
aqEnnable = !aqEnnable ? true : true;
// 省侧大屏跳转施工大屏 调用后台返回用户信息
bidCode = decryptCBC(bidCodeParam);
const token = decryptCBC(tokenParam);
@ -68,18 +69,25 @@ function reloadMenuData(us, bidCode) {
}
/* 初始化菜单 */
function setMenusData(menus) {
let html = '';
if (menus && menus.length > 0) {
$.each(menus[0].childer, function (index, item) {
if (index === 0) {
html += '<li class="layout checked" hrefValue="' + item.url + '"><p>' + item.menuName + '</p></li>'
} else {
html += '<li class="layout nocheck" hrefValue="' + item.url + '"><p>' + item.menuName + '</p></li>'
}
function setMenusData(data) {
if (data && data.length > 0) {
const menus = data.filter(item => {
return item.menuName === '施工大屏'
})
let html = '';
if (menus && menus.length > 0) {
$.each(menus[0].childer, function (index, item) {
if (index === 0 && item.menuName !== '数据操作') {
html += '<li class="layout checked" hrefValue="' + item.url + '"><p>' + item.menuName + '</p></li>'
} else if (index !== 0 && item.menuName !== '数据操作') {
html += '<li class="layout nocheck" hrefValue="' + item.url + '"><p>' + item.menuName + '</p></li>'
} else if (item.menuName === '数据操作') {
html += '<li class="layout nocheck" onclick="goBackground()"><p>' + item.menuName + '</p></li>'
}
})
}
$('#nav-right ul').empty().append(html);
}
$('#nav-right ul').empty().append(html);
}
/* 初始化用户绑定标段工程 */
@ -110,4 +118,18 @@ const GetQueryString = (name) => {
/* 返回省侧大屏 */
$('#nav-left button').on('click', function () {
window.location.href = login_sc_index;
})
})
/* 跳转后台 */
function goBackground() {
aqEnnable = !aqEnnable ? true : true;
const params = {
'token': token
};
// 将参数转换为查询字符串
const queryString = Object.keys(params)
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(encryptCBC(params[key])))
.join('&');
const hrefUrl = "http://10.40.92.113:9527/#/sso" + "?" + queryString;
const newWindow = window.open(hrefUrl,'newwindow');
}

View File

@ -23,7 +23,7 @@
<div id="nav-box" class="layout">
<div id="nav-icon">
<img src="../../img/navigation/logout.png" onclick="loginout()" alt="退出" data-mtpis="退出">
<p style="color: #fff;" onclick="goSg()">点击跳转施工大屏</p>
<!-- <p style="color: #fff;" onclick="goSg()">点击跳转施工大屏</p> -->
</div>
</div>
<div id="ifr-box">

View File

@ -40,7 +40,8 @@
</div>
</div>
<div class="layui-form-item" style="margin-top: 8%;">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">登 录</button>
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">
登 录</button>
</div>
</form>
</div>