repurchase.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view class="page">
  3. <NavBar title="复购统计" :showBack="true" />
  4. <scroll-view class="list-scroll" scroll-y v-if="data">
  5. <view class="section">
  6. <text class="section-title">复购概况</text>
  7. <view class="stats-grid">
  8. <view class="stat-item"><text class="stat-value">{{ (data.repurchaseRate || 0).toFixed(1) }}%</text><text class="stat-label">复购率</text></view>
  9. <view class="stat-item"><text class="stat-value">{{ data.repurchaseUsers || 0 }}</text><text class="stat-label">复购用户</text></view>
  10. <view class="stat-item"><text class="stat-value">{{ data.totalUsers || 0 }}</text><text class="stat-label">总用户</text></view>
  11. </view>
  12. </view>
  13. <view class="end-tip"><text>-- 数据截至最近30天 --</text></view>
  14. </scroll-view>
  15. </view>
  16. </template>
  17. <script setup lang="ts">
  18. import { ref, onMounted } from 'vue';
  19. import NavBar from '@/components/NavBar.vue';
  20. import { get } from '@/utils/request';
  21. import { formatDate } from '@/utils/common';
  22. const data = ref<any>(null);
  23. const loadData = async () => {
  24. try {
  25. const end = formatDate(new Date()); const start = formatDate(new Date(Date.now()-30*86400000));
  26. data.value = await get('/statistics/repurchase/overview', { startDate: start, endDate: end });
  27. } catch { }
  28. };
  29. onMounted(() => loadData());
  30. </script>
  31. <style lang="scss" scoped>
  32. .page { height: 100vh; background: $bg-color-page; display: flex; flex-direction: column; }
  33. .list-scroll { flex: 1; height: 0; }
  34. .section { background: $bg-color-card; margin-bottom: $spacing-2; padding: $spacing-3 $spacing-4; }
  35. .section-title { display: block; font-size: 28rpx; font-weight: 600; color: $text-color-primary; margin-bottom: $spacing-3; padding-bottom: $spacing-2; border-bottom: 1rpx solid $border-color-light; }
  36. .stats-grid { display: flex; }
  37. .stat-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: $spacing-3 0; }
  38. .stat-value { font-size: $font-size-2xl; font-weight: 700; color: $text-color-primary; margin-bottom: $spacing-1; }
  39. .stat-label { font-size: 24rpx; color: $text-color-muted; }
  40. .end-tip { text-align: center; padding: 36rpx; font-size: 24rpx; color: $text-color-placeholder; }
  41. </style>