index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div>
  3. <lineChartModel :tableData="tableData" :lineListData="lineListData" title="收益" />
  4. <lineChartModel :tableData="tableData" :lineListData="lineListData" :type="'ecpm'" title="ECPM趋势" />
  5. <userDataChart />
  6. </div>
  7. </template>
  8. <script setup>
  9. import { ref, onBeforeMount } from 'vue'
  10. import { getIndexProfit, getIndexHourReport } from '@/api/dashboard.js'
  11. import lineChartModel from './lineChartModel.vue'
  12. import userDataChart from './userDataChart.vue'
  13. const tableData = ref([])
  14. const getIndexProfitData = async () => {
  15. const res = await getIndexProfit()
  16. tableData.value = res.data
  17. }
  18. const lineListData = ref({})
  19. const getIndexHourReportData = async () => {
  20. const res = await getIndexHourReport()
  21. // 整理 lineListData
  22. lineListData.value = res.data.reduce((acc, item) => {
  23. const { channelName, estimatedRevenueList, estimatedRevenueEcpmList } = item;
  24. acc[channelName] = { estimatedRevenueList, estimatedRevenueEcpmList };
  25. return acc;
  26. }, {});
  27. }
  28. onBeforeMount(async () => {
  29. await getIndexProfitData()
  30. await getIndexHourReportData()
  31. })
  32. </script>
  33. <style lang="scss" scoped></style>