const DashboardView = {
template: `
数据概览
人
人
笔
¥
¥
`,
setup() {
const { ref, onMounted, computed } = Vue;
const userStats = ref({ total: 0, today: 0, thisWeek: 0, thisMonth: 0 });
const orderStats = ref({ totalCount: 0, paidCount: 0, todayPaid: 0, weekPaid: 0, monthPaid: 0, monthIncome: 0, weekIncome: 0 });
const monthIncome = computed(() => (orderStats.value.monthIncome / 100).toFixed(2));
const weekIncome = computed(() => (orderStats.value.weekIncome / 100).toFixed(2));
const toNum = (obj) => { const r = {}; for (const k in obj) r[k] = Number(obj[k]); return r; };
onMounted(async () => {
try { userStats.value = toNum(await userApi.stats()); } catch(e) {}
try { orderStats.value = toNum(await orderApi.stats()); } catch(e) {}
});
return { userStats, orderStats, monthIncome, weekIncome };
}
};