优化后台首页显示
This commit is contained in:
parent
89fb136559
commit
de7816122f
@ -223,6 +223,21 @@ function hour_document($arrData)
|
|||||||
return $documents;
|
return $documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//访问按日期归档统计
|
||||||
|
function date_document($arrData)
|
||||||
|
{
|
||||||
|
$documents = array();
|
||||||
|
foreach ($arrData as $index => $value) {
|
||||||
|
$archivesTime = date("Y-m-d", $value['create_time']);
|
||||||
|
if (empty($documents[$archivesTime])) {
|
||||||
|
$documents[$archivesTime] = 1;
|
||||||
|
} else {
|
||||||
|
$documents[$archivesTime] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $documents;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员操作日志
|
* 管理员操作日志
|
||||||
* @param string $type 操作类型 login add edit view delete
|
* @param string $type 操作类型 login add edit view delete
|
||||||
|
@ -304,14 +304,19 @@ class Api extends BaseController
|
|||||||
{
|
{
|
||||||
$param = get_params();
|
$param = get_params();
|
||||||
$first_time = time();
|
$first_time = time();
|
||||||
$second_time = time() - 86400;
|
$second_time = $first_time - 86400;
|
||||||
|
$three_time = $first_time - 86400*365;
|
||||||
$begin_first = strtotime(date('Y-m-d', $first_time) . " 00:00:00");
|
$begin_first = strtotime(date('Y-m-d', $first_time) . " 00:00:00");
|
||||||
$end_first = strtotime(date('Y-m-d', $first_time) . " 23:59:59");
|
$end_first = strtotime(date('Y-m-d', $first_time) . " 23:59:59");
|
||||||
$begin_second = strtotime(date('Y-m-d', $second_time) . " 00:00:00");
|
$begin_second = strtotime(date('Y-m-d', $second_time) . " 00:00:00");
|
||||||
$end_second = strtotime(date('Y-m-d', $second_time) . " 23:59:59");
|
$end_second = strtotime(date('Y-m-d', $second_time) . " 23:59:59");
|
||||||
|
$begin_three = strtotime(date('Y-m-d', $three_time) . " 00:00:00");
|
||||||
$data_first = Db::name('UserLog')->field('create_time')->whereBetween('create_time', "$begin_first,$end_first")->select();
|
$data_first = Db::name('UserLog')->field('create_time')->whereBetween('create_time', "$begin_first,$end_first")->select();
|
||||||
$data_second = Db::name('UserLog')->field('create_time')->whereBetween('create_time', "$begin_second,$end_second")->select();
|
$data_second = Db::name('UserLog')->field('create_time')->whereBetween('create_time', "$begin_second,$end_second")->select();
|
||||||
return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second)]);
|
|
||||||
|
$data_three = Db::name('UserLog')->field('create_time')->whereBetween('create_time', "$begin_three,$end_first")->select();
|
||||||
|
|
||||||
|
return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three'=>date_document($data_three)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,35 +2,18 @@
|
|||||||
|
|
||||||
{block name="style"}
|
{block name="style"}
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.clearfix {
|
.table-title {
|
||||||
display: block;
|
font-size: 18px;
|
||||||
|
font-weight: 800;
|
||||||
|
padding: 15px 0 5px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clearfix:after {
|
|
||||||
content: ".";
|
|
||||||
display: block;
|
|
||||||
height: 0;
|
|
||||||
clear: both;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
* html .clearfix {
|
|
||||||
height: 0.1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel-right {
|
|
||||||
border-bottom: 1px solid #e8e8e8;
|
|
||||||
padding: 0 20px 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel-num table {
|
.panel-num table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-num td {
|
.panel-num td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
width: 16.6%;
|
width: 20%;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
border-left: 1px solid #eee
|
border-left: 1px solid #eee
|
||||||
}
|
}
|
||||||
@ -46,24 +29,20 @@
|
|||||||
color: #009688;
|
color: #009688;
|
||||||
}
|
}
|
||||||
|
|
||||||
.latest-news {
|
.layui-timeline-title {
|
||||||
padding-top: 12px;
|
|
||||||
padding-bottom: 30px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.latest-news .layui-timeline-title {
|
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.latest-news .layui-timeline-item {
|
.layui-timeline-item {
|
||||||
padding-bottom: 1px;
|
padding-bottom: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-timeline-title span {
|
.layui-timeline-title span {
|
||||||
color: #999
|
color: #999
|
||||||
}
|
}
|
||||||
|
.layui-timeline{
|
||||||
|
padding-bottom: 30px;
|
||||||
|
}
|
||||||
.panel-more {
|
.panel-more {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
@ -72,103 +51,22 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
background: linear-gradient(rgba(225, 225, 225, 0), rgba(225, 225, 225, .8));
|
background: linear-gradient(rgba(225, 225, 225, 0), rgba(225, 225, 225, .9));
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-more a {
|
.panel-more a {
|
||||||
color: #0088FF
|
color: #0088FF
|
||||||
}
|
}
|
||||||
|
|
||||||
.index-row {
|
|
||||||
margin-right: 351px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel {
|
|
||||||
padding: 0 20px;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 800;
|
|
||||||
padding: 20px 0 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 800;
|
|
||||||
padding: 20px 0 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.row-right {
|
|
||||||
width: 350px;
|
|
||||||
float: right;
|
|
||||||
border-left: 1px solid #e8e8e8;
|
|
||||||
background-color: #f7f7f7;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
{/block}
|
{/block}
|
||||||
<!-- 主体 -->
|
<!-- 主体 -->
|
||||||
{block name="body"}
|
{block name="body"}
|
||||||
<div style="background-color: #fff;">
|
|
||||||
<div class="row-right">
|
|
||||||
<div class="panel-right">
|
|
||||||
<div class="table-title">最新动态</div>
|
|
||||||
<div class="latest-news">
|
|
||||||
<ul class="layui-timeline" id="logs">
|
|
||||||
</ul>
|
|
||||||
<div class="panel-more"><a href="/admin/api/log_list/">查看更多动态</a></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="panel-right">
|
|
||||||
<div class="table-title">系统信息</div>
|
|
||||||
<table class="layui-table" lay-skin="" lay-size="sm">
|
|
||||||
{if condition="($install == true)"}
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="color: #E94335;">提醒:发现app目录下的install文件夹没删除,为了系统的安全,请手动去删除。</td>
|
|
||||||
</tr>
|
|
||||||
{/if}
|
|
||||||
<tr>
|
|
||||||
<td><b>服务器系统</b></td>
|
|
||||||
<td>{:get_system_info('os')}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>PHP版本</b></td>
|
|
||||||
<td>{:get_system_info('php')}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>系统版本</b></td>
|
|
||||||
<td>{:CMS_VERSION}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>ThinkPHP版本</b></td>
|
|
||||||
<td>{:TP_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px"
|
|
||||||
href="https://www.kancloud.cn/manual/thinkphp6_0" target="_blank">TP6文档</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>Layui版本</b></td>
|
|
||||||
<td>{:LAYUI_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px" href="https://www.layui.com/doc/"
|
|
||||||
target="_blank">Layui文档</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>上传附件限制</b></td>
|
|
||||||
<td>{:get_system_info('upload_max_filesize')}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>执行时间限制</b></td>
|
|
||||||
<td>{:get_system_info('max_execution_time')}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><b>BUG反馈</b></td>
|
|
||||||
<td><a href="mailto:hdm58@qq.com" target="_blank">hdm58@qq.com</a></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space10">
|
||||||
<div class="index-row">
|
<div class="layui-col-md8">
|
||||||
<div class="panel-num">
|
<div class="layui-row layui-col-space10">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-card panel-num">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -194,39 +92,83 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel">
|
<div class="layui-card">
|
||||||
<div class="table-title">注册用户</div>
|
<div class="table-title">注册用户</div>
|
||||||
<table id="UserList" class="layui-table layui-table-view">
|
<div style="padding: 0 15px 5px;">
|
||||||
<thead>
|
<table id="UserList" lay-filter="UserList" class="layui-hide"></table>
|
||||||
<tr>
|
|
||||||
<th>用户名</th>
|
|
||||||
<th>头像</th>
|
|
||||||
<th>登录次数</th>
|
|
||||||
<th>最后登录时间</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
<div style="clear: left;"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel">
|
</div>
|
||||||
|
<div class="layui-card">
|
||||||
<div class="table-title">文章列表</div>
|
<div class="table-title">文章列表</div>
|
||||||
<table id="Article" class="layui-table layui-table-view">
|
<div style="padding: 0 15px 5px;">
|
||||||
<thead>
|
<table id="Article" lay-filter="Article" class="layui-hide" style="margin-top:0"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card">
|
||||||
|
<div id="chartView" style="width: 100%;height:300px;"></div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card">
|
||||||
|
<div id="chartYear" style="width: 100%;height:240px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="table-title">系统信息</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<table class="layui-table" lay-skin="" lay-size="sm">
|
||||||
|
{if condition="($install == true)"}
|
||||||
<tr>
|
<tr>
|
||||||
<th>文章标题</th>
|
<td colspan="2" style="color: #E94335;">提醒:发现app目录下的install文件夹没删除,为了系统的安全,请手动去删除。</td>
|
||||||
<th>文章分类</th>
|
</tr>
|
||||||
<th>发布时间</th>
|
{/if}
|
||||||
|
<tr>
|
||||||
|
<td><b>服务器系统</b></td>
|
||||||
|
<td>{:get_system_info('os')}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>PHP版本</b></td>
|
||||||
|
<td>{:get_system_info('php')}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>勾股博客版本</b></td>
|
||||||
|
<td>{:CMS_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px"
|
||||||
|
href="https://www.gougucms.com/" target="_blank">勾股CMS</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>ThinkPHP版本</b></td>
|
||||||
|
<td>{:TP_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px"
|
||||||
|
href="https://www.kancloud.cn/manual/thinkphp6_0" target="_blank">TP6文档</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Layui版本</b></td>
|
||||||
|
<td>{:LAYUI_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px"
|
||||||
|
href="https://www.layui.site/doc/" target="_blank">Layui文档</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>上传附件限制</b></td>
|
||||||
|
<td>{:get_system_info('upload_max_filesize')}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>执行时间限制</b></td>
|
||||||
|
<td>{:get_system_info('max_execution_time')}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>BUG反馈</b></td>
|
||||||
|
<td><a href="mailto:hdm58@qq.com" target="_blank">hdm58@qq.com</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
|
||||||
</table>
|
</table>
|
||||||
<div style="clear: left;"></div>
|
|
||||||
</div>
|
|
||||||
<div class="panel">
|
|
||||||
<div class="table-title">访问统计</div>
|
|
||||||
<div id="chartView" style="width: 100%;height:396px;"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: right;"></div>
|
<div class="layui-card">
|
||||||
|
<div class="table-title">操作日志</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<ul class="layui-timeline" id="logs"></ul>
|
||||||
|
<div class="panel-more"><a href="/admin/api/log_list/">查看更多日志</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
<!-- /主体 -->
|
<!-- /主体 -->
|
||||||
@ -241,7 +183,7 @@
|
|||||||
type: 'post',
|
type: 'post',
|
||||||
data: {
|
data: {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 10
|
limit: 20
|
||||||
},
|
},
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
@ -260,64 +202,53 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers() {
|
function init(layui) {
|
||||||
$.ajax({
|
var layer = layui.layer, table = layui.table;
|
||||||
url: "/admin/api/get_user_list",
|
getLogs();
|
||||||
type: 'post',
|
//注册用户
|
||||||
success: function (e) {
|
table.render({
|
||||||
if (e.code == 0) {
|
elem: '#UserList'
|
||||||
var html = '';
|
, url: '/admin/api/get_user_list' //数据接口
|
||||||
if(e.data.length==0){
|
, page: false //开启分页
|
||||||
html +='<tr>\
|
, cols: [[ //表头
|
||||||
<td colspan="4" style="padding:10px 0; color:#999; text-align:center;">暂无用户</td>\
|
{ field: 'username', title: '用户名'}
|
||||||
</tr>';
|
,{ field: 'username', title: '昵称', align: 'center', 'width': 120}
|
||||||
|
,{ field: 'sex', title: '性别','width': 60, align: 'center', templet: function (d) {
|
||||||
|
let str='-';
|
||||||
|
if(d.sex==1){
|
||||||
|
str='男';
|
||||||
}
|
}
|
||||||
else{
|
else if(d.sex==2){
|
||||||
$.each(e.data, function (key, value) {
|
str='女';
|
||||||
html += '<tr>\
|
}
|
||||||
<td>'+value.username+'</td>\
|
return str;
|
||||||
<td>\
|
}}
|
||||||
<img src="' + value.headimgurl + '" width="20" height="20" />\
|
, {
|
||||||
</td>\
|
field: 'headimgurl', title: '头像', align: 'center','width': 60, templet: function (d) {
|
||||||
<td>'+value.login_num+'</td>\
|
return '<img src="' + d.headimgurl + '" width="20" height="20" />';
|
||||||
<td>'+value.last_login_time+'</td>\
|
}
|
||||||
</tr>';
|
}
|
||||||
|
, { field: 'login_num', title: '登录次数', align: 'center','width': 100}
|
||||||
|
, { field: 'last_login_time', title: '最后登录时间', align: 'center','width': 168}
|
||||||
|
]]
|
||||||
});
|
});
|
||||||
}
|
|
||||||
$('#UserList').append(html);
|
//文章
|
||||||
}
|
table.render({
|
||||||
}
|
elem: '#Article'
|
||||||
})
|
, url: '/admin/api/get_article_list' //数据接口
|
||||||
|
, page: false //开启分页
|
||||||
|
, cols: [[ //表头
|
||||||
|
{ field: 'title', title: '文章标题'}
|
||||||
|
, { field: 'cate_title', title: '文章分类', align: 'center','width': 150 }
|
||||||
|
, { field: 'read', title: '访问量', align: 'center','width': 100 }
|
||||||
|
, { field: 'create_time', title: '发布时间', align: 'center','width': 168}
|
||||||
|
]]
|
||||||
|
});
|
||||||
|
get_view_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArticles() {
|
|
||||||
$.ajax({
|
|
||||||
url: "/admin/api/get_article_list",
|
|
||||||
type: 'post',
|
|
||||||
success: function (e) {
|
|
||||||
if (e.code == 0) {
|
|
||||||
var html = '';
|
|
||||||
if(e.data.length==0){
|
|
||||||
html +='<tr>\
|
|
||||||
<td colspan="3" style="padding:10px 0; color:#999; text-align:center;">暂无文章</td>\
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$.each(e.data, function (key, value) {
|
|
||||||
html += '<tr>\
|
|
||||||
<td>'+value.title+'</td>\
|
|
||||||
<td>' + value.cate_title + '</td>\
|
|
||||||
<td>'+value.create_time+'</td>\
|
|
||||||
</tr>';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$('#Article').append(html);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var echartsTheme={color:["#1AAD19","#1890FF","#5FB878","#FFB980","#D87A80","#8d98b3","#e5cf0d","#97b552","#95706d","#dc69aa","#07a2a4","#9a7fd1","#588dd5","#f5994e","#c05050","#59678c","#c9ab00","#7eb00a","#6f5553","#c14089"],title:{textStyle:{fontWeight:"normal",color:"#666"}},dataRange:{itemWidth:15,color:["#009688","#e0ffff"]},toolbox:{color:["#1e90ff","#1e90ff","#1e90ff","#1e90ff"],effectiveColor:"#ff4500"},tooltip:{axisPointer:{type:"line",lineStyle:{color:"#999"},crossStyle:{color:"#008acd"},shadowStyle:{color:"rgba(200,200,200,0.2)"}}},dataZoom:{dataBackgroundColor:"#efefff",fillerColor:"rgba(182,162,222,0.2)",handleColor:"#008acd"},grid:{borderColor:"#eee"},categoryAxis:{axisLine:{lineStyle:{color:"#555555"}},axisTick:{show:!1},splitLine:{lineStyle:{color:["#eee"]}}},valueAxis:{axisLine:{lineStyle:{color:"#555555"}},splitArea:{show:!0,areaStyle:{color:["rgba(250,250,250,0.1)","rgba(200,200,200,0.1)"]}},splitLine:{lineStyle:{color:["#eee"]}}},polar:{axisLine:{lineStyle:{color:"#ddd"}},splitArea:{show:!0,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(200,200,200,0.2)"]}},splitLine:{lineStyle:{color:"#ddd"}}},timeline:{lineStyle:{color:"#009688"},controlStyle:{normal:{color:"#009688"},emphasis:{color:"#009688"}},symbol:"emptyCircle",symbolSize:3},bar:{itemStyle:{normal:{barBorderRadius:2},emphasis:{barBorderRadius:2}}},line:{smooth:!0,symbol:"emptyCircle",symbolSize:8},k:{itemStyle:{normal:{color:"#d87a80",color0:"#2ec7c9",lineStyle:{color:"#d87a80",color0:"#2ec7c9"}}}},scatter:{symbol:"circle",symbolSize:4},radar:{symbol:"emptyCircle",symbolSize:3},map:{itemStyle:{normal:{areaStyle:{color:"#ddd"},label:{textStyle:{color:"#d87a80"}}},emphasis:{areaStyle:{color:"#fe994e"}}}},force:{itemStyle:{normal:{linkStyle:{color:"#1e90ff"}}}},chord:{itemStyle:{normal:{borderWidth:1,borderColor:"rgba(128, 128, 128, 0.5)",chordStyle:{lineStyle:{color:"rgba(128, 128, 128, 0.5)"}}},emphasis:{borderWidth:1,borderColor:"rgba(128, 128, 128, 0.5)",chordStyle:{lineStyle:{color:"rgba(128, 128, 128, 0.5)"}}}}},gauge:{axisLine:{lineStyle:{color:[[.2,"#2ec7c9"],[.8,"#5ab1ef"],[1,"#d87a80"]],width:10}},axisTick:{splitNumber:10,length:15,lineStyle:{color:"auto"}},splitLine:{length:22,lineStyle:{color:"auto"}},pointer:{width:5}},textStyle:{fontFamily:"微软雅黑, Arial, Verdana, sans-serif"}};
|
|
||||||
function setHour(num) {
|
function setHour(num) {
|
||||||
var str = num + ':00';
|
var str = num + ':00';
|
||||||
if (num < 10) {
|
if (num < 10) {
|
||||||
@ -325,7 +256,7 @@ function setHour(num){
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
var chartView = echarts.init(document.getElementById('chartView'),echartsTheme);
|
var chartView = echarts.init(document.getElementById('chartView'));
|
||||||
function get_view_data() {
|
function get_view_data() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/admin/api/get_view_data",
|
url: "/admin/api/get_view_data",
|
||||||
@ -335,6 +266,7 @@ $.ajax({
|
|||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
var data_first = e.data.data_first;
|
var data_first = e.data.data_first;
|
||||||
var data_second = e.data.data_second;
|
var data_second = e.data.data_second;
|
||||||
|
archiveCalendar = e.data.data_three;
|
||||||
var myDate = new Date();
|
var myDate = new Date();
|
||||||
var nowHour = myDate.getHours(); //获取当前小时数(0-23)
|
var nowHour = myDate.getHours(); //获取当前小时数(0-23)
|
||||||
var xData = [];
|
var xData = [];
|
||||||
@ -350,11 +282,20 @@ $.ajax({
|
|||||||
yData2.push(value);
|
yData2.push(value);
|
||||||
});
|
});
|
||||||
var ops = {
|
var ops = {
|
||||||
|
title: {
|
||||||
|
top: '15px',
|
||||||
|
text: '今日与昨日访问统计',
|
||||||
|
left: '12px',
|
||||||
|
textStyle: {
|
||||||
|
fontSize: '18',
|
||||||
|
color: '#333',
|
||||||
|
}
|
||||||
|
},
|
||||||
color: ["#1AAD19", "#1890FF"],
|
color: ["#1AAD19", "#1890FF"],
|
||||||
grid: {
|
grid: {
|
||||||
left: '10px',
|
left: '20px',
|
||||||
right: '20px',
|
right: '30px',
|
||||||
bottom: '20px',
|
bottom: '15px',
|
||||||
top: '60px',
|
top: '60px',
|
||||||
containLabel: true
|
containLabel: true
|
||||||
},
|
},
|
||||||
@ -371,15 +312,29 @@ $.ajax({
|
|||||||
show: true,
|
show: true,
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: ["今日", "昨日"]
|
data: ["今日", "昨日"],
|
||||||
|
top: '18px',
|
||||||
},
|
},
|
||||||
xAxis: [{
|
xAxis: [{
|
||||||
type: "category",
|
type: "category",
|
||||||
boundaryGap: !1,
|
boundaryGap: !1,
|
||||||
data: xData
|
data: xData,
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: '#999999',
|
||||||
|
width: 1,
|
||||||
|
}
|
||||||
|
},
|
||||||
}],
|
}],
|
||||||
yAxis: [{
|
yAxis: [{
|
||||||
type: "value"
|
type: "value",
|
||||||
|
axisLine: {
|
||||||
|
show: true,
|
||||||
|
lineStyle: {
|
||||||
|
color: '#999999',
|
||||||
|
width: 1,
|
||||||
|
}
|
||||||
|
},
|
||||||
}],
|
}],
|
||||||
series: [{
|
series: [{
|
||||||
name: "今日",
|
name: "今日",
|
||||||
@ -410,26 +365,135 @@ $.ajax({
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
chartView.setOption(ops);
|
chartView.setOption(ops);
|
||||||
|
|
||||||
|
|
||||||
|
let myChart = echarts.init(document.getElementById('chartYear'));
|
||||||
|
let option = {
|
||||||
|
title: {
|
||||||
|
top: '15px',
|
||||||
|
text: '近一年访问统计',
|
||||||
|
left: '12px',
|
||||||
|
textStyle: {
|
||||||
|
fontSize: '18',
|
||||||
|
color: '#333',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
padding: 6,
|
||||||
|
formatter: function (obj) {
|
||||||
|
var value = obj.value;
|
||||||
|
return '<div style="font-size: 12px;">' + value[0] + ':' + value[1] + ' 个访客</div>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
visualMap: {
|
||||||
|
min: 0,
|
||||||
|
max: 300,
|
||||||
|
show: false,
|
||||||
|
inRange: {
|
||||||
|
color: ['#fafafa', '#1AAD19']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
calendar: {
|
||||||
|
top: 75,
|
||||||
|
left: 52,
|
||||||
|
right: 20,
|
||||||
|
range: getRange(),
|
||||||
|
cellSize: ['auto', 21],
|
||||||
|
splitLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: '#aaa',
|
||||||
|
type: 'dashed'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
itemStyle: {
|
||||||
|
borderWidth: 0.5
|
||||||
|
},
|
||||||
|
yearLabel: { show: false },
|
||||||
|
monthLabel: {
|
||||||
|
nameMap: 'cn',
|
||||||
|
fontSize: 12
|
||||||
|
},
|
||||||
|
dayLabel: {
|
||||||
|
show: true,
|
||||||
|
formatter: '{start} 1st',
|
||||||
|
fontWeight: 'lighter',
|
||||||
|
nameMap: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
||||||
|
fontSize: 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
series: [{
|
||||||
|
type: 'heatmap',
|
||||||
|
coordinateSystem: 'calendar',
|
||||||
|
calendarIndex: 0,
|
||||||
|
data: getDay()
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
myChart.setOption(option);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.onresize = function () {
|
window.onresize = function () {
|
||||||
chartView.resize();
|
chartView.resize();
|
||||||
|
myChart.resize();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(e.data);
|
console.log(e.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var archiveCalendar = {};
|
||||||
|
function getRange() {
|
||||||
|
let today = new Date();
|
||||||
|
let tYear = today.getFullYear();
|
||||||
|
let tMonth = today.getMonth() + 1;
|
||||||
|
let tDate = today.getDate();
|
||||||
|
let dateFirst = tYear + "-" + tMonth + "-" + tDate;
|
||||||
|
let datelast = (tYear - 1) + "-" + tMonth + "-" + tDate;
|
||||||
|
let dataRange = [];
|
||||||
|
dataRange.push(dateFirst);
|
||||||
|
dataRange.push(datelast);
|
||||||
|
return dataRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDay() {
|
||||||
|
var today = new Date();
|
||||||
|
var dayArray = [];
|
||||||
|
for (var i = 0; i < 366; i++) {
|
||||||
|
var targetday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24 * i;
|
||||||
|
var date = new Date(targetday_milliseconds);
|
||||||
|
dayArray.push(retunDay(date));
|
||||||
|
}
|
||||||
|
return dayArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
function retunDay(day) {
|
||||||
|
var tYear = day.getFullYear();
|
||||||
|
var tMonth = day.getMonth();
|
||||||
|
var tDate = day.getDate();
|
||||||
|
tMonth = tMonth + 1;
|
||||||
|
if (tMonth.toString().length == 1) {
|
||||||
|
tMonth = "0" + tMonth;
|
||||||
|
}
|
||||||
|
if (tDate.toString().length == 1) {
|
||||||
|
tDate = "0" + tDate;
|
||||||
|
}
|
||||||
|
var dateStr = tYear + "-" + tMonth + "-" + tDate;
|
||||||
|
var dateArray = [];
|
||||||
|
dateArray.push(dateStr);
|
||||||
|
if (archiveCalendar[dateStr]) {
|
||||||
|
dateArray.push(archiveCalendar[dateStr]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dateArray.push(0);
|
||||||
|
}
|
||||||
|
return dateArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function init(layui) {
|
|
||||||
var layer = layui.layer, table = layui.table;
|
|
||||||
getLogs();
|
|
||||||
getUsers();
|
|
||||||
getArticles();
|
|
||||||
get_view_data();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{include file="common/layui" base="base" extend="[]" callback="init" /}
|
{include file="common/layui" base='base' extend="[]" callback="init" /}
|
||||||
{/block}
|
{/block}
|
||||||
<!-- /脚本 -->
|
<!-- /脚本 -->
|
Loading…
x
Reference in New Issue
Block a user