修复bug

This commit is contained in:
2026-03-20 15:24:59 +08:00
parent 14b506036c
commit 29f588a2b2
13 changed files with 321 additions and 2003 deletions

View File

@@ -173,8 +173,10 @@ async function loadAllData() {
const startTime = startDate.value ? (startDate.value + ' 00:00:00') : new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString()
const endTime = endDate.value ? (endDate.value + ' 23:59:59') : new Date().toISOString()
// 各图表独立 try-catch单个接口失败如 404不影响其他区块展示
// 1. 加载核心指标
try {
// 1. 加载核心指标
const stats = await fetchAdminProductStats(startTime, endTime)
if (stats != null) {
statItems.value.forEach(item => {
@@ -182,16 +184,24 @@ async function loadAllData() {
item.value = typeof val === 'number' ? (item.key.includes('amount') ? val.toFixed(2) : String(val)) : String(val ?? '0')
})
}
} catch (e) {
console.error('[product-stats] 核心指标加载失败', e)
}
// 2. 加载趋势图
// 2. 加载趋势图rpc_admin_product_trend 404 时返回空数组,图表为空但不崩溃)
try {
const trendData = await fetchAdminProductTrend(startTime, endTime)
initChart(trendData)
} catch (e) {
console.error('[product-stats] 趋势图加载失败', e)
}
// 3. 加载排行
// 3. 加载排行rpc_admin_product_ranking 404 时返回空数组)
try {
const rankingData = await fetchAdminProductRanking(startTime, endTime, 'sales', 10)
rankingList.value = rankingData
} catch (e) {
uni.showToast({ title: '加载统计失败', icon: 'none' })
console.error('[product-stats] 排行加载失败', e)
} finally {
loading.value = false
}