let element, layer, form, bidCode; let talkAbout=false; layui.use(['layer', 'element'], function () { element = layui.element; layer = layui.layer; form = layui.form; // 获取地址栏上的参数 const bidCodeParam = GetQueryString('bidCode'); const tokenParam = GetQueryString('token'); if (bidCodeParam && tokenParam) { aqEnnable = !aqEnnable ? true : true; // 省侧大屏跳转施工大屏 调用后台返回用户信息 bidCode = decryptCBC(bidCodeParam); const token = decryptCBC(tokenParam); ajaxRequest2(page_jump, "GET", token, function (result) { if (result.code === 200) { sessionStorage.setItem("zhgd_token", result.data.access_token); sessionStorage.setItem("zhgd_us", JSON.stringify(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_page; }); } else if (result.code === 401) { layer.msg(result.msg, { icon: 2 }, function () { loginout(1); }); } }, function (xhr) { error(xhr) }); } else { // 由施工大屏登录 reloadMenuData(JSON.parse(us), bidCode); } // 标段工程下拉选监听 form.on('select(bidPro)', function (data) { $('#nav-right ul li').each(function (index, item) { if ($(this).hasClass('checked')) { const hrefValue = $(this).attr('hrefValue'); $('#indexIframe').attr('src', hrefValue); } }) }); let loading; // 检查浏览器是否支持语音识别 API if ('webkitSpeechRecognition' in window) { const recognition = new webkitSpeechRecognition(); // 创建一个 SpeechRecognition 对象 recognition.continuous = false; // 是否持续识别,这里设置为 false recognition.lang = 'zh-CN'; // 设置识别的语言,这里设置为中文 recognition.interimResults = false; // 是否返回临时识别结果 // 当语音识别开始时触发 recognition.onstart = function() { loading = layer.load(2, { shade: false ,//0.1透明度的白色背景 content:'
语音识别中......
', success: function (layerContentStyle) { // 设置loading样式 layerContentStyle.find('.layui-layer-content').css({ 'padding-left': '45px', 'text-align': 'left', 'width': '175px', 'line-height':'30px' }); } }); }; // 当语音识别结束时触发 recognition.onend = function() { talkAbout=false; layer.close(loading); loading = layer.load(2, { shade: false ,//0.1透明度的白色背景 time: 1000, content:'
正在检测中......
', success: function (layerContentStyle) { // 设置loading样式 layerContentStyle.find('.layui-layer-content').css({ 'padding-left': '45px', 'text-align': 'left', 'width': '175px', 'line-height':'30px' }); } }); }; // 当识别到一个结果时触发 recognition.onresult = function(event) { layer.close(loading); const transcript = event.results[0][0].transcript; // 获取识别的文本 if(transcript){ let openUrl='' if(transcript.indexOf("首页")!=-1){ openUrl ='../index/index.html' }else if(transcript.indexOf("视频监控")!=-1){ openUrl ='../video/video.html' }else if(transcript.indexOf("组塔检测")!=-1){ openUrl ='../towerAssInspect/towerAssInspect.html' }else if(transcript.indexOf("作业环境")!=-1){ openUrl ='../operEnvironment/operEnvironment.html' }else if(transcript.indexOf("施工质量")!=-1){ openUrl ='../consQuality/consQuality.html' }else if(transcript.indexOf("人员管控")!=-1){ openUrl ='../personnelControl/personnelControl.html' }else if(transcript.indexOf("出入管理")!=-1){ openUrl ='../accessMge/accessMge.html' }else if(transcript.indexOf("告警管理")!=-1){ openUrl ='../alarmMge/alarmMge.html' }else { console.log("识别结果异常"); layer.msg('指令不正确', { icon: 6, time: 1000 }); return ; } console.log(openUrl) if(openUrl){ const li= $('#nav-right ul li'); for (let i = 0; i 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); }) } /* 初始化菜单 */ function setMenusData(us,data) { const nickName = us.nickName; 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 += '
  • ' + item.menuName + '

  • ' } else if ((index !== 0 && item.menuName !== '数据操作' && item.menuName!=='数据分析应用')) { html += '
  • ' + item.menuName + '

  • ' } else if (item.menuName === '数据操作') { // html += '
  • ' + item.menuName + '

  • ' } else if(item.menuName === '数据分析应用' && userArr.indexOf(nickName) === -1){ html += '
  • ' + item.menuName + '

  • ' } }) // // 新的数据分析 // if(userArr.indexOf(nickName) > -1){ // html += '
  • 数据分析

  • ' // html += '
  • 数据分析

  • ' // } // html += '
  • 安全帽

  • ' } $('#nav-right ul').empty().append(html); } } /* 初始化用户绑定标段工程 */ function setBandingPro(bidCodeList) { let html = ''; if (bidCodeList && bidCodeList.length > 0) { $.each(bidCodeList, function (index, item) { if (bidCode && bidCode === item.bidCode) { html += '' } else { html += '' } }) } $('#bidPro').empty().append(html); layui.form.render(); } /* 获取地址栏后的参数 */ const GetQueryString = (name) => { let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); let r = window.location.search.substr(1).match(reg); if (r != null) return decodeURIComponent(r[2]); return null; }; /* 返回省侧大屏 */ $('#nav-left button').on('click', function () { window.close(); }) /* 跳转后台 */ 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, '_blank'); } function openSc(){ const hrefUrl =screen_url; const newWindow = window.open(screen_url, 'screen_url'); } //进后台 function openBack(){ let sgccToken=sessionStorage.getItem("sgccToken") const hrefUrl = back_url+sgccToken; const newWindow = window.open(hrefUrl, '_blank'); }