|
@@ -1,287 +1,42 @@
|
|
|
-import { defineComponent, nextTick, onMounted, ref } from "vue";
|
|
|
-import styles from './index.module.less';
|
|
|
-import icon1 from '../images/icon1.png';
|
|
|
-import iconArrow from '../images/icon-arrow.png';
|
|
|
-import iconArrow1 from '../images/icon-arrow1.png';
|
|
|
-import iconArrow11 from '../images/icon-arrow1-1.png';
|
|
|
-import { Popover } from "vant";
|
|
|
-
|
|
|
-import * as echarts from 'echarts/core'
|
|
|
-import {
|
|
|
- LineChart,
|
|
|
- // LineSeriesOption
|
|
|
-} from 'echarts/charts'
|
|
|
-// import { PieChart } from 'echarts/charts'
|
|
|
-import {
|
|
|
- TitleComponent,
|
|
|
- // 组件类型的定义后缀都为 ComponentOption
|
|
|
- // TitleComponentOption,
|
|
|
- TooltipComponent,
|
|
|
- // TooltipComponentOption,
|
|
|
- GridComponent,
|
|
|
- // 数据集组件
|
|
|
- DatasetComponent,
|
|
|
- // DatasetComponentOption,
|
|
|
- // 内置数据转换器组件 (filter, sort)
|
|
|
- // TransformComponent,
|
|
|
- LegendComponent,
|
|
|
- ToolboxComponent,
|
|
|
- DataZoomComponent
|
|
|
-} from 'echarts/components'
|
|
|
-import { LabelLayout } from 'echarts/features'
|
|
|
-import { CanvasRenderer } from 'echarts/renderers'
|
|
|
-import { format } from "path";
|
|
|
-
|
|
|
-// 注册必须的组件
|
|
|
-echarts.use([
|
|
|
- TitleComponent,
|
|
|
- TooltipComponent,
|
|
|
- GridComponent,
|
|
|
- DatasetComponent,
|
|
|
- // TransformComponent,
|
|
|
- LabelLayout,
|
|
|
- // UniversalTransition,
|
|
|
- CanvasRenderer,
|
|
|
- // PieChart,
|
|
|
- ToolboxComponent,
|
|
|
- LegendComponent,
|
|
|
- DataZoomComponent,
|
|
|
- LineChart
|
|
|
-])
|
|
|
-
|
|
|
-const lineChartOption = (xAxisData: any, seriesData: any) => {
|
|
|
- return {
|
|
|
- title: {
|
|
|
- text: "单位:次",
|
|
|
- textStyle: {
|
|
|
- color: "#777777",
|
|
|
- fontSize: 13,
|
|
|
- fontWeight: 400
|
|
|
- }
|
|
|
- },
|
|
|
- legend: { show: false },
|
|
|
- emphasis: { lineStyle: { width: 2 } },
|
|
|
- xAxis: {
|
|
|
- boundaryGap: false,
|
|
|
- data: xAxisData,
|
|
|
- type: 'category',
|
|
|
- axisLine: { lineStyle: { color: '#8C8C8C' } },
|
|
|
- lineStyle: { color: '#F2F2F2' }
|
|
|
- },
|
|
|
- color: [
|
|
|
- '#2DC7AA',
|
|
|
- '#FF6079',
|
|
|
- // '#2DC7AA',
|
|
|
- // '#FF602C',
|
|
|
- // '#91DD1C',
|
|
|
- // '#FFA92C',
|
|
|
- // '#BE7E2E',
|
|
|
- // '#1C96DD',
|
|
|
- // '#D22CFF',
|
|
|
- // '#FF3C3C',
|
|
|
- // '#1AEE3E',
|
|
|
- // '#00c9ff'
|
|
|
- ],
|
|
|
- series: [
|
|
|
- {
|
|
|
- lineStyle: { width: 1 },
|
|
|
- data: seriesData[0],
|
|
|
- symbol: 'circle',
|
|
|
- name: '浏览次数',
|
|
|
- type: 'line',
|
|
|
- emphasis: { lineStyle: { width: 1 } }
|
|
|
- },
|
|
|
- {
|
|
|
- lineStyle: { width: 1 },
|
|
|
- data: seriesData[1],
|
|
|
- symbol: 'circle',
|
|
|
- name: '购买次数',
|
|
|
- type: 'line',
|
|
|
- areaStyle: {
|
|
|
- color: {
|
|
|
- type: 'linear',
|
|
|
- x: 0,
|
|
|
- y: 0,
|
|
|
- x2: 0,
|
|
|
- y2: 1,
|
|
|
- colorStops: [
|
|
|
- {
|
|
|
- offset: 0,
|
|
|
- color: 'rgba(255, 96, 121, 0.23)'
|
|
|
- // 0% 处的颜色
|
|
|
- },
|
|
|
- {
|
|
|
- offset: 1,
|
|
|
- // 100% 处的颜色
|
|
|
- color: 'rgba(255, 96, 121, 0)'
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
- emphasis: { lineStyle: { width: 1 } }
|
|
|
- }
|
|
|
- ],
|
|
|
- grid: {
|
|
|
- bottom: '3%',
|
|
|
- containLabel: true,
|
|
|
- left: '3%',
|
|
|
- right: '5%',
|
|
|
- top: '40'
|
|
|
- },
|
|
|
- tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
- confine: true,
|
|
|
- formatter: function (params: any) {
|
|
|
- return params[0].name;
|
|
|
- },
|
|
|
- backgroundColor: '#FF6079',
|
|
|
- borderWidth: 0,
|
|
|
- borderRadius: 24,
|
|
|
- padding: [1, 4],
|
|
|
- textStyle: {
|
|
|
- color: '#FFFFFF',
|
|
|
- fontSize: 12
|
|
|
- }
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- type: 'value',
|
|
|
- splitLine: {
|
|
|
- axisLine: { lineStyle: { color: '#8C8C8C' } },
|
|
|
- lineStyle: { color: ['#f2f2f2'], type: 'dashed' }
|
|
|
- }
|
|
|
- },
|
|
|
- dataZoom: [{ type: 'inside', throttle: 100 }],
|
|
|
- toolbox: { feature: { saveAsImage: { show: false } } }
|
|
|
- }
|
|
|
-}
|
|
|
+import { defineComponent } from 'vue'
|
|
|
+import styles from './index.module.less'
|
|
|
+import { Tab, Tabs } from 'vant'
|
|
|
+import Echats from './echats'
|
|
|
+import ColHeader from '@/components/col-header'
|
|
|
+import TheSticky from '@/components/the-sticky'
|
|
|
+import TeacherItem from './teacher-item'
|
|
|
+import List from './list'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'HomeStatistics',
|
|
|
setup() {
|
|
|
- const popoverStatus = ref(false);
|
|
|
- const statisticCounts = ref({
|
|
|
- browseCount: 0,
|
|
|
- buyCount: 0
|
|
|
- })
|
|
|
- let myChart: echarts.ECharts
|
|
|
-
|
|
|
- nextTick(() => {
|
|
|
- myChart = echarts.init(document.getElementById('eChart') as HTMLDivElement)
|
|
|
- })
|
|
|
-
|
|
|
- onMounted(() => {
|
|
|
- nextTick(() => {
|
|
|
- myChart.clear()
|
|
|
- lineChartOption && myChart.setOption(lineChartOption([
|
|
|
- '01月',
|
|
|
- '02月',
|
|
|
- '03月',
|
|
|
- '04月',
|
|
|
- '05月',
|
|
|
- '06月',
|
|
|
- '07月',
|
|
|
- '08月',
|
|
|
- '09月',
|
|
|
- '10月',
|
|
|
- '11月',
|
|
|
- '12月'
|
|
|
- ], [[
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '2',
|
|
|
- '0',
|
|
|
- '8',
|
|
|
- '10',
|
|
|
- '0'
|
|
|
- ], [
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '0',
|
|
|
- '1',
|
|
|
- '3',
|
|
|
- '0',
|
|
|
- '2',
|
|
|
- '0',
|
|
|
- '8',
|
|
|
- '10',
|
|
|
- '0'
|
|
|
- ]]))
|
|
|
- myChart.on('highlight', function (params: any) {
|
|
|
- const batch = params.batch || []
|
|
|
- const options: any = myChart.getOption()
|
|
|
- batch.forEach((item: any) => {
|
|
|
- const batchIndex = item.dataIndex;
|
|
|
-
|
|
|
- const browseCount = options.series[0].data[batchIndex]
|
|
|
- const buyCount = options.series[1].data[batchIndex]
|
|
|
- statisticCounts.value = {
|
|
|
- browseCount,
|
|
|
- buyCount
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
return () => (
|
|
|
<div class={styles.homeStatistics}>
|
|
|
- <div class={styles.homeHead}>
|
|
|
- <div class={styles.title}>
|
|
|
- <img src={icon1} />
|
|
|
- <span>浏览/购买</span>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class={styles.more}>
|
|
|
- <span>详情</span>
|
|
|
- <img src={iconArrow} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class={styles.eChartSection}>
|
|
|
- <div class={styles.eChartTitle}>
|
|
|
- <div class={styles.left}>
|
|
|
- <div class={styles.item} style="--color: #2DC7AA">
|
|
|
- <span class={styles.line}></span>
|
|
|
- <span class={styles.text}>浏览次数</span>
|
|
|
- <span class={styles.num}>{statisticCounts.value.browseCount}次</span>
|
|
|
- </div>
|
|
|
- <div class={styles.item} style="--color: #FF6079">
|
|
|
- <span class={styles.line}></span>
|
|
|
- <span class={styles.text}>购买次数</span>
|
|
|
- <span class={styles.num}>{statisticCounts.value.buyCount}次</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class={styles.right}>
|
|
|
- <Popover v-model:show={popoverStatus.value} showArrow={false}>
|
|
|
- {{
|
|
|
- default: () => (
|
|
|
- <div class={'select-time'}>
|
|
|
- <span>本月</span>
|
|
|
- <span class={'active'}>近三个月</span>
|
|
|
- <span>近半年</span>
|
|
|
- <span>近一年</span>
|
|
|
- </div>),
|
|
|
- reference: () => (<div class={[styles.showItem, popoverStatus.value && styles.showItemActive]}>
|
|
|
- <span>本月</span>
|
|
|
- <img src={popoverStatus.value?iconArrow11 : iconArrow1} />
|
|
|
- </div>)
|
|
|
- }}
|
|
|
- </Popover>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class={styles.eChart}>
|
|
|
- <div id="eChart" style="width: 100%; height: 100%;"></div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <TheSticky position="top">
|
|
|
+ <ColHeader border={false} background="transparent" />
|
|
|
+ </TheSticky>
|
|
|
+
|
|
|
+ <Tabs class={styles.tabs}>
|
|
|
+ <Tab title="VIP定制课" name="vip">
|
|
|
+ <List type="vip" />
|
|
|
+ </Tab>
|
|
|
+ <Tab title="趣纠课" name="practice">
|
|
|
+ <List type="practice" />
|
|
|
+ </Tab>
|
|
|
+ <Tab title="小组课" name="group">
|
|
|
+ <List type="group" />
|
|
|
+ </Tab>
|
|
|
+ <Tab title="直播课" name="live">
|
|
|
+ <List type="live" />
|
|
|
+ </Tab>
|
|
|
+ <Tab title="视频课" name="video">
|
|
|
+ <List type="video" />
|
|
|
+ </Tab>
|
|
|
+ <Tab title="乐谱" name="music">
|
|
|
+ <List type="music" />
|
|
|
+ </Tab>
|
|
|
+ </Tabs>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
-})
|
|
|
+})
|