Browse Source

用户分析部分接口联调完成

htc 23 hours ago
parent
commit
b21314a1d1
2 changed files with 41 additions and 25 deletions
  1. 14 0
      src/api/agent/indexTwo.js
  2. 27 25
      src/views/modules/statistics/userProfiling.vue

+ 14 - 0
src/api/agent/indexTwo.js

@@ -32,6 +32,20 @@ export function getOrderMoney(query) {
 // ---end 订单统计
 
 // ---start 用户分析
+export function getRegisterChannelStats(query) {
+  return request({
+    url: `/core/user/registerChannelStats`,
+    method: 'get',
+    params: query
+  })
+}
+export function getIndustryScattergram(query) {
+  return request({
+    url: `/core/user/industryScattergram`,
+    method: 'get',
+    params: query
+  })
+}
 // ---end 用户分析
 
 // ---start 小程序用户管理

+ 27 - 25
src/views/modules/statistics/userProfiling.vue

@@ -125,6 +125,10 @@
 
 <script setup name="">
     import * as echarts from "echarts";
+    import {
+        getRegisterChannelStats,
+        getIndustryScattergram
+    } from '@/api/agent/indexTwo.js'
     import { ref, getCurrentInstance, onMounted } from 'vue'
     const { proxy } = getCurrentInstance();
     
@@ -148,6 +152,18 @@
         didx.value = ''
     }
 
+    const getRegisterChannelStatsFn = () => {
+        let colors = ['#009191','#35CBCA','#7CC5C5','#FBD438']
+        getRegisterChannelStats().then(res => {
+            yhzcqdTypeList.value = res.data.map((item,index) => {
+                return { color:colors[index],name:item.channelName,num:item.registerCount??0 }
+            })
+            let data = yhzcqdTypeList.value.map(d=>({name:d.name,value:d.num}))
+            let sum = data.reduce((total,item)=>{return total+item.value},0)
+            initYhzcqdData(colors,data,sum)
+        })
+    }
+
     const initYhglEchart = () => {
         const chart = echarts.init(yhglRef.value)
         let option = {
@@ -208,20 +224,14 @@
     }
 
     const initHyfbData = () => {
-        hyfbData.value = [
-            {name:'IT/互联网',num:3623},
-            {name:'金融语专业服务',num:2311},
-            {name:'制造与工业',num:1523},
-            {name:'医疗保健与生命科学',num:965},
-            {name:'消费品与零售',num:623},
-            {name:'文化、媒体与教育',num:311},
-            {name:'能源、资源与公共事业',num:223},
-            {name:'政府与非营利组织',num:123},
-            {name:'其他',num:111}
-        ]
-        let sum = hyfbData.value.reduce((total,item)=>{return total+item.num},0)
-        hyfbData.value.forEach(item=>{
-            item.bl = (item.num/sum*100).toFixed(2)
+        getIndustryScattergram().then(res => {
+            hyfbData.value = res.data.map(item => {
+                return {name:item.industryName,num:item.industryCount}
+            })
+            let sum = hyfbData.value.reduce((total,item)=>{return total+item.num},0)
+            hyfbData.value.forEach(item=>{
+                item.bl = (item.num/sum*100).toFixed(2)
+            })
         })
     }
 
@@ -297,18 +307,10 @@
         })
     }
 
-    const initYhzcqdData = () => {
-        yhzcqdTypeList.value = [
-            {color:'#009191',name:'创衡运营邀请渠道',num:8928},
-            {color:'#35CBCA',name:'用户搜索注册',num:10233},
-            {color:'#7CC5C5',name:'用户推荐转发',num:7344},
-            {color:'#FBD438',name:'团队教练转发问卷任务',num:10987}
-        ]
-        let data = yhzcqdTypeList.value.map(d=>({name:d.name,value:d.num}))
-        let sum = data.reduce((total,item)=>{return total+item.value},0)
+    const initYhzcqdData = (color,data,sum) => {
         const chart = echarts.init(yhzcqdRef.value)
         let option = {
-            color: ['#009191','#35CBCA','#7CC5C5','#FBD438'],
+            color,
             grid: {
                 left: 20,
                 right: 20,
@@ -384,9 +386,9 @@
     }
 
     onMounted(()=>{
+        getRegisterChannelStatsFn()
         initYhglEchart()
         initHyfbData()
-        initYhzcqdData()
         initYhhxEchart()
         initNlfbEcharts()
         proxy.$nextTick(()=>{