diff --git a/api/commonRequest.js b/api/commonRequest.js index b4065cb..d927a13 100644 --- a/api/commonRequest.js +++ b/api/commonRequest.js @@ -3,7 +3,11 @@ const commonUrl = "http://10.40.92.33:18080/zhgd/"; /* 登录相关 */ const login_url = commonUrl + "auth/login"; // 登录url const login_out = commonUrl + "auth/logout"; // 登出url -const login_page = "http://127.0.0.1:8100/login.html" // 登录页面 +const page_jump = commonUrl + "auth/pageJump"; // 登出url +const login_sg_page = "http://10.40.92.33:8101/sg_login.html" // 施工大屏登录页面 +const login_sc_page = "http://10.40.92.33:8100/sc_login.html" // 省侧大屏登录页面 +const login_sg_index = "http://10.40.92.33:8101/pages/home/navigation.html" // 施工大屏首页 +const login_sc_index = "http://10.40.92.33:8100/pages/web/index.html" // 省侧大屏首页 // ajax 请求封装 function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType) { @@ -11,7 +15,7 @@ function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, conte url: url, type: type, headers: { - "authorization": localStorage.getItem("zhgd_token") + "authorization": sessionStorage.getItem("zhgd_token") }, data: data, async: async, @@ -20,4 +24,17 @@ function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, conte success: successFn, error: errorFn }); +} + +/* 施工大屏跳转 ajax请求封装 */ +function ajaxRequest2(url, type, token, successFn, errorFn) { + $.ajax({ + url: url, + type: type, + headers: { + "authorization": token + }, + success: successFn, + error: errorFn + }); } \ No newline at end of file diff --git a/css/home/navigation.css b/css/home/navigation.css index 0940398..225b8ab 100644 --- a/css/home/navigation.css +++ b/css/home/navigation.css @@ -22,14 +22,53 @@ html { width: 27%; height: 100%; } -#nav-left p{ - margin-top: 50px; + +#nav-left button { + position: absolute; + left: 22%; + top: 1.5%; + width: 80px; + height: 40px; + background-position: center center !important; + color: #00FFF4; + background-color: transparent; + border: none; font-size: 20px; + cursor: pointer; +} + +#nav-left form { + width: 100%; + height: 100%; + align-items: self-end; +} + +.layui-form-select { + width: 80%; +} + +.layui-form-select .layui-input { + background-color: transparent; + font-size: 16px; + text-align: center; background-image: linear-gradient(to bottom, #DAF8F4FF, #44DEC9FA); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; + font-weight: bold; + border-color: #2EA699; } + +.layui-form-select .layui-edge { + border-top-color: #2EA699; +} + + +.layui-input:hover, +.layui-textarea:hover { + border-color: #16b777 !important; +} + #nav-icon { width: 120px; height: 30px; @@ -37,10 +76,13 @@ html { left: 81%; top: 0.5%; cursor: pointer; + } -#nav-icon img{ + +#nav-icon img { margin-right: 10px; } + #nav-right { width: 73%; height: 100%; diff --git a/css/login.css b/css/login.css index 0580d7e..5bd50cb 100644 --- a/css/login.css +++ b/css/login.css @@ -70,6 +70,10 @@ html { color: #fff; } +.layui-input:hover, .layui-textarea:hover { + border-color: #16b777 !important; +} + input::-webkit-input-placeholder { color: rgb(153, 152, 152) !important; } diff --git a/js/login/login.js b/js/login/login.js index ee2a47b..ef719ec 100644 --- a/js/login/login.js +++ b/js/login/login.js @@ -4,20 +4,33 @@ layui.use(function () { layer = layui.layer; form.on('submit(demo-login)', function (data) { let field = data.field; + let loginType = ""; + let hrefUrl = window.location.href; + if (hrefUrl && hrefUrl.indexOf("sg_login") > 0) { + loginType = "2" + } else if (hrefUrl && hrefUrl.indexOf("sc_login") > 0) { + loginType = "1" + } const params = { "username": field.username, "password": field.password, - "loginType": "2" + "loginType": loginType } let encryptStr = encryptCBC(JSON.stringify(params)); ajaxRequest(login_url, "POST", encryptStr, true, function () { }, function (result) { console.log(result); if (result.code === 200) { - top.layer.msg(result.msg, { icon: 1, time: 1000 }, function () { - localStorage.setItem("zhgd_token", result.data.access_token); - localStorage.setItem("zhgd_us", result.data.us); - window.location.href = "pages/home/navigation.html"; + top.layer.msg(result.msg, { icon: 1, time: 500 }, function () { + sessionStorage.setItem("zhgd_token", result.data.access_token); + sessionStorage.setItem("zhgd_us", result.data.us); + const us = JSON.parse(result.data.us); + sessionStorage.setItem("zhgd_type", us.jumpType); + if (us.jumpType === '2') { + window.location.href = "pages/home/navigation.html"; + } else if (us.jumpType === '1') { + window.location.href = "pages/web/index.html"; + } }); } else if (result.code === 500) { layer.msg(result.msg, { icon: 2 }); diff --git a/js/pages/home/navigation.js b/js/pages/home/navigation.js index a95523d..b3d8005 100644 --- a/js/pages/home/navigation.js +++ b/js/pages/home/navigation.js @@ -1,18 +1,104 @@ -let element, layer; +let element, layer, bidCode; layui.use(['layer', 'element'], function () { element = layui.element; layer = layui.layer; + // 获取地址栏上的参数 + const bidCodeParam = GetQueryString('bidCode'); + const tokenParam = GetQueryString('token'); + if (bidCodeParam && tokenParam) { + // 省侧大屏跳转施工大屏 调用后台返回用户信息 + bidCode = decryptCBC(bidCodeParam); + const token = decryptCBC(tokenParam); + ajaxRequest2(page_jump, "GET", token, function (result) { + console.log(result); + if (result.code === 200) { + sessionStorage.setItem("zhgd_token", result.data.access_token); + sessionStorage.setItem("zhgd_us", result.data.us.sysUser); + sessionStorage.setItem("zhgd_type", result.data.us.sysUser.jumpType); + reloadMenuData(result.data.us.sysUser, bidCode); + $('#nav-left button').removeAttr('style') + } else if (result.code === 500) { + layer.msg(result.msg, { icon: 2 }, function () { + window.location.href = login_sc_index; + }); + } else if (result.code === 401) { + layer.msg(result.msg, { icon: 2 }, function () { + loginout(1); + }); + } + }, function (xhr) { + error(xhr) + }); + } else { + // 由施工大屏登录 + reloadMenuData(JSON.parse(us), bidCode); + } }); -$('#indexIframe').attr('src', '../index/index.html'); -$('#nav-right ul li').on('click', function () { - $('#nav-right ul li').each(function (index, item) { - if ($(this).hasClass('checked')) { - $(this).removeClass('checked').addClass('nocheck'); - } +/* 页面数据加载 */ +function reloadMenuData(us, bidCode) { + let menus = us.menus; + let bidCodeList = us.bidProVoList; + setBandingPro(bidCodeList, bidCode); + setMenusData(menus); + if ($('#nav-right ul li').length > 0) { + let hrefValue = $('#nav-right ul li').eq(0).attr('hrefValue'); + $('#indexIframe').attr('src', hrefValue); + } + $('#nav-right ul li').on('click', function () { + $('#nav-right ul li').each(function (index, item) { + if ($(this).hasClass('checked')) { + $(this).removeClass('checked').addClass('nocheck'); + } + }) + $(this).removeClass('nocheck').addClass('checked'); + const hrefValue = $(this).attr('hrefValue'); + $('#indexIframe').attr('src', hrefValue); }) - $(this).removeClass('nocheck').addClass('checked'); - const hrefValue = $(this).attr('hrefValue'); - $('#indexIframe').attr('src', hrefValue); +} + +/* 初始化菜单 */ +function setMenusData(menus) { + let html = ''; + if (menus && menus.length > 0) { + $.each(menus[0].childer, function (index, item) { + if (index === 0) { + html += '
' + item.menuName + '
' + item.menuName + '