Files
dvcp_v2_wxcp_app/src/project/saas/AppDataStatistics/components/message.vue

483 lines
12 KiB
Vue
Raw Normal View History

2022-12-11 16:21:17 +08:00
<template>
2022-12-11 17:46:29 +08:00
<div class="message">
2022-12-20 10:44:51 +08:00
<div class="head">
<span>消息回复率</span>
</div>
2022-12-21 10:25:39 +08:00
<div class="echarts_list">
<div id="echarts1"></div>
<div id="echarts2"></div>
<div id="echarts3"></div>
</div>
2022-12-20 10:44:51 +08:00
<div class="head">
<span>单聊统计</span>
</div>
<div class="card">
2022-12-22 16:37:06 +08:00
<div class="item" :class="privateCurrent == 0? 'active':''" @click="privateCurrent = 0,getPrivateData()">
2022-12-22 15:31:49 +08:00
<div class="item_name">单聊会话</div>
2022-12-22 16:07:33 +08:00
<div class="item_num" v-if="privateCard">{{ Number(privateCard.chatCnt).toLocaleString('en-US') }}</div>
2022-12-22 15:31:49 +08:00
<div class="item_num" v-else>0</div>
2022-12-20 10:44:51 +08:00
</div>
2022-12-22 16:37:06 +08:00
<div class="item" :class="privateCurrent == 1? 'active':''" @click="privateCurrent = 1,getPrivateData()">
2022-12-20 10:44:51 +08:00
<div class="item_name">单聊消息</div>
2022-12-22 16:07:33 +08:00
<div class="item_num" v-if="privateCard">{{ Number(privateCard.messageCnt).toLocaleString('en-US') }}</div>
2022-12-22 15:31:49 +08:00
<div class="item_num" v-else>0</div>
2022-12-20 10:44:51 +08:00
</div>
</div>
<div class="privateChat_box">
2022-12-22 16:37:06 +08:00
<div id="privateChat" v-if="privateData.length"></div>
<AiEmpty style="padding-top: 10px;" description="暂无数据" v-else></AiEmpty>
2022-12-20 10:44:51 +08:00
</div>
<div class="head">
<span>群聊统计</span>
</div>
<div class="card">
2022-12-22 16:37:06 +08:00
<div class="item" :class="groupCurrent == 0? 'active':''" @click="groupCurrent = 0,getGroupData()">
2022-12-20 10:44:51 +08:00
<div class="item_name">活跃群聊</div>
2022-12-22 16:07:33 +08:00
<div class="item_num" v-if="groupCard">{{ Number(groupCard.chatHasMsg).toLocaleString('en-US') }}</div>
2022-12-22 15:31:49 +08:00
<div class="item_num" v-else>0</div>
2022-12-20 10:44:51 +08:00
</div>
2022-12-22 16:37:06 +08:00
<div class="item" :class="groupCurrent == 1? 'active':''" @click="groupCurrent = 1,getGroupData()">
2022-12-20 10:44:51 +08:00
<div class="item_name">活跃群成员</div>
2022-12-22 16:07:33 +08:00
<div class="item_num" v-if="groupCard">{{ Number(groupCard.memberHasMsg).toLocaleString('en-US') }}</div>
2022-12-22 15:31:49 +08:00
<div class="item_num" v-else>0</div>
2022-12-20 10:44:51 +08:00
</div>
2022-12-22 16:37:06 +08:00
<div class="item" :class="groupCurrent == 2? 'active':''" @click="groupCurrent = 2,getGroupData()">
2022-12-20 10:44:51 +08:00
<div class="item_name">群聊消息</div>
2022-12-22 16:07:33 +08:00
<div class="item_num" v-if="groupCard">{{ Number(groupCard.msgTotal).toLocaleString('en-US') }}</div>
2022-12-22 15:31:49 +08:00
<div class="item_num" v-else>0</div>
2022-12-20 10:44:51 +08:00
</div>
</div>
<div class="groupChat_box">
2022-12-22 16:37:06 +08:00
<div id="groupChat" v-if="groupData.length"></div>
<AiEmpty style="padding-top: 10px;" description="暂无数据" v-else></AiEmpty>
2022-12-20 10:44:51 +08:00
</div>
2022-12-11 17:46:29 +08:00
</div>
2022-12-11 16:21:17 +08:00
</template>
<script>
2022-12-20 10:44:51 +08:00
import echarts from "echarts"
2022-12-11 16:21:17 +08:00
export default {
2022-12-20 10:44:51 +08:00
name: 'message',
data() {
return {
2022-12-22 17:18:34 +08:00
replyData: {},
2022-12-22 15:31:49 +08:00
privateCard: {},
privateData: [],
2022-12-22 16:07:33 +08:00
privateDate: [],
privateMsg: [],
privateCurrent: 0,
2022-12-22 15:31:49 +08:00
groupCard: {},
groupData: [],
2022-12-22 16:07:33 +08:00
groupDate: [],
groupMsg: [],
groupCurrent: 0,
2022-12-20 10:44:51 +08:00
}
},
2022-12-22 15:31:49 +08:00
created() {
this.getData()
},
2022-12-20 10:44:51 +08:00
mounted() {
2022-12-21 10:25:39 +08:00
this.getEcharts1()
this.getEcharts2()
this.getEcharts3()
2022-12-20 10:44:51 +08:00
this.getPrivateChat()
this.getGroupChat()
},
methods: {
2022-12-22 15:31:49 +08:00
getData() {
// 回复率
this.$http.post(`/app/wxgroupstatistic/replyPercentage`).then(res=> {
if(res?.data) {
2022-12-22 17:18:34 +08:00
this.replyData = res.data
2022-12-22 15:31:49 +08:00
}
})
2022-12-22 16:37:06 +08:00
this.getPrivateData()
this.getGroupData()
},
getPrivateData() {
2022-12-22 15:31:49 +08:00
// 单聊统计
this.$http.post('/app/wxgroupstatistic/getUserChatNumber').then(res=> {
if(res?.data) {
this.privateCard = res.data.单聊总和
this.privateData = res.data.条形统计
2022-12-22 16:37:06 +08:00
this.privateDate = this.privateData?.map(v=> v.dateDay)
if(this.privateCurrent == 0) {
this.privateMsg = this.privateData?.map(v=> v.chatCnt)
} else if(this.privateCurrent == 1) {
this.privateMsg = this.privateData?.map(v=> v.messageCnt)
}
2022-12-22 15:31:49 +08:00
}
})
2022-12-22 16:37:06 +08:00
},
getGroupData() {
2022-12-22 15:31:49 +08:00
// 群聊统计
this.$http.post('/app/wxgroupstatistic/getgroupChatNumber').then(res=> {
if(res?.data) {
this.groupCard = res.data.群聊总和
this.groupData = res.data.条形统计
2022-12-22 16:37:06 +08:00
this.groupDate = this.groupData?.map(v=> v.dateDay)
if(this.groupCurrent == 0) {
this.groupMsg = this.groupData?.map(v=>v.chatHasMsg)
} else if(this.groupCurrent ==1) {
this.groupMsg = this.groupData?.map(v=>v.memberHasMsg)
} else if(this.groupCurrent == 2) {
this.groupMsg = this.groupData?.map(v=>v.msgTotal)
}
2022-12-22 15:31:49 +08:00
}
})
},
2022-12-21 10:25:39 +08:00
getEcharts1() {
let echarts1 = document.getElementById('echarts1');
let myChart = echarts.init(echarts1);
let option = {
tooltip: {
trigger: 'item',
},
title: {
zlevel: 0,
2022-12-22 17:18:34 +08:00
text: [`{name|昨日}\n{value|${ this.replyData?.replyPercentage || 0 } %}`],
2022-12-21 10:25:39 +08:00
top: 'center',
left: '46%',
textAlign: 'center',
textStyle: {
rich: {
name: {
color: '#999999',
fontSize: 13,
lineHeight: 15
},
value: {
color: '#333333',
fontSize: 13,
lineHeight: 16
}
},
},
},
2022-12-22 17:18:34 +08:00
color: ['#3975C6','#5d5c5c'],
2022-12-21 10:25:39 +08:00
series: [
{
name: '昨天',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
hoverAnimation: false,
labelLine: {
show: false,
},
data: [
2022-12-22 17:18:34 +08:00
{ value: this.replyData?.replyPercentage, name: '已回复聊天比' },
{ value: 100 - this.replyData?.replyPercentage, name: '未回复聊天比' },
2022-12-21 10:25:39 +08:00
]
}
]
};
option && myChart.setOption(option);
},
getEcharts2() {
let echarts2 = document.getElementById('echarts2');
let myChart = echarts.init(echarts2);
let option = {
tooltip: {
trigger: "item",
},
title: {
zlevel: 0,
2022-12-22 17:18:34 +08:00
text: [`{name|近7天}\n{value|${ this.replyData?.weekSum || 0 } %}`],
2022-12-21 10:25:39 +08:00
top: 'center',
left: '46%',
textAlign: 'center',
textStyle: {
rich: {
name: {
color: '#999999',
fontSize: 13,
lineHeight: 15
},
value: {
color: '#333333',
fontSize: 13,
lineHeight: 16
}
},
},
},
color: ['#3975C6','#F0F2F5'],
series: [
{
name: '近7天',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
hoverAnimation: false,
labelLine: {
show: false,
},
data: [
2022-12-22 17:18:34 +08:00
{ value: this.replyData?.weekSum, name: '近7天回复率' },
{ value: 100 - this.replyData?.weekSum, name: '女' },
2022-12-21 10:25:39 +08:00
]
}
]
};
option && myChart.setOption(option);
},
getEcharts3() {
let echarts3 = document.getElementById('echarts3');
let myChart = echarts.init(echarts3);
let option = {
tooltip: {
trigger: "item",
},
title: {
zlevel: 0,
2022-12-22 17:18:34 +08:00
text: [`{name|近30天}\n{value|${ this.replyData?.monthSum || 0 } %}`],
2022-12-21 10:25:39 +08:00
top: 'center',
left: '46%',
textAlign: 'center',
textStyle: {
rich: {
name: {
color: '#999999',
fontSize: 13,
lineHeight: 15
},
value: {
color: '#333333',
fontSize: 13,
lineHeight: 16
}
},
},
},
color: ['#3975C6','#F0F2F5'],
series: [
{
name: '近30天',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
hoverAnimation: false,
labelLine: {
show: false,
},
data: [
2022-12-22 17:18:34 +08:00
{ value: this.replyData?.monthSum, name: '近一个月回复率' },
{ value: 100 - this.replyData?.monthSum, name: '近一个月未回复率' },
2022-12-21 10:25:39 +08:00
]
}
]
};
option && myChart.setOption(option);
},
2022-12-20 10:44:51 +08:00
getPrivateChat() {
let privateDom = document.getElementById('privateChat');
let myChart = echarts.init(privateDom);
let option = {
tooltip: {
trigger: "axis",
},
xAxis: {
type: 'category',
2022-12-22 16:37:06 +08:00
data: this.privateDate,
2022-12-20 10:44:51 +08:00
axisTick: {
show: false,
}
},
yAxis: {
type: 'value',
axisLine: {
show: false,
},
axisTick: {
show: false,
}
},
series: [
{
2022-12-22 16:37:06 +08:00
data: this.privateMsg,
2022-12-20 10:44:51 +08:00
type: 'line',
lineStyle: {
color: '#3975C6', // 折线线条颜色
},
itemStyle: {
color: '#3975C6', // 折角颜色
},
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [ // 渐变颜色
{
offset: 0,
color: '#2891ff33',
},
{
offset: 1,
color: '#2891ff00',
},
],
global: false,
},
},
}
]
};
option && myChart.setOption(option);
},
getGroupChat() {
let groupDom = document.getElementById('groupChat');
let myChart = echarts.init(groupDom);
let option = {
tooltip: {
trigger: "axis",
},
xAxis: {
type: 'category',
2022-12-22 16:37:06 +08:00
data: this.groupDate,
2022-12-20 10:44:51 +08:00
axisTick: {
show: false,
}
},
yAxis: {
type: 'value',
axisLine: {
show: false,
},
axisTick: {
show: false,
}
},
series: [
{
2022-12-22 16:37:06 +08:00
data: this.groupMsg,
2022-12-20 10:44:51 +08:00
type: 'line',
lineStyle: {
color: '#3975C6', // 折线线条颜色
},
itemStyle: {
color: '#3975C6', // 折角颜色
},
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [ // 渐变颜色
{
offset: 0,
color: '#2891ff33',
},
{
offset: 1,
color: '#2891ff00',
},
],
global: false,
},
},
}
]
};
option && myChart.setOption(option);
}
},
2022-12-11 16:21:17 +08:00
}
</script>
<style lang="scss" scoped>
.message {
2022-12-20 10:44:51 +08:00
padding: 0 32px;
box-sizing: border-box;
.head {
margin-top: 32px;
span {
font-size: 32px;
color: #333333;
font-weight: 600;
2022-12-22 17:18:34 +08:00
color: #5d5c5c;
2022-12-20 10:44:51 +08:00
}
}
.card {
2022-12-22 16:37:06 +08:00
padding: 8px;
box-sizing: border-box;
2022-12-20 10:44:51 +08:00
display: flex;
text-align: center;
align-items: center;
background: #FFF;
2022-12-22 16:37:06 +08:00
border-radius: 16px 16px 0 0;
2022-12-20 10:44:51 +08:00
margin-top: 24px;
.item {
flex: 1;
2022-12-22 16:37:06 +08:00
padding: 16px 0;
2022-12-22 16:07:33 +08:00
box-sizing: border-box;
2022-12-20 10:44:51 +08:00
.item_name {
color: #666666;
}
.item_num {
color: #000000;
font-size: 36px;
font-weight: 600;
}
.imgs {
width: 30px;
height: 30px;
}
}
2022-12-22 16:07:33 +08:00
.active {
2022-12-22 16:37:06 +08:00
background: #EBF1F9;
2022-12-22 16:07:33 +08:00
border-radius: 16px;
}
2022-12-20 10:44:51 +08:00
}
2022-12-11 16:21:17 +08:00
2022-12-20 10:44:51 +08:00
.privateChat_box,
.groupChat_box {
width: 100%;
height: 514px;
background: #FFF;
#privateChat,
#groupChat {
width: 100%;
height: 100%;
}
}
2022-12-21 10:25:39 +08:00
.echarts_list {
width: 100%;
height: 256px;
background: #FFF;
border-radius: 8px;
margin-top: 24px;
display: flex;
#echarts1,
#echarts2,
#echarts3 {
flex: 1;
width: 100%;
height: 100%;
}
}
2022-12-11 16:21:17 +08:00
}
</style>