You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.4 KiB
71 lines
2.4 KiB
$.extend({
|
|
getUrlVars: function () {
|
|
var vars = [], hash;
|
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
|
for (var i = 0; i < hashes.length; i++) {
|
|
hash = hashes[i].split('=');
|
|
vars.push(hash[0]);
|
|
vars[hash[0]] = hash[1];
|
|
}
|
|
return vars;
|
|
},
|
|
getUrlVar: function (name) {
|
|
return $.getUrlVars()[name];
|
|
},
|
|
GetDateStr: function (AddDayCount) {
|
|
var dd = new Date();
|
|
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
|
|
var y = dd.getFullYear();
|
|
var m = dd.getMonth() + 1; //获取当前月份的日期
|
|
var d = dd.getDate();
|
|
return m + "-" + d;
|
|
},
|
|
|
|
getNowFormatDate:function () {
|
|
var date = new Date();
|
|
var seperator1 = "-";
|
|
var year = date.getFullYear();
|
|
var month = date.getMonth() + 1;
|
|
var strDate = date.getDate();
|
|
if (month >= 1 && month <= 9) {
|
|
month = "0" + month;
|
|
}
|
|
if (strDate >= 0 && strDate <= 9) {
|
|
strDate = "0" + strDate;
|
|
}
|
|
var currentdate = year + seperator1 + month + seperator1 + strDate;
|
|
return currentdate;
|
|
},
|
|
/*
|
|
*下载文件
|
|
* options:{
|
|
* url:'', //下载地址
|
|
* isNewWinOpen:false,是否新窗口打开
|
|
* data:{name:value}, //要发送的数据
|
|
* method:'post'
|
|
* }
|
|
*/
|
|
downLoadFile: function (url, data, method, isNewWinOpen) {
|
|
var config = {
|
|
url: url,
|
|
data: (data = data || {}),
|
|
method: (method = method || "GET"),
|
|
isNewWinOpen: (isNewWinOpen = isNewWinOpen || false)
|
|
};
|
|
var $iframe = $('<div style="display: none"><iframe id="down-file-iframe" name="down-file-iframe" /></div>');
|
|
var $form = $('<form target="down-file-iframe" method="' + config.method + '" action="' + config.url + '" />');
|
|
if (config.isNewWinOpen) {
|
|
$form.attr("target", "_blank");
|
|
}
|
|
/*拼接参数*/
|
|
for (var key in config.data) {
|
|
$form.append('<input type="hidden" name="' + key + '" value="' + config.data[key] + '" />');
|
|
}
|
|
$iframe.append($form);
|
|
$(document.body).append($iframe);
|
|
$form.submit();
|
|
// setTimeout(function () {
|
|
// $iframe.remove();
|
|
// }, 4000)
|
|
}
|
|
});
|
|
|