328 lines
10 KiB
HTML
328 lines
10 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>营收数据汇总</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Microsoft YaHei', Arial, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
background: rgba(255, 255, 255, 0.95);
|
|
border-radius: 20px;
|
|
padding: 30px;
|
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
font-size: 28px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.info-section {
|
|
background: #f8f9fa;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.info-item {
|
|
margin-bottom: 10px;
|
|
font-size: 14px;
|
|
color: #555;
|
|
}
|
|
|
|
.info-item strong {
|
|
color: #333;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.data-section {
|
|
margin-top: 30px;
|
|
}
|
|
|
|
.data-title {
|
|
font-size: 20px;
|
|
color: #667eea;
|
|
margin-bottom: 15px;
|
|
font-weight: 600;
|
|
border-left: 4px solid #667eea;
|
|
padding-left: 12px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.copy-btn {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
|
}
|
|
|
|
.copy-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
.copy-btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.copy-btn.copied {
|
|
background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
|
|
}
|
|
|
|
.data-content {
|
|
background: #f8f9fa;
|
|
border-radius: 8px;
|
|
padding: 15px;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
pre {
|
|
margin: 0;
|
|
font-size: 13px;
|
|
line-height: 1.6;
|
|
color: #333;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 40px;
|
|
font-size: 18px;
|
|
color: #667eea;
|
|
}
|
|
|
|
.error {
|
|
background: #fee;
|
|
color: #c33;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
border-left: 4px solid #c33;
|
|
}
|
|
|
|
.spinner {
|
|
border: 4px solid #f3f3f3;
|
|
border-top: 4px solid #667eea;
|
|
border-radius: 50%;
|
|
width: 40px;
|
|
height: 40px;
|
|
animation: spin 1s linear infinite;
|
|
margin: 20px auto;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<h1>营收数据汇总分析</h1>
|
|
|
|
<div class="info-section">
|
|
<div class="info-item">
|
|
<strong>统计月份:</strong>
|
|
<span id="statisticsMonth">-</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<strong>统计日期:</strong>
|
|
<span id="statisticsDate">-</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<strong>省份代码:</strong>
|
|
<span id="provinceCode">340000</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="loadingDiv" class="loading">
|
|
<div class="spinner"></div>
|
|
<p>正在加载数据...</p>
|
|
</div>
|
|
|
|
<div id="errorDiv" style="display: none;"></div>
|
|
|
|
<div id="resultDiv" style="display: none;">
|
|
<div class="data-section">
|
|
<div class="data-title">
|
|
NewPythonData
|
|
<button id="copyBtn" class="copy-btn">📋 复制数据</button>
|
|
</div>
|
|
<div class="data-content">
|
|
<pre id="finalData"></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 从 URL 参数获取 StatisticsMonth
|
|
function getUrlParameter(name) {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
return urlParams.get(name);
|
|
}
|
|
|
|
// 模拟 request.$webGet 方法
|
|
const request = {
|
|
$webGet: async function (url, params) {
|
|
// API 基础地址
|
|
const baseUrl = 'https://eshangtech.com:18900/';
|
|
|
|
const queryString = new URLSearchParams(params).toString();
|
|
const fullUrl = `${baseUrl}${url}?${queryString}`;
|
|
|
|
const response = await fetch(fullUrl, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
|
|
return await response.json();
|
|
}
|
|
};
|
|
|
|
// 主函数
|
|
async function loadData() {
|
|
try {
|
|
// 从 URL 获取 StatisticsMonth 参数
|
|
const statisticsMonth = getUrlParameter('StatisticsMonth') || '202601';
|
|
|
|
// 更新页面显示的参数信息
|
|
document.getElementById('statisticsMonth').textContent = statisticsMonth;
|
|
document.getElementById('statisticsDate').textContent = '2026-01-11';
|
|
|
|
// 第一个 API 请求
|
|
let req = {
|
|
pushProvinceCode: "340000",
|
|
StatisticsMonth: statisticsMonth,
|
|
StatisticsDate: '2026-01-11',
|
|
};
|
|
|
|
const lastData = await request.$webGet("CommercialApi/Revenue/GetSummaryRevenueMonth", req);
|
|
let NewLastData = JSON.parse(JSON.stringify(lastData));
|
|
|
|
// 处理时间逻辑 (这里简化处理,直接使用 statisticsMonth)
|
|
const time = statisticsMonth;
|
|
|
|
// 第二个 API 请求
|
|
const trafficReq = {
|
|
Province_Code: "340000",
|
|
Statistics_Date: time,
|
|
};
|
|
|
|
const trafficData = await request.$webGet("CommercialApi/Revenue/GetProvinceAvgBayonetAnalysis", trafficReq);
|
|
let trafficList = trafficData.Result_Data.List;
|
|
|
|
// 处理 trafficList 数据
|
|
if (trafficList && trafficList.length > 0) {
|
|
trafficList.forEach((item) => {
|
|
if (item.Serverpart_Name === 'QOQ') {
|
|
item.Serverpart_Name = '环比数据';
|
|
} else if (item.Serverpart_Name === 'YOY') {
|
|
item.Serverpart_Name = '同比数据';
|
|
} else {
|
|
item.Serverpart_Name = '当前数据';
|
|
}
|
|
});
|
|
}
|
|
|
|
console.log('入区车流', JSON.parse(JSON.stringify(trafficList)));
|
|
|
|
// 组合最终数据
|
|
let NewPythonData = {
|
|
...NewLastData.Result_Data.MonthRevenueModel,
|
|
GrowthRate: NewLastData.Result_Data.GrowthRate,
|
|
BusinessTypeList: NewLastData.Result_Data.BusinessTypeList,
|
|
BayonetEntryList: trafficList
|
|
};
|
|
|
|
console.log('处理了的数据', JSON.parse(JSON.stringify(NewPythonData)));
|
|
|
|
// 显示数据
|
|
displayData(NewPythonData, trafficList, lastData);
|
|
|
|
} catch (error) {
|
|
console.error('加载数据失败:', error);
|
|
showError(error.message);
|
|
}
|
|
}
|
|
|
|
// 显示数据
|
|
function displayData(finalData, trafficList, rawData) {
|
|
document.getElementById('loadingDiv').style.display = 'none';
|
|
document.getElementById('resultDiv').style.display = 'block';
|
|
|
|
const jsonString = JSON.stringify(finalData, null, 2);
|
|
document.getElementById('finalData').textContent = jsonString;
|
|
|
|
// 添加复制按钮事件
|
|
const copyBtn = document.getElementById('copyBtn');
|
|
copyBtn.addEventListener('click', function () {
|
|
navigator.clipboard.writeText(jsonString).then(() => {
|
|
// 复制成功提示
|
|
const originalText = copyBtn.textContent;
|
|
copyBtn.textContent = '✓ 已复制!';
|
|
copyBtn.classList.add('copied');
|
|
|
|
setTimeout(() => {
|
|
copyBtn.textContent = originalText;
|
|
copyBtn.classList.remove('copied');
|
|
}, 2000);
|
|
}).catch(err => {
|
|
console.error('复制失败:', err);
|
|
alert('复制失败,请手动复制');
|
|
});
|
|
});
|
|
}
|
|
|
|
// 显示错误
|
|
function showError(message) {
|
|
document.getElementById('loadingDiv').style.display = 'none';
|
|
const errorDiv = document.getElementById('errorDiv');
|
|
errorDiv.className = 'error';
|
|
errorDiv.innerHTML = `<strong>错误:</strong> ${message}`;
|
|
errorDiv.style.display = 'block';
|
|
}
|
|
|
|
// 页面加载完成后执行
|
|
window.addEventListener('DOMContentLoaded', loadData);
|
|
</script>
|
|
</body>
|
|
|
|
</html> |