Browse Source

优化图表

tags/小炒逻辑变更前
yangwenhua 2 years ago
parent
commit
3e900b86f9
1 changed files with 26 additions and 3 deletions
  1. +26
    -3
      src/pages/order/order-member-statement/index.jsx

+ 26
- 3
src/pages/order/order-member-statement/index.jsx View File

@@ -30,6 +30,10 @@ export default function Index() {
newAddUser: [],
repurChase: []
});
//新增会员数
const [newMemberNum, setNewMemberNum] = useState(0);
//复购次数
const [repurChaseNum, setRepurChaseNum] = useState(0);

//新增会员图表实例
let newMemberObj = null;
@@ -116,6 +120,16 @@ export default function Index() {
const response = await marketAPI.getMemberReport(jsonData);
setShowLoading(false);
if (response.statusCode === 200) {
let sumNewMember = 0;
let sumRepurChase = 0;
response.data.newAddUser.forEach(item => {
sumNewMember += item.userValue
});
response.data.repurChase.forEach(item => {
sumRepurChase += item.userValue
});
setNewMemberNum(sumNewMember);
setRepurChaseNum(sumRepurChase);
setMemberReport(response.data);
} else {
message.error(response.errors || '获取会员报表失败');
@@ -133,7 +147,7 @@ export default function Index() {
const seriesData = [];
memberReport.newAddUser.forEach(item => {
const date = new Date(item.userKey);
xAxisData.push(date.toLocaleString());
xAxisData.push(date.toLocaleDateString());
seriesData.push(item.userValue);
});
const option = {
@@ -173,6 +187,15 @@ export default function Index() {
title: {
text: '复购次数'
},
tooltip: {
trigger: 'axis',
axisPointer: {
label: {
show: true,
formatter: '复购{value}次'
}
}
},
xAxis: {
type: 'category',
data: xAxisData
@@ -284,7 +307,7 @@ export default function Index() {
新增会员
</div>
<div className={styles['member-card-sufixx']}>
{memberReport.newAddUser.length}
{newMemberNum}
</div>
</div>
<div className={styles['member-card-box']}>
@@ -292,7 +315,7 @@ export default function Index() {
复购数量
</div>
<div className={styles['member-card-sufixx']}>
{memberReport.repurChase.length}
{repurChaseNum}
</div>
</div>
</Card>


Loading…
Cancel
Save