322 lines
9.8 KiB
HTML
322 lines
9.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Moboos 广告投放报告</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: #f5f7fa;
|
|
color: #333;
|
|
padding: 20px;
|
|
}
|
|
.header {
|
|
text-align: center;
|
|
padding: 30px 0 20px;
|
|
}
|
|
.header h1 {
|
|
font-size: 24px;
|
|
color: #1a1a2e;
|
|
margin-bottom: 8px;
|
|
}
|
|
.header p {
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
.controls {
|
|
max-width: 1400px;
|
|
margin: 0 auto 20px;
|
|
display: flex;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
}
|
|
.controls label {
|
|
font-size: 13px;
|
|
color: #555;
|
|
font-weight: 500;
|
|
}
|
|
.controls select {
|
|
padding: 6px 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 6px;
|
|
font-size: 13px;
|
|
background: #fff;
|
|
cursor: pointer;
|
|
}
|
|
.charts-grid {
|
|
max-width: 1400px;
|
|
margin: 0 auto 30px;
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 20px;
|
|
}
|
|
.chart-card {
|
|
background: #fff;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
|
}
|
|
.chart-card h3 {
|
|
font-size: 14px;
|
|
color: #555;
|
|
margin-bottom: 12px;
|
|
}
|
|
.chart-card canvas {
|
|
width: 100% !important;
|
|
height: 250px !important;
|
|
}
|
|
.table-section {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
background: #fff;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
|
overflow-x: auto;
|
|
}
|
|
.table-section h2 {
|
|
font-size: 16px;
|
|
color: #1a1a2e;
|
|
margin-bottom: 15px;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 12px;
|
|
}
|
|
th {
|
|
background: #f0f2f5;
|
|
padding: 10px 8px;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
color: #555;
|
|
white-space: nowrap;
|
|
position: sticky;
|
|
top: 0;
|
|
}
|
|
td {
|
|
padding: 8px;
|
|
border-bottom: 1px solid #f0f2f5;
|
|
white-space: nowrap;
|
|
}
|
|
tr:hover td {
|
|
background: #f8f9fb;
|
|
}
|
|
.pkg-tag {
|
|
display: inline-block;
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
font-size: 11px;
|
|
background: #e8f4fd;
|
|
color: #1976d2;
|
|
}
|
|
.metric-up { color: #4caf50; }
|
|
.metric-down { color: #f44336; }
|
|
@media (max-width: 900px) {
|
|
.charts-grid { grid-template-columns: 1fr; }
|
|
}
|
|
.updated-time {
|
|
text-align: center;
|
|
color: #999;
|
|
font-size: 12px;
|
|
margin-top: 20px;
|
|
padding-bottom: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>Moboos 广告投放数据报告</h1>
|
|
<p>数据范围:每日自动更新</p>
|
|
</div>
|
|
|
|
<div class="controls">
|
|
<label>筛选广告主:</label>
|
|
<select id="pkgFilter">
|
|
<option value="all">全部</option>
|
|
</select>
|
|
<label style="margin-left:12px;">指标:</label>
|
|
<select id="metricFilter">
|
|
<option value="impressions">展示</option>
|
|
<option value="clicks">点击</option>
|
|
<option value="conversions">转化</option>
|
|
<option value="ecpm">eCPM</option>
|
|
<option value="cpc">CPC</option>
|
|
<option value="ctr">CTR</option>
|
|
<option value="ivr">IVR</option>
|
|
<option value="cvr">CVR</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="charts-grid">
|
|
<div class="chart-card">
|
|
<h3>展示量趋势</h3>
|
|
<canvas id="chartImpressions"></canvas>
|
|
</div>
|
|
<div class="chart-card">
|
|
<h3>点击量趋势</h3>
|
|
<canvas id="chartClicks"></canvas>
|
|
</div>
|
|
<div class="chart-card">
|
|
<h3>转化量趋势</h3>
|
|
<canvas id="chartConversions"></canvas>
|
|
</div>
|
|
<div class="chart-card">
|
|
<h3>eCPM 趋势</h3>
|
|
<canvas id="chartEcpm"></canvas>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-section">
|
|
<h2>明细数据</h2>
|
|
<table id="dataTable">
|
|
<thead>
|
|
<tr>
|
|
<th>日期</th>
|
|
<th>广告单元</th>
|
|
<th>Pkg</th>
|
|
<th>展示</th>
|
|
<th>点击</th>
|
|
<th>转化</th>
|
|
<th>eCPM</th>
|
|
<th>CPC</th>
|
|
<th>CTR</th>
|
|
<th>IVR</th>
|
|
<th>CVR</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="updated-time" id="updatedTime"></div>
|
|
|
|
<script>
|
|
const COLORS = [
|
|
'#1976d2','#e53935','#43a047','#fb8c00','#8e24aa',
|
|
'#00acc1','#6d4c41','#546e7a','#d81b60','#00897b'
|
|
];
|
|
|
|
let rawData = [];
|
|
let charts = {};
|
|
|
|
async function loadData() {
|
|
try {
|
|
const resp = await fetch('data.json?' + Date.now());
|
|
rawData = await resp.json();
|
|
init();
|
|
} catch(e) {
|
|
console.error('Failed to load data:', e);
|
|
}
|
|
}
|
|
|
|
function init() {
|
|
populateFilter();
|
|
renderAll();
|
|
document.getElementById('pkgFilter').addEventListener('change', renderAll);
|
|
document.getElementById('metricFilter').addEventListener('change', renderAll);
|
|
document.getElementById('updatedTime').textContent = '数据更新时间:' + new Date().toLocaleString('zh-CN');
|
|
}
|
|
|
|
function populateFilter() {
|
|
const pkgs = [...new Set(rawData.map(d => d.pkg))];
|
|
const sel = document.getElementById('pkgFilter');
|
|
pkgs.forEach(p => {
|
|
const opt = document.createElement('option');
|
|
opt.value = p;
|
|
opt.textContent = p.split('.').pop();
|
|
sel.appendChild(opt);
|
|
});
|
|
}
|
|
|
|
function getFilteredData() {
|
|
const pkg = document.getElementById('pkgFilter').value;
|
|
if (pkg === 'all') return rawData;
|
|
return rawData.filter(d => d.pkg === pkg);
|
|
}
|
|
|
|
function renderAll() {
|
|
renderCharts();
|
|
renderTable();
|
|
}
|
|
|
|
function renderCharts() {
|
|
const data = getFilteredData();
|
|
const dates = [...new Set(data.map(d => d.date))].sort();
|
|
const pkgs = [...new Set(data.map(d => d.pkg))];
|
|
|
|
renderChart('chartImpressions', dates, pkgs, data, 'impressions');
|
|
renderChart('chartClicks', dates, pkgs, data, 'clicks');
|
|
renderChart('chartConversions', dates, pkgs, data, 'conversions');
|
|
renderChart('chartEcpm', dates, pkgs, data, 'ecpm');
|
|
}
|
|
|
|
function renderChart(canvasId, dates, pkgs, data, metric) {
|
|
if (charts[canvasId]) charts[canvasId].destroy();
|
|
|
|
const datasets = pkgs.map((pkg, i) => {
|
|
const values = dates.map(date => {
|
|
const rows = data.filter(d => d.date === date && d.pkg === pkg);
|
|
if (rows.length === 0) return null;
|
|
return rows.reduce((sum, r) => sum + (r[metric] || 0), 0);
|
|
});
|
|
return {
|
|
label: pkg.split('.').pop(),
|
|
data: values,
|
|
borderColor: COLORS[i % COLORS.length],
|
|
backgroundColor: COLORS[i % COLORS.length] + '20',
|
|
borderWidth: 2,
|
|
pointRadius: 3,
|
|
tension: 0.3,
|
|
fill: false
|
|
};
|
|
});
|
|
|
|
const ctx = document.getElementById(canvasId).getContext('2d');
|
|
charts[canvasId] = new Chart(ctx, {
|
|
type: 'line',
|
|
data: { labels: dates.map(d => d.slice(5)), datasets },
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
plugins: {
|
|
legend: { position: 'bottom', labels: { boxWidth: 12, font: { size: 11 } } }
|
|
},
|
|
scales: {
|
|
x: { grid: { display: false } },
|
|
y: { beginAtZero: true, grid: { color: '#f0f0f0' } }
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function renderTable() {
|
|
const data = getFilteredData();
|
|
const sorted = [...data].sort((a, b) => b.date.localeCompare(a.date) || a.pkg.localeCompare(b.pkg));
|
|
const tbody = document.querySelector('#dataTable tbody');
|
|
tbody.innerHTML = sorted.map(d => `
|
|
<tr>
|
|
<td>${d.date}</td>
|
|
<td>${d.ad_unit}</td>
|
|
<td><span class="pkg-tag">${d.pkg}</span></td>
|
|
<td>${d.impressions.toLocaleString()}</td>
|
|
<td>${d.clicks.toLocaleString()}</td>
|
|
<td>${d.conversions}</td>
|
|
<td>${d.ecpm.toFixed(3)}</td>
|
|
<td>${d.cpc.toFixed(3)}</td>
|
|
<td>${(d.ctr * 100).toFixed(2)}%</td>
|
|
<td>${(d.ivr * 100).toFixed(3)}%</td>
|
|
<td>${(d.cvr * 100).toFixed(2)}%</td>
|
|
</tr>
|
|
`).join('');
|
|
}
|
|
|
|
loadData();
|
|
</script>
|
|
</body>
|
|
</html>
|