<template>
	<NavBar />
	<view class="container">
		<view class="title">
			<PageTitle :title="$t('menu.partner')" />
		</view>
	</view>
	<OverviewChart :chartData="overviewData" />
</template>

<script>
import OverviewChart from '@/pages/components/overviewChart/index.vue';
import { getOverviewChart } from '@/services/partner/overview.ts';
import dayjs from 'dayjs';
export default {
	data() {
		return {
			chartParams: {},
			overviewData: {}
		};
	},
	methods: {
		async getOverviewChartData() {
			const res = await getOverviewChart(this.chartParams);
			if (res && res.code === 0) {
				this.overviewData.categories = res.data.map((item) => dayjs(item.date).format('M-D'));
				this.overviewData.series = [{ name: this.chartParams.label, data: res.data.map((item) => item.amount) }];
			}
		}
	},
	onLoad(params) {
		this.chartParams = JSON.parse(params.params);
		this.getOverviewChartData();
	},
	components: {
		OverviewChart
	}
};
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
