member-sleep.vue
2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
<workbench-card title="沉睡会员概览" subtitle="沉睡区间分布" icon="el-icon-moon" tone="purple" :loading="loading">
<div class="wb-kpi-grid kpi-2">
<div class="wb-kpi-cell wb-kpi-cell--warning">
<div class="wb-kpi-cell__label">60-89天</div>
<div class="wb-kpi-cell__value">{{ formatNumber(data.sleep_60_89) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--danger">
<div class="wb-kpi-cell__label">90-179天</div>
<div class="wb-kpi-cell__value">{{ formatNumber(data.sleep_90_179) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--info">
<div class="wb-kpi-cell__label">180-359天</div>
<div class="wb-kpi-cell__value">{{ formatNumber(data.sleep_180_359) }}</div>
</div>
<div class="wb-kpi-cell wb-kpi-cell--primary">
<div class="wb-kpi-cell__label">360天+</div>
<div class="wb-kpi-cell__value">{{ formatNumber(data.sleep_360_plus) }}</div>
</div>
</div>
<div class="sleep-total">合计沉睡:{{ formatNumber(data.totalSleepMembers) }} 人</div>
</workbench-card>
</template>
<script>
import request from '@/utils/request'
import WorkbenchCard from '../workbench-card.vue'
import { formatNumber, getCurrentMonthYm } from '../utils'
export default {
name: 'WidgetMemberSleep',
components: { WorkbenchCard },
data() {
return { loading: false, data: {} }
},
mounted() {
this.load()
},
methods: {
formatNumber,
async load() {
this.loading = true
try {
const res = await request({
url: '/api/Extend/LqReport/get-dashboard-data',
method: 'POST',
data: { StatisticsMonth: getCurrentMonthYm() }
})
const ms = (res.data && res.data.Success && res.data.Data && res.data.Data.MemberStatistics)
? res.data.Data.MemberStatistics : {}
this.data = {
totalSleepMembers: ms.TotalSleepMembers || 0,
sleep_60_89: ms.SleepMembers60_89 || 0,
sleep_90_179: ms.SleepMembers90_179 || 0,
sleep_180_359: ms.SleepMembers180_359 || 0,
sleep_360_plus: ms.SleepMembers360Plus || 0
}
} catch (e) {
this.data = {}
} finally {
this.loading = false
}
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
.kpi-2 { grid-template-columns: repeat(2, 1fr); }
.sleep-total {
margin-top: 10px;
text-align: center;
font-size: 12px;
color: #94a3b8;
}
</style>