var accTok = localStorage.getItem("_yz_TT") != "null" && localStorage.getItem("_yz_TT") != null ? JSON.parse(
localStorage.getItem("_yz_TT")).ysyTok : "";
var _Tok = localStorage.getItem("_yz_TT") != "null" && localStorage.getItem("_yz_TT") != null ? JSON.parse(localStorage
.getItem("_yz_TT")).yzTok : "";
var staticUrl = "http://10.60.11.142:32000/yzDemo";
// var vipUrl = "https://www.enstation.vip:8083/rueigao-admin";
var vipUrl = "https://www.enstation.com:8083/ruico/rueigao-admin";
// var vipUrl = "https://192.168.1.107:8081/rueigao-admin";
// var vipUrl = "https://10.60.11.150:8081/rueigao-admin";
function ShowLoading(_msg, _type) {
var boarddiv = "
";
$(document.body).append(boarddiv);
if (_type == 1) {
setTimeout(() => {
$(".mask_").remove();
}, 2000);
}
}
function hideLoading() {
setTimeout(() => {
$(".mask_").remove();
}, 100);
}
var yzkj = {
options: null,
open: function(options) {
var _btn = options.btn != undefined ? `
` : '';
var _titl = options.title != undefined ? `` : '';
var boarddiv = `
${_titl}
${options.content}
${_btn}
`;
$(document.body).append(boarddiv);
yzkj.options = options;
},
close: function() {
$(".mask").remove();
},
load: function(_id) {
var _div = '' +
'
';
$(document.body).append(_div);
},
closeLoad: function(_id) {
$("#" + _id).remove();
}
}
$(document).on("click", ".open_title .icon-cha", function() {
$(".mask").remove();
})
$(document).on("click", ".open_btn button[name='yue']", function(e) {
if (yzkj.options.yes != undefined) {
yzkj.options.yes();
}
})
$(document).on("click", ".open_btn button[name='no']", function() {
if (yzkj.options.no != undefined) {
yzkj.options.no();
}
$(".mask").remove();
})
function goBack(num) {
top.location.href = "../MainPh.html?sn=" + num;
}
function checkLogin() {
if (localStorage.getItem("_yz_TT") != "null" && localStorage.getItem("_yz_TT") != null) {
} else {
top.location.href = staticUrl+"/Login.html?v="+(new Date().getTime());
return;
}
let _type = localStorage.getItem("ptType");
if (_type != null && _type != "null" && _type != undefined) {
var sheetObj = $("#linkSource")[0];
if (sheetObj != undefined) {
setStyle(sheetObj, ".topBox", ["height", "padding"], ["80px", "40px"]);
setStyle(sheetObj, ".topParen", ["padding"], ["80px 0 0"]);
setStyle(sheetObj, ".topBox .icon-left", ["top"], ["48px"]);
}
} else {
}
}
function setStyle(Obj, Text, _name, _val) {
var _Sheet = Obj.sheet;
var rules = _Sheet.cssRules;
var rule;
var selectorText;
for (i = 0; i < rules.length; i++) {
rule = rules[i];
selectorText = rule.selectorText;
if (selectorText == null || selectorText == "") {
continue;
} else if (selectorText === Text) {
for (var i = 0; i < _name.length; i++) {
rule.style.setProperty(_name[i], _val[i]);
}
return;
}
}
}
function getTime(_time) {
let date = _time
const yyyy = date.getFullYear();
const MM = date.getMonth() + 1 > 9 ? date.getMonth() + 1 : '0' + (date.getMonth() + 1);
const dd = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
const HH = date.getHours() > 9 ? date.getHours() : '0' + date.getHours();
const mm = date.getMinutes() > 9 ? date.getMinutes() : '0' + date.getMinutes();
const ss = date.getSeconds() > 9 ? date.getSeconds() : '0' + date.getSeconds();
return [yyyy + '-' + MM + '-' + dd, 'T' + HH + ':' + mm, " " + HH + ':' + mm + ':' + ss];
}
function dayChange(a, num) {
var timestamp = Date.parse(new Date(a.replace(/-/g, '\/')));
var newTimestamp = timestamp + num * 24 * 60 * 60 * 1000;
var date = new Date(newTimestamp);
if ((new Date() - new Date(date)) <= 0) {
ShowLoading('不能再往下翻啦', 1);
return;
} else {
return date;
}
}
// 判断是苹果端还是安卓端
function IsIOS() {
var u = navigator.userAgent;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
if (isiOS) {
return true;
} else if (isAndroid) {
return false;
}
}
// 全屏事件
function requesetFullScreen(elem) {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen();
} else if (elem.msRequestFullScreen) {
elem.msRequestFullScreen();
} else {
alert('当前浏览器不支持全屏,请更换浏览器')
return false
}
}
// 退出登录
function loginOut() {
localStorage.removeItem("_yz_TT");
localStorage.removeItem("_yz_TU");
localStorage.removeItem("shipSn");
localStorage.removeItem("deList");
top.location.href = staticUrl+"/Login.html?v="+(new Date().getTime());
}
// 折线图X轴
function setXAxis() {
for (var i = 0; i < _ChartU.length; i++) {
let _ecid = echarts.init(document.getElementById(_ChartU[i] + ''));
_myChart.push(_ecid);
}
_XAxis = [];
for (var i = 0; i < 12; i++) {
_XAxis = [..._XAxis, ...[i * 2, '', '', '', '', '', '', '', '', '', '', '']];
}
}
// GET请求
function tokenAjax(opts, data,_who) {
return new Promise(function(resolve, reject) {
$.ajax({
url: vipUrl + opts.url,
type: opts.type,
dataType: "json",
async:_who == "port"?true: false,
data: data,
headers:{
"Authorization":"Bearer "+_Tok
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
// ajaxErr();
},
//更新日志列表
success: function(dart) {
if(dart.code == 401){
// ajaxErr();
}else if(dart.code == 200||dart.result == "ok"||_who == "port"){
resolve(dart);
}else{
ShowLoading(dart.msg, 1)
}
}
});
})
}
// POST请求
function tokenPostAjax(opts,data,_yb) {
return new Promise(function(resolve, reject) {
$.ajax({
url: vipUrl + opts.url,
type: opts.type,
dataType: "JSON",
contentType: 'application/json; charset=UTF-8',
async: _yb !=undefined?true : false,
headers:{
"Authorization":"Bearer "+_Tok
},
data: JSON.stringify(data),
error: function(XMLHttpRequest, textStatus, errorThrown) {
// ajaxErr();
},
success: function(dart) {
if(dart.code == 401){
// ajaxErr();
}else if(dart.code == 200||dart.result == "ok"){
resolve(dart);
}else{
ShowLoading(dart.msg, 1)
}
}
});
})
}
function ajaxErr(){
localStorage.removeItem("_yz_TT");
localStorage.removeItem("_yz_TU");
top.location.href= staticUrl+"/Login.html?v="+(new Date().getTime());
}