-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.html
440 lines (346 loc) · 14.2 KB
/
user.html
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Dashboard - Bootstrap Admin</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link href="./css/bootstrap.min.css" rel="stylesheet"/>
<link href="./css/bootstrap-responsive.min.css" rel="stylesheet"/>
<link href="./css/font-awesome.css" rel="stylesheet"/>
<link href="./css/adminia.css" rel="stylesheet"/>
<link href="./css/adminia-responsive.css" rel="stylesheet"/>
<link href="./css/pages/dashboard.css" rel="stylesheet"/>
<script src=" https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<style>
.td {
width: 100px;
overflow: hidden
}
</style>
<body>
<!--<a href="javascript:history.go(-1);" style="display: block; /* 设置为块元素 */-->
<!-- text-align: center;-->
<!-- border: 1px solid #ccc;-->
<!-- font-size: 16px;-->
<!-- font-weight: 600;-->
<!-- color: #95B8CE;" >返回上一页</a>-->
<div id="content" style="background: linear-gradient(150deg, #D8E3E7 0%, #a0e8f5 70%);">
<div class="container">
<div class="span12">
<!--用户信息-->
<div class="account-container">
<div class="account-avatar">
<img src="./img/logo.png" alt="" class="thumbnail"/>
</div> <!-- /account-avatar -->
<div class="account-details">
<span id="account-name">用户名</span>
<span class="account-role">权限:用户权限</span>
<span class="account-actions">
<span id="account-email">用户邮箱</span>
</span>
</div> <!-- /account-details -->
</div> <!-- /account-container -->
<!--标签栏-->
<h1 class="page-title">
<i class="icon-home"></i>
整体信息
</h1>
<!--标签栏-->
<div class="stat-container">
<div class="stat-holder">
<div class="stat" id="counts">
<span>564</span>
总查询次数
</div> <!-- /stat -->
</div> <!-- /stat-holder -->
<div class="stat-holder">
<div class="stat" id="days">
<span>423</span>
学习天数
</div> <!-- /stat -->
</div> <!-- /stat-holder -->
<div class="stat-holder">
<div class="stat" id="todays">
<span>2</span>
今日查词
</div> <!-- /stat -->
</div> <!-- /stat-holder -->
</div> <!-- /stat-container -->
<!--chart-->
<div class="widget">
<div class="widget-header">
<h3>近日查询统计</h3>
</div> <!-- /widget-header -->
<div class="widget-content">
<div id="area-chart" class="chart-holder"></div> <!-- /area-chart -->
</div> <!-- /widget-content -->
</div> <!-- /widget -->
<!--chart-->
<div class="widget">
<div class="widget-header">
<h3>查询类别统计</h3>
</div> <!-- /widget-header -->
<div class="widget-content">
<div id="pie-chart" class="chart-holder"></div> <!-- /donut-chart -->
</div> <!-- /widget-content -->
</div> <!-- /widget -->
<!--table-->
<div class="widget widget-table">
<div class="widget-header">
<i class="icon-th-list"></i>
<h3>查询记录</h3>
</div> <!-- /widget-header -->
<div class="widget-content" style="height:200px;overflow-y:scroll">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>查询记录</th>
<th>查询模式</th>
<th>查询时间</th>
<th>内容概要</th>
<th> </th>
</tr>
</thead>
<tbody id="contain">
<tr>
<td>1</td>
<td>Michael</td>
<td>Jordan</td>
<td>@mjordan</td>
</tr>
<tr>
<td>2</td>
<td>Magic</td>
<td>Johnson</td>
<td>@mjohnson</td>
</tr>
<tr>
<td>3</td>
<td>Charles</td>
<td>Barkley</td>
<td>@cbarkley</td>
</tr>
<tr>
<td>4</td>
<td>Karl</td>
<td>Malone</td>
<td>@kmalone</td>
</tr>
<tr>
<td>5</td>
<td>David</td>
<td>Robinson</td>
<td>@drobinson</td>
</tr>
<tr>
<td>6</td>
<td>Reggie</td>
<td>Miller</td>
<td>@rmiller</td>
</tr>
<tr>
<td>7</td>
<td>Clyde</td>
<td>Drexler</td>
<td>@cdrexler</td>
</tr>
<tr>
<td>8</td>
<td>Hakeem</td>
<td>Olajuwon</td>
<td>@holajuwon</td>
</tr>
</tbody>
</table>
</div> <!-- /widget-content -->
</div> <!-- /widget -->
</div> <!-- /span9 -->
</div> <!-- /container -->
</div> <!-- /content -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./js/jquery-1.7.2.min.js"></script>
<script src="./js/excanvas.min.js"></script>
<script src="./js/jquery.flot.js"></script>
<script src="./js/jquery.flot.pie.js"></script>
<script src="./js/jquery.flot.orderBars.js"></script>
<script src="./js/jquery.flot.resize.js"></script>
<!-- 画图的js都在charts下面 可以根据要求改 -->
<script src="./js/bootstrap.js"></script>
<script src="./js/charts/bar.js"></script>
<script src="./js/charts/area.js"></script>
<script src="./js/charts/line.js"></script>
<script>
// 根据数组的内容,生成页面中的table表格
// 建立数组
var arr = [];
window.onload = function () {
console.log(localStorage.string);
//table
$.ajax({
type: "GET",
url: "https://ppreader.creativecc.cn/api/others/getqueryinfo" + "?usrid=" + localStorage.string,
data: "",
success: function (data) {
console.log(data);
if (data['status'] == 200) {
data1 = data['res'];
for (var i = 0; i < data1.length; i++) {
var arr1 = [data1[i]['content'], data1[i]['mode'], data1[i]['time'], data1[i]['result']]
arr.push(arr1);
}
table();
} else {
localStorage.string = 1000;
}
},
error: function (data) {
alert("error!")
}
});
//others
$.ajax({
type: "GET",
url: "https://ppreader.creativecc.cn/api/others/getquerycounts" + "?usrid=" + localStorage.string,
data: "",
success: function (data) {
console.log(data);
if (data['status'] == 200) {
const counts = document.getElementById("counts");
const todays = document.getElementById("todays");
const days = document.getElementById("days");
counts.innerHTML = "<span>" + data['all'] + "</span>" + "总查询次数";
todays.innerHTML = "<span>" + data['today'] + "</span>" + "今日查词";
days.innerHTML = "<span>" + data['days'] + "</span>" + "学习天数";
var datas = data['res'];
area(datas);
var datas2 = data['modedict'];
pie(datas2);
} else {
localStorage.string = 1000;
}
},
error: function (data) {
alert("error!")
}
});
$.ajax({
type: "GET",
url: "https://ppreader.creativecc.cn/api/others/getuserinfo" + "?usrid=" + localStorage.string,
data: "",
success: function (data) {
console.log(data);
const name = document.getElementById("account-name");
const email = document.getElementById("account-email");
name.innerText = "用户名:" + data['username'];
email.innerText = "用户邮箱:" + data['email'];
},
error: function (data) {
alert("error!")
}
});
}
function table() {
// 定义变量,存储生成的字符串内容,使用 += 拼接字符串形式
var str = '';
//外层循环,生成tr
for (var i = 0; i <= arr.length - 1; i++) {
// 外层循环生成tr标签,循环几次,就生成几个tr标签
// 因为tr标签中还要有td内容,要将两个tr标签,分开,写成拼接的形式
str += '<tr>';
// 第一个单元格是单独生成的,不参与内层循环,是 当前 外层循环 索引下标+1
str += `<td>${i + 1}</td>`;
//当前行,对应的二维数组,循环的对象是 arr[i] ,
//生成 arr[i] 的所有的索引下标,通过索引下标,获取对应的数据。
// 起始数值是0 终止数值是 arr[i]的最大索引下标,arr[i]的length-1
for (var j = 0; j <= arr[i].length - 1; j++) {
// 每一个单元的内容,就是当前二维数组单元的数据内容
// 获取二维数组, 数组变量[一维索引][二维索引] 一维索引是i 二维索引是j
str += `<td>${arr[i][j]}</td>`;
}
str += '</tr>';
}
// 将定义好的内容,写入到taody标签中
contain.innerHTML = str;
}
function area(data) {
// we use an inline data source in the example, usually data would
// be fetched from a server
var res = [];
var xlabel = new Array();
var count = 0;
for (const key in data) {
res.push([count, data[key]]);
xlabel.push([count++, key]);
}
// setup plot
var options = {
yaxis: {min: 0, max: data.length},
xaxis: {min: 0, max: data.length, ticks: xlabel},
colors: ["#BFD3DD", "#3C4049", "#95B8CE", "#BBB"],
series: {
lines: {
lineWidth: 2,
fill: true,
fillColor: {colors: [{opacity: 0.6}, {opacity: 0.2}]},
steps: false
}
}
};
var plot = $.plot($("#area-chart"), [res], options);
}
function pie(datas) {
console.log(datas);
console.log(datas[0].keys);
var data = [];
for (var key in datas) {
data.push({label: 'mode' + key, data: datas[key]});
}
$.plot($("#pie-chart"), data,
{
colors: ["#BFD3DD", "#3C4049", "#95B8CE", "#BBB"],
series: {
pie: {
show: true,
radius: 1, //半径
label: {
show: true,
radius: 2 / 3,
formatter: function (label, series) {
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">' + label + '<br/>' + Math.round(series.percent) + '%</div>';
},
threshold: 0.03 //这个值小于0.03,也就是3%时,label就会隐藏
}
}
},
legend: {
show: false
}
});
}
$("#pie-chart").bind("plothover", pieHover);
$("#pie-chart").bind("plotclick", pieClick);
function pieHover(event, pos, obj) {
if (!obj)
return;
percent = parseFloat(obj.series.percent).toFixed(2);
$("#hover").html('<span style="font-weight: bold; color: ' + obj.series.color + '">' + obj.series.label + ' (' + percent + '%)</span>');
}
function pieClick(event, pos, obj) {
if (!obj)
return;
percent = parseFloat(obj.series.percent).toFixed(2);
alert('' + obj.series.label + ': ' + percent + '%');
}
</script>
</body>
</html>