test.php
5.29 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<link rel="stylesheet" type="text/css" href="/resource/static/h-ui/css/H-ui.min.css"/>
<?php
if (isset($styles) && is_array($styles)) {
foreach ($styles as $style) {
echo '<link rel="stylesheet" type="text/css" href="' . $style . '" />';
}
}
?>
<meta name="keywords" content="">
<meta name="description" content="">
<title>标题</title>
<script>
var apiBaseUrl = "http://151.28ms.com:8088/";
</script>
</head>
<body>
<script type="text/javascript" src="/resource/lib/jquery/1.9.1/jquery.min.js"></script>
<script>
(function ($) {
$.fn.serializeJson = function () {
var serializeObj = {};
var array = this.serializeArray();
var str = this.serialize();
$(array).each(function () {
if (serializeObj[this.name]) {
if ($.isArray(serializeObj[this.name])) {
serializeObj[this.name].push(this.value);
} else {
serializeObj[this.name] = [serializeObj[this.name], this.value];
}
} else {
serializeObj[this.name] = this.value;
}
});
return serializeObj;
};
})(jQuery);
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return null; //返回参数值
}
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
var hour = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
if (hour >= 1 && hour <= 9) {
hour = "0" + hour;
}
if (min >= 1 && min <= 9) {
min = "0" + min;
}
if (sec >= 1 && sec <= 9) {
sec = "0" + sec;
}
var currentdate = year + seperator1 + month + seperator1 + strDate + ' ' + hour + ':' + min + ':' + sec;
return currentdate;
}
function msg(msg) {
layer.msg(msg);
}
$.extend(true, $.fn.dataTable.defaults, {
sDom: '<"top">rt<"bottom"ip><"clear">',
aaSorting: [[1, "desc"]],
serverSide: true,
processing: true,
bSort: false,
iDisplayLength: 6,
bLengthChange: false,
ajax: {
url: apiBaseUrl + $('#table').attr('url'),
dataFilter: function (json) {
var ret = {}, json = jQuery.parseJSON(json);
ret.data = json.data || [];
var draw = getUrlParam('draw');
if (draw) {
ret.draw = draw;
}
ret.recordsTotal = 0;
ret.recordsFiltered = 0;
if (json.page) {
ret.recordsTotal = parseInt(json.page.totalNumber);
ret.recordsFiltered = parseInt(json.page.totalNumber);
}
return JSON.stringify(ret);
},
data: function (data) {
data.pageSize = data.length;
data.currentPage = parseFloat(data.start / data.length) + 1;
return data;
},
},
fnServerParams: function (aoData) {
delete aoData.columns;
aoData.startTime = $('#min').val() || '';
aoData.endTime = $('#max').val() || '';
aoData.departmentId = $('[name="departmentId"]').val() || '';
aoData.productId = $('[name="productId"]').val() || '';
aoData.createUser = $('[name="createUser"]').val() || '';
aoData.status = $('[name="status"]').val() || '';
aoData.modifyUser = $('[name="modifyUser"]').val() || '';
},
});
$('.bsearch').on('click', function () {
$('#table').DataTable().draw();
});
$('#min, #max').on('keyup', function () {
$('#table').DataTable().draw();
});
function resetHandler() {
$('#table').DataTable().draw();
}
</script>
<script>
$.ajax({
type: "GET",
url: "http://test.smalldebit.club/api/Debit/GetUserDebitRecords?userId=7",
beforeSend: function (request) {
request.setRequestHeader("token", "926EE68FEF39A83EBFAAC7AF632A4737");
},
success: function (result) {
console.log(result);
}
});
// $.get('http://test.smalldebit.club/api/Debit/GetUserDebitRecords?userId=7', function (d) {
// console.log(d)
// });
</script>
</body>
</html>