修复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

@@ -1,76 +0,0 @@
<template>
<view class="page-container">
<view class="page-content">
<view class="placeholder-card">
<text class="placeholder-title">正在跳转...</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { onMounted } from 'vue'
import { openRoute } from '@/layouts/admin/store/adminNavStore.uts'
onMounted(() => {
openRoute('product_productList')
})
</script>
<style scoped lang="scss">
.page-container {
padding: 20px;
min-height: 100vh;
background: #f5f5f5;
}
.page-header {
margin-bottom: 20px;
}
.page-title {
display: block;
font-size: 24px;
font-weight: 600;
color: #333;
margin-bottom: 8px;
}
.page-subtitle {
display: block;
font-size: 14px;
color: #999;
}
.page-content {
background: #fff;
border-radius: 4px;
padding: 24px;
}
.placeholder-card {
text-align: center;
padding: 60px 20px;
}
.placeholder-title {
display: block;
font-size: 18px;
font-weight: 600;
color: #666;
margin-bottom: 12px;
}
.placeholder-desc {
display: block;
font-size: 14px;
color: #999;
margin-bottom: 8px;
}
.placeholder-info {
display: block;
font-size: 12px;
color: #1890ff;
}
</style>

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
}