index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div class="card-list">
  3. <Row v-for="row in list" :key="row.id" :row="row" />
  4. </div>
  5. </template>
  6. <script lang="js" setup>
  7. import { ref, onBeforeMount } from 'vue'
  8. import Row from './row.vue'
  9. import { statisticsHome,statisticsHomePart1 } from '@/api/dashboard.js'
  10. const list = ref([
  11. { id: 1, name: '用户总数', data: '31258', color: '#4e73df', icon: 'sfont system-yonghu' },
  12. { id: 2, name: '当日增长用户数', data: '5542', color: '#1cc88a', icon: 'sfont system-xiaoxi' },
  13. { id: 3, name: '总收益金额(元)', data: '108827', color: '#36b9cc', icon: 'sfont system-shuliang_mianxing' },
  14. { id: 4, name: '当日收益金额(元)', data: '64581.04', color: '#f6c23e', icon: 'sfont system-jindutiaoshouyidaozhang' }
  15. ])
  16. const getTopCountData = async () => {
  17. try {
  18. const res = await statisticsHomePart1()
  19. const { totalAmount, todayAmount, userCount,todayUserCount } = res.data
  20. list.value = [
  21. { id: 1, name: '用户总数', data: userCount || 0, color: '#4e73df', icon: 'sfont system-yonghu' },
  22. { id: 2, name: '当日增长用户数', data: todayUserCount || 0, color: '#1cc88a', icon: 'sfont system-xiaoxi' },
  23. { id: 3, name: '总收益金额(元)', data: totalAmount || 0, color: '#36b9cc', icon: 'sfont system-shuliang_mianxing' },
  24. { id: 4, name: '当日收益金额(元)', data: parseFloat(todayAmount || 0).toFixed(2), color: '#f6c23e', icon: 'sfont system-jindutiaoshouyidaozhang' }
  25. ]
  26. } catch (e) {
  27. console.log('错误', e)
  28. }
  29. }
  30. onBeforeMount(() => {
  31. getTopCountData()
  32. })
  33. </script>
  34. <style lang="scss" scoped>
  35. .card-list {
  36. width: calc(100% + 20px);
  37. margin-left: -10px;
  38. display: flex;
  39. flex-wrap: wrap;
  40. margin-bottom: 10px;
  41. }
  42. </style>