282 lines
8.0 KiB
HTML
282 lines
8.0 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>
|
|
|
|
<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">
|
|
carData (Result_Data.List)
|
|
<button id="copyBtn" class="copy-btn">📋 复制数据</button>
|
|
</div>
|
|
<div class="data-content">
|
|
<pre id="carData"></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') || '202401';
|
|
|
|
// 更新页面显示的参数信息
|
|
document.getElementById('statisticsMonth').textContent = statisticsMonth;
|
|
|
|
// API 请求
|
|
let req = {
|
|
StatisticsMonth: statisticsMonth
|
|
};
|
|
|
|
const res = await request.$webGet('CommercialApi/BigData/GetProvinceMonthAnalysis', req);
|
|
const carData = res.Result_Data.List;
|
|
|
|
console.log('this.carDatathis.carData', JSON.parse(JSON.stringify(carData)));
|
|
|
|
// 显示数据
|
|
displayData(carData);
|
|
|
|
} catch (error) {
|
|
console.error('加载数据失败:', error);
|
|
showError(error.message);
|
|
}
|
|
}
|
|
|
|
// 显示数据
|
|
function displayData(carData) {
|
|
document.getElementById('loadingDiv').style.display = 'none';
|
|
document.getElementById('resultDiv').style.display = 'block';
|
|
|
|
const jsonString = JSON.stringify(carData, null, 2);
|
|
document.getElementById('carData').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> |