//var IP = "http://47.104.149.73:1991";//接口IP
|
// var IP = "http://172.16.71.101:8082/";//接口IP
|
var IP = "http://localhost:13243/api";
|
//var IP = "http://192.168.220.130:8081/api";
|
//var IP = "http://192.168.220.130:8081/api";
|
//var IP = "http://192.168.1.226:8086";
|
|
var pageCnt = 50;
|
var pageLimits = [10, 15, 20, 30, 50, 70, 100];
|
function sendData(url, data, type, callbackFun) {
|
var deferred = $.Deferred();
|
if (type != "get") {
|
data = JSON.stringify(data);
|
}
|
if (url!=IP+"/WeatherForecast/Login") {
|
if (!$.cookie('token')) {
|
callbackFun("登录人信息已失效1");
|
}
|
}
|
$.ajax({
|
url: url,
|
data: data,
|
type: type,
|
headers: {
|
"Content-Type": "application/json; charset=UTF-8",
|
"ToKen":$.cookie('token')
|
},
|
timeout: 45000,
|
async: true,
|
cache: false,
|
beforeSend: function (xhr, settings) {},
|
success: function (res, status, xhr) {
|
callbackFun(res);
|
},
|
error: function (res, status, error) {
|
callbackFun(res, status, error);
|
layer.msg("登录人信息已失效2", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
window.parent.location.reload(); //刷新父页面
|
window.parent.location.href="/views/Login.html";
|
});
|
},
|
});
|
}
|
function synData(url, data, type, callbackFun) {
|
var deferred = $.Deferred();
|
if (type != "get") {
|
data = JSON.stringify(data);
|
}
|
if (url!=IP+"/WeatherForecast/Login") {
|
if (!$.cookie('token')) {
|
callbackFun("登录人信息已失效3");
|
}
|
}
|
$.ajax({
|
url: url,
|
data: data,
|
type: type,
|
headers: {
|
"Content-Type": "application/json; charset=UTF-8",
|
"ToKen":$.cookie('token')
|
},
|
timeout: 45000,
|
async: false,
|
cache: false,
|
beforeSend: function (xhr, settings) {},
|
success: function (res, status, xhr) {
|
callbackFun(res);
|
},
|
error: function (res, status, error) {
|
callbackFun(res, status, error);
|
layer.msg("登录人信息已失效5", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
},
|
});
|
}
|
|
// 根据时间戳转换为时间格式
|
function formatDate(str) {
|
if (str == null || str == "" || str == undefined) {
|
return "";
|
} else {
|
var date = new Date(str
|
//parseInt(str.replace("/Date(", "").replace(")/", ""), 10)
|
);
|
Y = date.getFullYear();
|
M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1);
|
D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
|
h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours());
|
m = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
return Y +"-"+ M +"-" +D+" " + h+":" + m + ":" + s;
|
}
|
}
|
// 根据时间戳转换为时间格式:年-月-日
|
function formatDate2(str) {
|
if (str == null || str == "" || str == undefined) {
|
return "";
|
} else {
|
var date = new Date(str
|
//parseInt(str.replace("/Date(", "").replace(")/", ""), 10)
|
);
|
Y = date.getFullYear() + "-";
|
M =
|
(date.getMonth() + 1 < 10
|
? "0" + (date.getMonth() + 1)
|
: date.getMonth() + 1) + "-";
|
D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
|
h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
|
m = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
return Y + M + D;
|
}
|
}
|
|
//获取浏览器参数
|
function getQueryString(name) {
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
var r = window.location.search.substr(1).match(reg);
|
if (r != null) return unescape(r[2]);
|
return null;
|
}
|
|
// 同步方法
|
function sendDataAsync(url, data, type, callbackFun) {
|
var deferred = $.Deferred();
|
data = JSON.stringify(data);
|
$.ajax({
|
url: url,
|
data: data,
|
type: type,
|
headers: {
|
"Content-Type": "application/json",
|
},
|
timeout: 45000,
|
async: false,
|
cache: false,
|
beforeSend: function (xhr, settings) {},
|
success: function (res, status, xhr) {
|
callbackFun("登录人信息已失效6");
|
},
|
error: function (xhr, status, error) {
|
console.log("失败了");
|
console.log(xhr);
|
},
|
});
|
}
|
|
//获取除搜索条件外高度
|
function GetTableHeight() {
|
var bodyHeight = $("#body").outerHeight();
|
var topHeight = $("#top").outerHeight();
|
var centerHeight = $("#center").outerHeight();
|
|
var hh = bodyHeight - topHeight-centerHeight - 26 ;//6是body上内边距
|
return hh;
|
}
|
//获取除搜索条件外60%高度
|
function GetTableTopHeight() {
|
var bodyHeight = $("#body").outerHeight();
|
var topHeight = $("#top").outerHeight();
|
var centerHeight = $("#center").outerHeight();
|
// console.log(bodyHeight);
|
// console.log(topHeight);
|
// console.log(centerHeight);
|
|
var hh = bodyHeight - topHeight -centerHeight - 26 ;//6是body上内边距、20是layui-card-body上下内边距
|
var h1 = parseInt(hh*0.6)
|
return h1;
|
}
|
//获取除搜索条件外40%高度
|
function GetTableBottomHeight() {
|
var bodyHeight = $("#body").outerHeight();
|
var topHeight = $("#top").outerHeight();
|
var centerHeight = $("#center").outerHeight();
|
|
|
var hh = bodyHeight - topHeight-centerHeight - 26 ;//6是body上内边距
|
var h2 = parseInt(hh*0.4)
|
return h2;
|
}
|
|
//判断是否正整数 true 正整数 false 其他
|
function isIntNum(val){
|
var regPos = /^\d+$/;
|
//var regNeg = /^\-[1-9][0-9]"*$/;
|
|
if (regPos.test(val))//&®Neg.test(val))
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|