gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<script lang="ts" setup>
import type { Dayjs } from 'dayjs';
 
import { ref } from 'vue';
 
import { fenToYuan } from '..\..\..\..\..\packages\utils\src';
 
import { Card } from 'ant-design-vue';
 
import { getMemberAnalyse } from '#/api/mall/statistics/member';
import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker';
 
/** 会员概览卡片 */
defineOptions({ name: 'MemberFunnelCard' });
 
const loading = ref(false);
const analyseData = ref<any>();
 
/** 查询会员概览数据列表 */
async function loadData(times: [Dayjs, Dayjs]) {
  if (!times || times.length !== 2) {
    return;
  }
  loading.value = true;
  try {
    analyseData.value = await getMemberAnalyse({
      times,
    });
  } finally {
    loading.value = false;
  }
}
 
/** 时间范围改变 */
const handleTimeRangeChange = (times: [Dayjs, Dayjs]) => {
  loadData(times);
};
 
/** 计算环比增长率 */
const calculateRelativeRate = (value?: number, reference?: number) => {
  if (!reference || reference === 0) {
    return 0;
  }
  return (((value || 0) - reference) / reference) * 100;
};
</script>
 
<template>
  <Card :bordered="false" :loading="loading">
    <template #title>
      <div class="flex items-center justify-between">
        <span>会员概览</span>
        <ShortcutDateRangePicker @change="handleTimeRangeChange" />
      </div>
    </template>
    <div class="min-w-[900px] py-4">
      <div class="flex h-24">
        <div class="flex w-[75%] bg-blue-50">
          <div class="ml-[50px] flex flex-col justify-center">
            <div class="font-bold">
              注册用户数量:
              {{ analyseData?.comparison?.value?.registerUserCount || 0 }}
            </div>
            <div class="mt-2 text-sm">
              环比增长率:
              {{
                calculateRelativeRate(
                  analyseData?.comparison?.value?.registerUserCount,
                  analyseData?.comparison?.reference?.registerUserCount,
                ).toFixed(2)
              }}%
            </div>
          </div>
        </div>
        <div
          class="-ml-[154px] mt-1.5 flex w-[308px] flex-col items-center justify-center bg-blue-500 text-sm text-white [transform:perspective(5em)_rotateX(-11deg)]"
        >
          <span class="text-2xl font-bold">
            {{ analyseData?.visitUserCount || 0 }}
          </span>
          <span>访客</span>
        </div>
      </div>
      <div class="flex h-24">
        <div class="flex w-[75%] bg-cyan-50">
          <div class="ml-[50px] flex flex-col justify-center">
            <div class="font-bold">
              活跃用户数量:
              {{ analyseData?.comparison?.value?.visitUserCount || 0 }}
            </div>
            <div class="mt-2 text-sm">
              环比增长率:
              {{
                calculateRelativeRate(
                  analyseData?.comparison?.value?.visitUserCount,
                  analyseData?.comparison?.reference?.visitUserCount,
                ).toFixed(2)
              }}%
            </div>
          </div>
        </div>
        <div
          class="-ml-[112px] mt-[6.8px] flex h-[100px] w-[224px] flex-col items-center justify-center bg-cyan-500 text-sm text-white [transform:perspective(7em)_rotateX(-20deg)]"
        >
          <span class="text-2xl font-bold">
            {{ analyseData?.orderUserCount || 0 }}
          </span>
          <span>下单</span>
        </div>
      </div>
      <div class="flex h-24">
        <div class="flex w-[75%] bg-slate-50">
          <div class="ml-[50px] flex flex-row gap-x-16">
            <div class="flex flex-col justify-center">
              <div class="font-bold">
                充值用户数量:
                {{ analyseData?.comparison?.value?.rechargeUserCount || 0 }}
              </div>
              <div class="mt-2 text-sm">
                环比增长率:
                {{
                  calculateRelativeRate(
                    analyseData?.comparison?.value?.rechargeUserCount,
                    analyseData?.comparison?.reference?.rechargeUserCount,
                  ).toFixed(2)
                }}%
              </div>
            </div>
            <div class="flex flex-col justify-center">
              <div class="font-bold">
                客单价:{{ fenToYuan(analyseData?.atv || 0) }}
              </div>
            </div>
          </div>
        </div>
        <div
          class="-ml-[72px] mt-[13px] flex h-[92px] w-[144px] flex-col items-center justify-center bg-slate-500 text-sm text-white [transform:perspective(3em)_rotateX(-13deg)]"
        >
          <span class="text-2xl font-bold">
            {{ analyseData?.payUserCount || 0 }}
          </span>
          <span>成交用户</span>
        </div>
      </div>
    </div>
  </Card>
</template>