|
|
@@ -4,9 +4,9 @@
|
|
|
<div class="layout-container-main-top">
|
|
|
<div class="top-left">
|
|
|
<div class="line"></div>
|
|
|
- <span>收益</span>
|
|
|
+ <span>{{ title }}</span>
|
|
|
</div>
|
|
|
- <div class="main">
|
|
|
+ <div class="main" v-if="type === 'earn'">
|
|
|
<el-row>
|
|
|
<el-col :span="8">
|
|
|
<el-statistic title="今日收益" :value="268.5" precision="2" />
|
|
|
@@ -24,9 +24,9 @@
|
|
|
<el-table class="table" :data="tableData" border height="100%" :fit="true" :scroll-x="false"
|
|
|
:style="{ width: '100%' }">
|
|
|
<el-table-column prop="platform" label="统计" align="center" />
|
|
|
- <el-table-column prop="today" label="今日" align="center" />
|
|
|
- <el-table-column prop="yesterday" label="昨日" align="center" />
|
|
|
- <el-table-column prop="month" label="本月" align="center" />
|
|
|
+ <el-table-column :prop="type === 'earn' ? 'today' : 'ecpmToday'" label="今日" align="center" />
|
|
|
+ <el-table-column :prop="type === 'earn' ? 'yesterday' : 'ecpmYesterday'" label="今日" align="center" />
|
|
|
+ <el-table-column :prop="type === 'earn' ? 'month' : 'ecpmMonth'" label="今日" align="center" />
|
|
|
</el-table>
|
|
|
|
|
|
<Chart class="chart" :option="options" />
|
|
|
@@ -36,24 +36,30 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { defineComponent, reactive, ref, onMounted, onBeforeMount } from 'vue'
|
|
|
+import { ref, watch } from 'vue'
|
|
|
import Chart from '@/components/charts/index.vue'
|
|
|
-import { getIndexProfit } from '@/api/dashboard.js'
|
|
|
-//穿山甲、优量汇、快手、Sigmob、百度
|
|
|
|
|
|
-// 收益统计表格数据格式
|
|
|
-const tableData = ref([])
|
|
|
-
|
|
|
-const getIndexProfitData = async () => {
|
|
|
- let res = await getIndexProfit()
|
|
|
- tableData.value = res.data
|
|
|
-
|
|
|
- console.log('收益数据', res)
|
|
|
-}
|
|
|
-
|
|
|
-onBeforeMount(async () => {
|
|
|
- await getIndexProfitData()
|
|
|
-})
|
|
|
+const props = defineProps({
|
|
|
+ // 表格数据
|
|
|
+ tableData: {
|
|
|
+ type: Array,
|
|
|
+ default: []
|
|
|
+ },
|
|
|
+ // 折线图数据
|
|
|
+ lineListData: {
|
|
|
+ type: Object,
|
|
|
+ default: {}
|
|
|
+ },
|
|
|
+ // 类型 'earn'- 收益 | 'ecpm'
|
|
|
+ type: {
|
|
|
+ type: String,
|
|
|
+ default: 'earn'
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
const xAxisList = [
|
|
|
'00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00',
|
|
|
@@ -61,39 +67,7 @@ const xAxisList = [
|
|
|
'16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'
|
|
|
];
|
|
|
|
|
|
-const seriesData = [450, 200, 300, 520, 800, 760, 700, 680, 700, 650, 690, 710, 450, 200, 300, 520, 800, 760, 700, 680, 700, 650, 690, 710];
|
|
|
-// 穿山甲数据(随机生成,保持原40-80范围)
|
|
|
-const seriesData1 = [42, 25, 33, 55, 76, 68, 72, 63, 71, 65, 62, 69, 45, 22, 31, 53, 79, 73, 68, 64, 72, 61, 67, 70];
|
|
|
-
|
|
|
-// 优量汇数据(模拟中型广告平台,范围200-500)
|
|
|
-const seriesData2 = (() => {
|
|
|
- const base = [380, 210, 290, 470, 490, 420, 450, 430, 460, 410, 440, 480];
|
|
|
- return [...base, ...base.map(v => v * 0.9)]; // 下午数据略降
|
|
|
-})();
|
|
|
-
|
|
|
-// 快手数据(模拟短视频平台,高峰在晚间)
|
|
|
-const seriesData3 = [
|
|
|
- 320, 180, 220, 300, 350,
|
|
|
- 420, 550, 680, 720, 650, // 早高峰
|
|
|
- 600, 580, 320, 280, 350,
|
|
|
- 480, 620, 750, 820, 880, // 晚高峰
|
|
|
- 760, 680, 550, 450
|
|
|
-];
|
|
|
-
|
|
|
-// Sigmob数据(模拟国际广告平台,较平稳)
|
|
|
-const seriesData4 = Array(24).fill(0).map(
|
|
|
- (_, i) => 350 + Math.sin(i / 4) * 100 + (i > 12 ? -20 : 0) + Math.random() * 30
|
|
|
-).map(v => Math.round(v));
|
|
|
-
|
|
|
-// 百度数据(模拟搜索广告,白天稳定)
|
|
|
-const seriesData5 = xAxisList.map((_, i) =>
|
|
|
- i < 8 ? 280 + i * 20 : // 清晨上升
|
|
|
- i < 18 ? 420 + (i % 3) * 15 : // 白天稳定
|
|
|
- 400 - (i - 18) * 25 // 夜间下降
|
|
|
-);
|
|
|
-
|
|
|
-
|
|
|
-const options = {
|
|
|
+const options = ref({
|
|
|
/* title: {
|
|
|
text: "单位:个",
|
|
|
textStyle: {
|
|
|
@@ -128,7 +102,7 @@ const options = {
|
|
|
}
|
|
|
},
|
|
|
legend: {
|
|
|
- data: ['平均收益', '穿山甲', '优量汇', '快手', 'Sigmob', '百度'],
|
|
|
+ data: ['穿山甲', '优量汇', '快手', 'Sigmob', '百度'],
|
|
|
top: 'top',
|
|
|
textStyle: {
|
|
|
color: '#808080'
|
|
|
@@ -174,111 +148,77 @@ const options = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- series: [
|
|
|
- {
|
|
|
- type: 'line',
|
|
|
- name: '平均收益',
|
|
|
- symbolSize: 6,
|
|
|
- z: 1,
|
|
|
- label: {
|
|
|
- show: false // Hide labels
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- color: '#70e3cd'
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: '#70e3cd',
|
|
|
- width: 2,
|
|
|
- },
|
|
|
- data: seriesData,
|
|
|
- },
|
|
|
+ series: []
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+// 监听 props.lineListData 变化,动态更新 series
|
|
|
+watch(() => props.lineListData, (newVal) => {
|
|
|
+ if (Object.keys(newVal).length === 0) return; // 空数据不更新
|
|
|
+
|
|
|
+ options.value.series = [
|
|
|
{
|
|
|
type: 'line',
|
|
|
name: '穿山甲',
|
|
|
symbolSize: 6,
|
|
|
z: 1,
|
|
|
- label: {
|
|
|
- show: false // Hide labels
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- color: '#add7f6'
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: '#add7f6',
|
|
|
- width: 2,
|
|
|
- },
|
|
|
- data: seriesData1,
|
|
|
+ label: { show: false },
|
|
|
+ itemStyle: { color: '#add7f6' },
|
|
|
+ lineStyle: { color: '#add7f6', width: 2 },
|
|
|
+ data: props.type === 'earn' ?
|
|
|
+ newVal['穿山甲']?.estimatedRevenueList ?? [] :
|
|
|
+ newVal['穿山甲']?.estimatedRevenueEcpmList ?? []
|
|
|
},
|
|
|
{
|
|
|
type: 'line',
|
|
|
name: '优量汇',
|
|
|
symbolSize: 6,
|
|
|
z: 1,
|
|
|
- label: {
|
|
|
- show: false // Hide labels
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- color: '#f7a8b8'
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: '#f7a8b8',
|
|
|
- width: 2,
|
|
|
- },
|
|
|
- data: seriesData2,
|
|
|
+ label: { show: false },
|
|
|
+ itemStyle: { color: '#f7a8b8' },
|
|
|
+ lineStyle: { color: '#f7a8b8', width: 2 },
|
|
|
+ data: props.type === 'earn' ?
|
|
|
+ newVal['优量汇']?.estimatedRevenueList ?? [] :
|
|
|
+ newVal['优量汇']?.estimatedRevenueEcpmList ?? []
|
|
|
},
|
|
|
{
|
|
|
type: 'line',
|
|
|
name: '快手',
|
|
|
symbolSize: 6,
|
|
|
z: 1,
|
|
|
- label: {
|
|
|
- show: false // Hide labels
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- color: '#ffcc5c'
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: '#ffcc5c',
|
|
|
- width: 2,
|
|
|
- },
|
|
|
- data: seriesData3,
|
|
|
+ label: { show: false },
|
|
|
+ itemStyle: { color: '#ffcc5c' },
|
|
|
+ lineStyle: { color: '#ffcc5c', width: 2 },
|
|
|
+ data: props.type === 'earn' ?
|
|
|
+ newVal['快手']?.estimatedRevenueList ?? [] :
|
|
|
+ newVal['快手']?.estimatedRevenueEcpmList ?? []
|
|
|
},
|
|
|
{
|
|
|
type: 'line',
|
|
|
name: 'Sigmob',
|
|
|
symbolSize: 6,
|
|
|
z: 1,
|
|
|
- label: {
|
|
|
- show: false // Hide labels
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- color: '#88d8b0'
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: '#88d8b0',
|
|
|
- width: 2,
|
|
|
- },
|
|
|
- data: seriesData4,
|
|
|
+ label: { show: false },
|
|
|
+ itemStyle: { color: '#88d8b0' },
|
|
|
+ lineStyle: { color: '#88d8b0', width: 2 },
|
|
|
+ data: props.type === 'earn' ?
|
|
|
+ newVal['Sigmob']?.estimatedRevenueList ?? [] :
|
|
|
+ newVal['Sigmob']?.estimatedRevenueEcpmList ?? []
|
|
|
},
|
|
|
{
|
|
|
type: 'line',
|
|
|
name: '百度',
|
|
|
symbolSize: 6,
|
|
|
z: 1,
|
|
|
- label: {
|
|
|
- show: false // Hide labels
|
|
|
- },
|
|
|
- itemStyle: {
|
|
|
- color: '#9966cc'
|
|
|
- },
|
|
|
- lineStyle: {
|
|
|
- color: '#9966cc',
|
|
|
- width: 2,
|
|
|
- },
|
|
|
- data: seriesData5,
|
|
|
+ label: { show: false },
|
|
|
+ itemStyle: { color: '#9966cc' },
|
|
|
+ lineStyle: { color: '#9966cc', width: 2 },
|
|
|
+ data: props.type === 'earn' ?
|
|
|
+ newVal['百度']?.estimatedRevenueList ?? [] :
|
|
|
+ newVal['百度']?.estimatedRevenueEcpmList ?? []
|
|
|
}
|
|
|
]
|
|
|
-};
|
|
|
+}, { immediate: true })
|
|
|
|
|
|
</script>
|
|
|
|