Commit 93a3fd11ad09b4cbaded5c205f5e994890bcf1a7

Authored by 郭伟龙
1 parent 26ea3e40
Exists in develop and in 1 other branch charge

feat:修改统计

api/total.js
1 1 const { http } = uni.$u
2 2  
3 3 // 本财年市场摸底分析
4   -export const getStatisticsReport = id => http.get('/insight/statistics/report/'+id)
  4 +export const getStatisticsReport = params => http.get('/insight/statistics/report',{params})
5 5  
6 6 // 待开发用户池数据分析
7 7 export const getStatisticsPool = params => http.get('/insight/statistics/pool',{params})
8   -// /statistics/pool
9 8  
10   -export const getStatisticsLogin = params => http.get('/insight/statistics/login',{params})
11 9 // 访问量和浏览量
12   -// /statistics/login
  10 +export const getStatisticsLogin = params => http.get('/insight/statistics/login',{params})
  11 +
  12 +// 主体账号查询近7天
  13 +export const getStatisticsChart = params => http.get('/insight/statistics/chart?entity='+params)
  14 +
  15 +// 区域和主体柱状图
  16 +export const getHistogram = params => http.get('/insight/statistics/getHistogram',{params})
13 17  
14 18  
... ...
pages/login/mobile.vue
... ... @@ -216,19 +216,24 @@
216 216 },
217 217 mobileLogin(data) {
218 218 // return
219   - this.rememberPassword()
  219 + console.log("登录信息",data);
220 220 this.$store.dispatch('Login', {
221 221 type: 0,
222 222 data: data
223 223 }).then(res => {
224 224 uni.$u.toast('登录成功');
225 225 //获取全部字典信息 保存至store
  226 + this.rememberPassword()
226 227 this.$store.dispatch('loadDictDatas')
227 228 setTimeout(() => {
228 229 uni.switchTab({
229 230 url: '/pages/market/index'
230 231 })
231 232 }, 300)
  233 + }).catch(error =>{
  234 + if(error.data.code === 500){
  235 + this.getCode();
  236 + }
232 237 })
233 238 }
234 239 }
... ...
pages/market/total.vue
... ... @@ -2,7 +2,7 @@
2 2 <view class="ComCss">
3 3 <!-- <u-navbar v-if="!$isDing" class="navBarCss" title="数据统计" leftIconSize="0"
4 4 :titleStyle="{'fontSize':'36rpx','color':'#333333','fontWeight':'700'}" safeAreaInsetTop placeholder /> -->
5   - <view class="bigCardCss">
  5 + <view class="bigCardCss" v-if="isZbOrQy">
6 6 <view class="titleCss">
7 7 本财年报告已上报数
8 8 </view>
... ... @@ -13,7 +13,7 @@
13 13 <view class="flexCss">
14 14 <view class="cardCss">
15 15 <view class="titleCss">
16   - 待开发居民用户
  16 + 待开发居民小区用户
17 17 </view>
18 18 <view class="numCss">
19 19 {{statistics.resident}}
... ... @@ -21,7 +21,7 @@
21 21 </view>
22 22 <view class="cardCss">
23 23 <view class="titleCss">
24   - 待开发商业用户
  24 + 待开发商业用户
25 25 </view>
26 26 <view class="numCss">
27 27 {{statistics.business}}
... ... @@ -29,14 +29,14 @@
29 29 </view>
30 30 <view class="cardCss">
31 31 <view class="titleCss">
32   - 待开发工业用户
  32 + 流失大客户总数
33 33 </view>
34 34 <view class="numCss">
35   - {{statistics.industry}}
  35 + {{statistics.customer}}
36 36 </view>
37 37 </view>
38 38 </view>
39   - <view class="charCardCss">
  39 + <view class="charCardCss" v-if="isZbOrQy">
40 40 <view class="charTitleCss">
41 41 本财年市场摸底分析
42 42 </view>
... ... @@ -52,14 +52,14 @@
52 52 <echarts class="pie-chart" :option="pieOption2" canvasId="pie2"></echarts>
53 53 </view>
54 54 </view>
55   - <!-- <view class="charCardCss">
  55 + <view class="charCardCss">
56 56 <view class="charTitleCss">
57   - 近4年待开发用户池数据情况
  57 + {{title}}
58 58 </view>
59 59 <view class="charbox">
60 60 <echarts class="line-chart" :option="lineOption" canvasId="line"></echarts>
61 61 </view>
62   - </view> -->
  62 + </view>
63 63 </view>
64 64 </template>
65 65  
... ... @@ -67,7 +67,9 @@
67 67 import {
68 68 getStatisticsReport,
69 69 getStatisticsPool,
70   - getStatisticsLogin
  70 + getStatisticsLogin,
  71 + getStatisticsChart,
  72 + getHistogram
71 73 } from '@/api/total.js'
72 74 export default {
73 75 components: {},
... ... @@ -81,20 +83,44 @@
81 83 lineOption: {},
82 84 fiscalYear: "",
83 85 statistics: {
84   - totalNum: "",
85 86 resident: "",
  87 + totalNum: "",
  88 + residentDeveloping: "",
  89 + residentUndeveloped: "",
86 90 business: "",
87   - industry: ""
  91 + customer: ""
88 92 },
  93 + title: "",
  94 + reportCharData: null,
  95 + reportCharBarData: null,
89 96 data1: [],
90 97 data2: [],
91 98 data3: [],
92 99 total1: 0,
93 100 total2: 0,
  101 + roleTypes: "",
  102 + isZbOrQy: false,
  103 + roleId: this.$store.state.user.roleId,
  104 + entity: this.$store.state.user.entity,
94 105 }
95 106 },
96 107 mounted() {
97   -
  108 + if (this.roleId.includes('103')) {
  109 + this.roleTypes = '103';
  110 + this.isZbOrQy = true
  111 + this.title = '各区域中心待开发用户池数据情况'
  112 + console.log("总部账号", this.roleTypes);
  113 + } else if (this.roleId.includes('105')) {
  114 + this.isZbOrQy = true
  115 + this.roleTypes = '105';
  116 + this.title = '待开发用户池总数量排名前8的预算主体数据情况'
  117 + console.log("区域账号", this.roleTypes);
  118 + } else {
  119 + this.isZbOrQy = false
  120 + this.roleTypes = '104';
  121 + this.title = '近七天待开发用户池数据情况'
  122 + console.log("主体账号", this.roleTypes);
  123 + }
98 124 },
99 125 computed: {
100 126  
... ... @@ -103,13 +129,58 @@
103 129 this.initData()
104 130 },
105 131 methods: {
106   - async initData() {
107   - this.fiscalYear = this.$u.timeFormat("", 'yyyy');
108   - await getStatisticsReport(this.fiscalYear).then(res => {
  132 + async getHistogram(query) {
  133 + const result = await getHistogram(query);
  134 + if (this.roleTypes === '105') {
  135 + this.reportCharBarData = this.findTopEightMaxSums(result.data);
  136 + } else if (this.roleTypes === '103') {
  137 + this.reportCharBarData = result.data;
  138 + }
  139 + console.log("柱状图数据", this.reportCharBarData);
  140 + },
  141 + async getSevenDayData() {
  142 + const result = await getStatisticsChart(this.entity);
  143 + this.reportCharData = result.data;
  144 + console.log("近7天结果", this.reportCharData);
  145 + },
  146 + //取最大的八个值
  147 + findTopEightMaxSums(data) {
  148 + let sums = [];
  149 + // 循环遍历 data 数组
  150 + for (let obj of data) {
  151 + let sum =
  152 + obj.list.reduce((acc, curr) => {
  153 + return (
  154 + acc +
  155 + curr.commerceAndIndustry +
  156 + curr.customerRecoveryProgress +
  157 + curr.resident
  158 + );
  159 + }, 0);
  160 +
  161 + sums.push(sum);
  162 + }
  163 +
  164 + // 取前八个和最大的索引
  165 + let maxSumIndices = [];
  166 + for (let i = 0; i < 8; i++) {
  167 + let maxIndex = sums.indexOf(Math.max(...sums));
  168 + if (maxIndex !== -1) {
  169 + maxSumIndices.push(maxIndex);
  170 + sums[maxIndex] = -Infinity;
  171 + }
  172 + }
  173 + // 获取前八个对象
  174 + let topEightObjects = maxSumIndices.map((index) => data[index]);
  175 + return topEightObjects;
  176 + },
  177 + async getStatisticsReport(data) {
  178 + let that = this;
  179 + await getStatisticsReport(data).then(res => {
109 180 if (res.code === 200) {
110 181 let data = res.data;
111   - this.statistics.totalNum = data.pass + data.revise;
112   - this.data1 = [{
  182 + that.statistics.totalNum = parseInt(data.pass) + parseInt(data.review);
  183 + that.data1 = [{
113 184 value: data.submit,
114 185 name: '待申报'
115 186 },
... ... @@ -130,40 +201,111 @@
130 201 name: '未创建'
131 202 },
132 203 ]
133   - this.total1 = data.total
134   - console.log("报告", this.data1);
  204 + that.total1 = data.total
  205 + console.log("报告", that.data1);
135 206 }
136 207 })
137   - let query = {
138   - roleIds: uni.getStorageSync('roleId') || null,
139   - entity: uni.getStorageSync("entity") || null,
140   - }
  208 + },
  209 + async getStatisticsPool(query) {
  210 + let that = this;
141 211 await getStatisticsPool(query).then(res => {
142 212 if (res.code === 200) {
143 213 let data = res.data;
144   - this.statistics.resident = data.resident;
145   - this.statistics.business = data.commerce;
146   - this.statistics.industry = data.industry;
147   - this.data2 = [{
148   - value: data.resident,
149   - name: '待开发居民用户数'
  214 + that.statistics.resident = parseInt(data.residentDeveloping) + parseInt(data.residentUndeveloped);
  215 + that.statistics.residentDeveloping = data.residentDeveloping;
  216 + that.statistics.residentUndeveloped = data.residentUndeveloped;
  217 + that.statistics.business = data.commerceAndIndustry;
  218 + that.statistics.customer = data.customerRecoveryProgress;
  219 + that.data2 = [{
  220 + value: data.residentDeveloping,
  221 + name: '居民_开发中小区总数'
  222 + },
  223 + {
  224 + value: data.residentUndeveloped,
  225 + name: '居民_未开发中小区总数'
150 226 },
151 227 {
152   - value: data.commerce,
  228 + value: data.commerceAndIndustry,
153 229 name: '待开发商业用户数'
154 230 },
155 231 {
156   - value: data.industry,
  232 + value: data.customer,
157 233 name: '待开发工业用户数'
158 234 },
159 235 ]
160   - this.total2 = data.total
  236 + that.total2 = data.total
161 237 }
162 238 })
  239 + },
  240 + async initData() {
  241 + let query = {
  242 + roleIds: this.roleId || null,
  243 + entity: this.entity || null,
  244 + }
  245 + this.fiscalYear = this.$u.timeFormat("", 'yyyy');
  246 + let data = {
  247 + ...query,
  248 + 'fiscalYear': this.fiscalYear
  249 + }
  250 + await this.getStatisticsReport(data);
  251 + await this.getStatisticsPool(query);
  252 + if (this.roleTypes === '104') {
  253 + await this.getSevenDayData();
  254 + } else {
  255 + await this.getHistogram(query)
  256 + }
  257 + if (this.isZbOrQy && this.reportCharBarData.length) {
  258 + this.reportCharBarData.map(item => {
  259 + this.data3.push({
  260 + time: item.entityName,
  261 + residentUserValue: item.list[0]?.resident || 0,
  262 + businessUserValue: item.list[0]?.commerceAndIndustry || 0,
  263 + customerUserValue: item.list[0]?.customerRecoveryProgress || 0
  264 + })
  265 + })
  266 + console.log("区域或总部内容", this.data3);
  267 + }
  268 + if (!this.isZbOrQy && this.reportCharData) {
  269 + let {
  270 + residentLedger,
  271 + poolIndustryAndCommerce,
  272 + customerRecoveryProgress
  273 + } = this.reportCharData;
  274 + for (let i = 0; i <= 6; i++) {
  275 + let time = (residentLedger[i]?.days) || (poolIndustryAndCommerce[i]?.days) || (customerRecoveryProgress[i]
  276 + ?.days) || '';
  277 + this.data3.push({
  278 + time: time,
  279 + residentUserValue: residentLedger[i]?.count || 0,
  280 + businessUserValue: poolIndustryAndCommerce[i]?.count || 0,
  281 + customerUserValue: customerRecoveryProgress[i]?.count || 0
  282 + })
  283 + }
  284 + console.log("近七天待开发用户池数据情况", this.data3);
  285 + }
163 286 this.refreshData()
164 287 },
165 288 refreshData() {
166 289 let that = this;
  290 + const series = [{
  291 + name: '居民用户',
  292 + type: this.isZbOrQy ? 'bar' : 'line',
  293 + color: '#15c2c3',
  294 + data: this.data3.map(item => item.residentUserValue),
  295 + },
  296 + {
  297 + name: '工商业用户',
  298 + type: this.isZbOrQy ? 'bar' : 'line',
  299 + color: '#3436c7',
  300 + data: this.data3.map(item => item.businessUserValue),
  301 + },
  302 + {
  303 + name: '流失大客户',
  304 + type: this.isZbOrQy ? 'bar' : 'line',
  305 + color: '#f04864',
  306 + data: this.data3.map(item => item.customerUserValue),
  307 + }
  308 + ]
167 309 this.pieOption = {
168 310 tooltip: {
169 311 trigger: 'item'
... ... @@ -181,7 +323,7 @@
181 323 series: [{
182 324 name: '摸底分析',
183 325 type: 'pie',
184   - right: 100,
  326 + right: 150,
185 327 radius: ['65%', '80%'],
186 328 avoidLabelOverlap: false,
187 329 label: {
... ... @@ -224,7 +366,7 @@
224 366 legend: {
225 367 orient: 'vertical',
226 368 y: 'center',
227   - right: 10,
  369 + right: 0,
228 370 itemWidth: 8,
229 371 itemGap: 14,
230 372 icon: 'circle',
... ... @@ -235,7 +377,7 @@
235 377 series: [{
236 378 name: '待开发用户池数据分析',
237 379 type: 'pie',
238   - right: 100,
  380 + right: 150,
239 381 radius: ['65%', '80%'],
240 382 avoidLabelOverlap: false,
241 383 label: {
... ... @@ -272,9 +414,6 @@
272 414 }]
273 415 };
274 416 this.lineOption = {
275   - // title: {
276   - // text: 'Stacked Line'
277   - // },
278 417 tooltip: {
279 418 trigger: 'axis'
280 419 },
... ... @@ -285,7 +424,7 @@
285 424 itemWidth: 10,
286 425 itemHeight: 2,
287 426 itemGap: 20,
288   - data: ['民居用户', '商业用户', '工业用户']
  427 + data: series.map(item => item.name)
289 428 },
290 429 grid: {
291 430 left: '3%',
... ... @@ -293,41 +432,70 @@
293 432 bottom: '3%',
294 433 containLabel: true
295 434 },
  435 + // dataZoom: [{
  436 + // type: "slider", // 滑动条型数据区域缩放组件
  437 + // show: true, // 是否显示组件(用于 x 轴使用)
  438 + // start: 70, // 数据窗口范围的起始百分比(范围是:0 ~ 100。表示 0% ~ 100%)
  439 + // end: 100, // 数据窗口范围的结束百分比(范围是:0 ~ 100。表示 0% ~ 100%)
  440 + // height: 30, // 组件的高度(水平布局默认 30,竖直布局默认自适应)
  441 + // handleSize: '30%', // 控制手柄的尺寸,可以是像素大小,也可以是相对于 dataZoom 组件宽度的百分比,默认跟 dataZoom 宽度相同
  442 + // handleStyle: {
  443 + // // color: '#fff', // 图形的颜色
  444 + // // borderColor: 'red', // 图形的描边颜色
  445 + // // borderWidth: 1, // 描边线宽。为 0 时无描边
  446 + // borderType: 'solid' // 描边类型 solid.实线(默认) dashed.虚线 dotted.点虚线
  447 + // }, // 两侧缩放手柄的样式配置
  448 + // showDataShadow: false, // 是否在 dataZoom-silder 组件中显示数据阴影。数据阴影可以简单地反应数据走势
  449 + // }, {
  450 + // type: "inside", // 内置型数据区域缩放组件(即在坐标系内平移与缩放)
  451 + // start: 70, // 数据窗口范围的起始百分比(范围是:0 ~ 100。表示 0% ~ 100%)
  452 + // end: 100 // 数据窗口范围的结束百分比(范围是:0 ~ 100。表示 0% ~ 100%)
  453 + // }, {
  454 + // type: "slider", // 滑动条型数据区域缩放组件
  455 + // show: false, // 是否显示组件(用于 y 轴使用)
  456 + // width: "5%", // 组件的宽度(竖直布局默认 30,水平布局默认自适应)
  457 + // height: "70%", // 组件的高度(水平布局默认 30,竖直布局默认自适应)
  458 + // yAxisIndex: 0, // 组件控制的 y 轴(即下方 yAxis 数组的索引值)
  459 + // filterMode: "empty", // none.不过滤数据只改变数轴范围 empty.当前数据窗口外的数据设置为空,不影响其他轴的数据范围 其他访问https://echarts.apache.org/zh/option.html#dataZoom-slider.filterMode
  460 + // handleSize: '30%', // 控制手柄的尺寸,可以是像素大小,也可以是相对于 dataZoom 组件宽度的百分比,默认跟 dataZoom 宽度相同
  461 + // handleStyle: {
  462 + // // color: '#fff', // 图形的颜色
  463 + // // borderColor: 'red', // 图形的描边颜色
  464 + // // borderWidth: 1, // 描边线宽。为 0 时无描边
  465 + // borderType: 'solid' // 描边类型 solid.实线(默认) dashed.虚线 dotted.点虚线
  466 + // }, // 两侧缩放手柄的样式配置
  467 + // showDataShadow: false, // 是否在 dataZoom-silder 组件中显示数据阴影。数据阴影可以简单地反应数据走势
  468 + // left: "93%" // 组件离容器左侧的距离
  469 + // }], // 区域缩放
296 470 toolbox: {
297 471 feature: {
298 472 saveAsImage: {}
299 473 }
300 474 },
301 475 xAxis: {
  476 + show: true,
302 477 type: 'category',
303 478 boundaryGap: true,
304   - data: ['2020财年', '2021财年', '2021财年', '2023财年']
  479 + data: this.data3.map(item => item.time),
  480 + axisLabel: {
  481 + fontSize: 14,
  482 + color: '#666666',
  483 + formatter: function(value) {
  484 + if (that.isZbOrQy) {
  485 + if (value.length > 3) {
  486 + return `${value.slice(0, 2)}...`
  487 + }
  488 + }
  489 + return value
  490 + },
  491 + },
305 492 },
306 493 yAxis: {
307 494 type: 'value'
308 495 },
309   - series: [{
310   - name: '民居用户',
311   - type: 'line',
312   - stack: 'Total',
313   - data: [120, 132, 101, 134, 90, 230, 210]
314   - },
315   - {
316   - name: '商业用户',
317   - type: 'line',
318   - stack: 'Total',
319   - data: [220, 182, 191, 234, 290, 330, 310]
320   - },
321   - {
322   - name: '工业用户',
323   - type: 'line',
324   - stack: 'Total',
325   - data: [150, 232, 201, 154, 190, 330, 410]
326   - },
327   - ]
  496 + series: series
328 497 }
329 498 }
330   -
331 499 }
332 500 }
333 501 </script>
... ... @@ -348,6 +516,9 @@
348 516 }
349 517  
350 518 .cardCss {
  519 + display: flex;
  520 + flex-direction: column;
  521 + justify-content: space-between;
351 522 width: 220rpx;
352 523 margin: 20rpx 0rpx;
353 524 padding: 40rpx 25rpx;
... ...
sitemap.json
... ... @@ -1,7 +0,0 @@
1   -{
2   - "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3   - "rules": [{
4   - "action": "allow",
5   - "page": "*"
6   - }]
7   -}
8 0 \ No newline at end of file
store/mudules/user.js
... ... @@ -151,4 +151,4 @@ const user = {
151 151 }
152 152 }
153 153 }
154   -export default user
155 154 \ No newline at end of file
  155 +export default user
... ...