123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- //页面初始化
- window.onload=function(){
- if (typeof(document.onselectstart) != "undefined") {
- // IE禁止元素选取
- document.onselectstart = function (event){
- if(event.target.tagName!="INPUT"){
- return false;
- }
- }
- }
-
- AccessAuthService.init();
- WebSocketBase.socket.onerror = function () {
- logEvent("HealthManagerService startSession callback");
- let tips = "终端链接失败"
- ModalStyle(tips, 'pathN')
- };
- logEvent("initinar onload");
- };
- /**
- * @description: modal显示设置
- * @param {type}
- * @return:
- */
- function ModalStyle(tips,pathType){
- $('#loadContent').fadeOut('slow')
- $('#errTips').html(tips);
- let path = (pathType == 'pathY') ? './images/success.png' : './images/fail.png'
- }
- /**
- * @description: 输入不为null校验
- * @param {type}
- * @return:
- */
- function RegExpNull(vals){
- let IsNull = false;
- let RegxNull = /\S/;
- for(let item in vals){
- if( !RegxNull.test(vals[item]) ){
- let tips = '信息填写不完整'
- ModalStyle(tips,'pathN');
- IsNull = true
- break;
- }
- }
- return IsNull;
- }
- let timeout=60000;
- /**
- * @description: 下载集中配置
- * @param {type}
- * @return:
- */
- let ti = 29;
- let timeChange = null;
- function clock () {
- if (ti > 0) {
- ti = ti - 1;
- document.getElementById('restart-time').innerHTML = ti;
- } else {
- clearInterval(timeChange);
- ti = 29;
- $('#boxRestart').fadeOut('slow');
- exitTipsColck();
- DeviceService.RebootShell();
- }
- };
- function restart(){
- clearInterval(timeChange);
- ti = 29;
- $('#boxRestart').fadeOut('slow');
- exitTipsColck();
- DeviceService.RebootShell();
- }
- // 扫码登录后接收code
- window.onmessage = (event) => {
- console.log('event----',event)
- if (event && event.data.code) {
- //接收code参数,格式{code: "********",state:"***********"}
- ResetRSA(event.data.code)
- $('.iframe-box').fadeOut();
- $('.result-wrap').fadeIn();
- $('.tipsing').html('重置设备密钥中,稍后自动重启应用···')
- let date = +new Date
- let dateTime = getFamtterTimer(date)
- $('#currDate').html(dateTime)
- }
- };
- /**
- * @description: 密钥初始化
- * @param {type}
- * @return:
- */
- function ResetRSA(code){
- let req = new Request(),reqIn={};
- // reqIn.strAuthServer = HostUrl;
- reqIn.strUserID = code
- reqIn.strPassword = '88888888' //默认值,后台不做校验
- req.timeout = 60000
- req = Object.assign({},req,reqIn)
- if(reqIn.strUserID==''){
- let tips = '用户名不能为空'
- ModalStyle(tips,'pathN')
- return;
- }
- $('#loadContent').fadeIn('slow')
- // timeoutFn
- let timeoutFn= setTimeout(function(){
- $('#loadContent').fadeOut('slow')
- let tips = '请求超时'
- ModalStyle(tips,'pathN')
- },timeout)
- logEvent("AccessAuthService->InitializeNew");
- //重置密钥
- AccessAuthService.InitializeNew(req, function(ret) {
- logEvent("InitializeNew ret: "+JSON.stringify(ret));
- console.log("InitializeNew ret: "+JSON.stringify(ret));
- if(ret){
- $('#loadContent').fadeOut('slow');
- clearTimeout(timeoutFn)
- }
- if(ret.errorCode == 0) {
- if(ret.Errcode !== 0)
- {
- let tips = Number(ret.Errcode).toString(16)+ (ret.ErrMsg?ret.ErrMsg:'重置密钥失败')
- ModalStyle(tips,'pathN')
- }else{
- let tips = '加载DES主密钥成功'
- ModalStyle(tips,'pathY')
- setTimeout(()=>{
- DeviceService.RebootShell() //初始化成功后自动重启应用
- },3000)
- }
- }
- else{
- let tips = '重置密钥失败'
- ModalStyle(tips,'pathN')
- }
- });
- }
- function exit(){
- // 进入的方式,决定退出的方式
- if(window.location.href.indexOf('errPage')>-1){
- $('.iframeDiv').fadeOut();
- $('.iframe-box').fadeOut();
- $('.result-wrap').fadeOut();
- }else{
- let req = {};
- req.messageType = 0;
- req.command = 'ChromiumClose';
- sendRequest(req);
- }
- }
- function sendRequest(request){
- try{
- window.cefQuery({
- request: JSON.stringify(request),
- onSuccess: function() {
- console.log('window.cefQuery success');
- },
- onFailure: function(error_code, error_message) {
- console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')');
- let tips = error_code + error_message
- ModalStyle(tips,'pathN')
- }
- });
- }
- catch(ex) {
- console.log('window.cefQuery exception ',ex);
- let tips = '退出失败'
- ModalStyle(tips,'pathN')
- }
- }
|