listMange.js
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var listMangeJS = {};
var urls = {
"reportbyday": "/marketing/hapi/reportbyday",
"reportbymonth": "/marketing/hapi/reportbymonth"
};
listMangeJS.list = function() {
//var status = $("#status").val();
var status = 1;
var begin_time = $("#begin_time").val();
var end_time = $("#end_time").val();
var type = $("input[name='type']:checked").val();
var url = "";
if (type == 0) {
url = _REQUESTURL + urls.reportbyday;
} else {
url = _REQUESTURL + urls.reportbymonth;
}
$.ajax({
"url": url,
"data": { beginTime: begin_time, endTime: end_time, page: 1, size: 15 },
"success": function(res) {
if (res.success && res.code == 2000) {
if (res.content) {
var context = "<thead>" +
"<tr>" +
"<th>时间</th>" +
"<th>注册数量</th>" +
"<th>领取数量</th>" +
"</tr>" +
"</thead>";
if (res.content) {
$.each(res.content, function(k, v) {
context = context +
"<tr>" +
" <td>" + _nullValue(k) + "</td>" +
" <td>" + (v.registerCount) + "</td>" +
" <td>" + (v.genereportCount) + "</td>";
context = context +
" </td>" +
"</tr>";
});
}
$("#data_table").html(context);
} else {}
} else {
alert("系统错误");
}
}
});
}
$(function() {
var myDate = new Date();
var lw = new Date(myDate - 1000 * 60 * 60 * 24 * 30); //最后一个数字30可改,30天的意思
var lastY = lw.getFullYear();
var lastM = lw.getMonth() + 1;
var lastD = lw.getDate();
var startdate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD); //三十天之前日期
var nowY = myDate.getFullYear();
var nowM = myDate.getMonth() + 1;
var nowD = myDate.getDate();
var enddate = nowY + "-" + (nowM < 10 ? "0" + nowM : nowM) + "-" + (nowD < 10 ? "0" + nowD : nowD); //当前日期
$("#begin_time").val(startdate);
$("#end_time").val(enddate);
//时间空间初始化
jeDate({
dateCell: "#begin_time",
format: "YYYY-MM-DD",
isinitVal: false,
isTime: true, //isClear:false,
okfun: function(val) {}
})
//时间空间初始化
jeDate({
dateCell: "#end_time",
format: "YYYY-MM-DD",
isinitVal: false,
isTime: true, //isClear:false,
okfun: function(val) {}
})
listMangeJS.list();
$("#search").on("click", function() {
listMangeJS.list();
});
$(document).keypress(function(e) {
// 回车键事件
if (e.which == 13) {
listMangeJS.list();
return;
}
});
});