192 lines
7.6 KiB
HTML
192 lines
7.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>实时数据</title>
|
|
<link rel="stylesheet" href="/layui/css/layui.css">
|
|
<link rel="stylesheet" href="/css/Chart.min.css">
|
|
</head>
|
|
<body>
|
|
<div class="layui-layout layui-layout-admin">
|
|
<div id="header"></div>
|
|
<div class="layui-body" style="left: 0px;">
|
|
<div style="width: 50%;margin-left: 25%; margin-top: 2%;">
|
|
<blockquote class="layui-elem-quote">
|
|
选择选项卡可查看数据
|
|
<div id="temp"></div>
|
|
</blockquote>
|
|
</div>
|
|
<div style="width: 80%;margin-left: 10%; margin-top: 2%;">
|
|
<div class="layui-tab layui-tab-card" lay-filter="upInfo" lay-allowClose="false">
|
|
<ul class="layui-tab-title">
|
|
</ul>
|
|
<div class="layui-tab-content">
|
|
<div style="padding: 20px; background-color: #F2F2F2;">
|
|
<div class="layui-row layui-col-space15">
|
|
<div class="layui-col-md4">
|
|
<div class="layui-card" style="width: 100%;">
|
|
<div class="layui-card-header">当前人气值</div>
|
|
<div class="layui-card-body" id="popular">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-col-md4">
|
|
<div class="layui-card" style="width: 100%;">
|
|
<div class="layui-card-header">今日累计访问数</div>
|
|
<div class="layui-card-body" id="user">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-col-md4">
|
|
<div class="layui-card" style="width: 100%;">
|
|
<div class="layui-card-header">今日累计收益(金瓜子)</div>
|
|
<div class="layui-card-body" id="price">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-col-md-offset2"></div>
|
|
<div class="layui-col-md6">
|
|
<div class="layui-card" style="width: 100%;height: 400px">
|
|
<div class="layui-card-header">今日收益(金瓜子)</div>
|
|
<div class="layui-card-body">
|
|
<canvas id="toDayPrice" width="600" height="300"></canvas>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-col-md6">
|
|
<div class="layui-card" style="width: 100%;height: 400px">
|
|
<div class="layui-card-header">今日礼物 (含免费)</div>
|
|
<div class="layui-card-body">
|
|
<canvas id="toDayGift" width="600" height="300"></canvas>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div id="footer"></div>
|
|
</div>
|
|
<script src="/layui/layui.js"></script>
|
|
<script src="/js/jquery-3.2.1.js"></script>
|
|
<script src="/js/Chart.min.js"></script>
|
|
<script src="/js/Chart.bundle.min.js"></script>
|
|
<script>
|
|
$('#header').load("/html/header.html");
|
|
$('#footer').load("/html/footer.html");
|
|
layui.use(['layer', 'form', 'element', 'table'], function () {
|
|
let layer = layui.layer
|
|
, form = layui.form
|
|
, table = layui.table
|
|
, element = layui.element;
|
|
let giftChart,priceChart;
|
|
|
|
$.post("/upinfo/get/list.do", function (json) {
|
|
let id=0;
|
|
if (json.code === 0) {
|
|
for (let i in json.data) {
|
|
if(id===0){
|
|
id=json.data[i].roomid;
|
|
}
|
|
element.tabAdd('upInfo', {
|
|
title: json.data[i].name
|
|
, id: json.data[i].roomid
|
|
})
|
|
}
|
|
|
|
}
|
|
element.tabChange('upInfo', id);
|
|
form.render()
|
|
})
|
|
element.on('tab(upInfo)', function (data) {
|
|
let index = layer.load();
|
|
if(giftChart!=null){
|
|
giftChart.destroy();
|
|
}
|
|
if(priceChart!=null){
|
|
priceChart.destroy()
|
|
}
|
|
$.post("/realTimeData/get/query.do", {"roomid": this.getAttribute('lay-id')}, function (json) {
|
|
console.log(json)
|
|
if (json.code !== 0) {
|
|
$('#popular').text(0);
|
|
$('#user').text(0);
|
|
$('#price').text(0);
|
|
layer.close(index);
|
|
return;
|
|
}
|
|
let gifts = json.data.gift;
|
|
let prices = json.data.price;
|
|
let priceSize = 0;
|
|
let picTime = [];
|
|
let pic = []
|
|
let gift = []
|
|
let giftSize = []
|
|
for (let i in prices) {
|
|
priceSize += prices[i].price;
|
|
pic[i] = prices[i].price;
|
|
picTime[i] = prices[i].time
|
|
}
|
|
for (let i in gifts) {
|
|
gift[i] = gifts[i].giftName;
|
|
giftSize[i] = gifts[i].size;
|
|
}
|
|
let text=(json.data.vipLength + json.data.userLength)+"。 普通用户:"+json.data.userLength+"、 舰长:"+json.data.vipLength
|
|
$('#popular').text(json.data.popular);
|
|
$('#user').text(text);
|
|
$('#price').text(priceSize+" *叔叔抽成后:"+(priceSize/2)+"(¥"+((priceSize/2))/1000+")");
|
|
priceChart= dataInit('toDayPrice', '金瓜子', 'line', picTime, pic)
|
|
giftChart=dataInit('toDayGift', '礼物', 'bar', gift, giftSize)
|
|
layer.close(index);
|
|
})
|
|
})
|
|
|
|
|
|
function dataInit(elemId, label, type, title, data) {
|
|
var ctx = document.getElementById(elemId).getContext('2d');
|
|
var myChart = new Chart(ctx, {
|
|
type: type,
|
|
data: {
|
|
labels: title,
|
|
datasets: [{
|
|
label: label,
|
|
data: data,
|
|
backgroundColor: [
|
|
|
|
'rgba(255, 159, 64, 0.2)'
|
|
],
|
|
borderColor: [
|
|
|
|
'rgba(255, 159, 64, 1)'
|
|
],
|
|
borderWidth: 1
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
yAxes: [{
|
|
ticks: {
|
|
beginAtZero: true
|
|
}
|
|
}]
|
|
},
|
|
tooltips: {
|
|
intersect: false,
|
|
}
|
|
}
|
|
});
|
|
return myChart;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |