diff --git a/api/total.js b/api/total.js index b89ccaa..59d6395 100644 --- a/api/total.js +++ b/api/total.js @@ -1,14 +1,18 @@ const { http } = uni.$u // 本财年市场摸底分析 -export const getStatisticsReport = id => http.get('/insight/statistics/report/'+id) +export const getStatisticsReport = params => http.get('/insight/statistics/report',{params}) // 待开发用户池数据分析 export const getStatisticsPool = params => http.get('/insight/statistics/pool',{params}) -// /statistics/pool -export const getStatisticsLogin = params => http.get('/insight/statistics/login',{params}) // 访问量和浏览量 -// /statistics/login +export const getStatisticsLogin = params => http.get('/insight/statistics/login',{params}) + +// 主体账号查询近7天 +export const getStatisticsChart = params => http.get('/insight/statistics/chart?entity='+params) + +// 区域和主体柱状图 +export const getHistogram = params => http.get('/insight/statistics/getHistogram',{params}) diff --git a/pages/login/mobile.vue b/pages/login/mobile.vue index bbf9f66..8b82cfe 100644 --- a/pages/login/mobile.vue +++ b/pages/login/mobile.vue @@ -216,19 +216,24 @@ }, mobileLogin(data) { // return - this.rememberPassword() + console.log("登录信息",data); this.$store.dispatch('Login', { type: 0, data: data }).then(res => { uni.$u.toast('登录成功'); //获取全部字典信息 保存至store + this.rememberPassword() this.$store.dispatch('loadDictDatas') setTimeout(() => { uni.switchTab({ url: '/pages/market/index' }) }, 300) + }).catch(error =>{ + if(error.data.code === 500){ + this.getCode(); + } }) } } diff --git a/pages/market/total.vue b/pages/market/total.vue index a5bd680..ca39ec7 100644 --- a/pages/market/total.vue +++ b/pages/market/total.vue @@ -2,7 +2,7 @@ - + 本财年报告已上报数 @@ -13,7 +13,7 @@ - 待开发居民用户 + 待开发居民小区用户 {{statistics.resident}} @@ -21,7 +21,7 @@ - 待开发商业用户 + 待开发工商业用户 {{statistics.business}} @@ -29,14 +29,14 @@ - 待开发工业用户 + 流失大客户总数 - {{statistics.industry}} + {{statistics.customer}} - + 本财年市场摸底分析 @@ -52,14 +52,14 @@ - + @@ -67,7 +67,9 @@ import { getStatisticsReport, getStatisticsPool, - getStatisticsLogin + getStatisticsLogin, + getStatisticsChart, + getHistogram } from '@/api/total.js' export default { components: {}, @@ -81,20 +83,44 @@ lineOption: {}, fiscalYear: "", statistics: { - totalNum: "", resident: "", + totalNum: "", + residentDeveloping: "", + residentUndeveloped: "", business: "", - industry: "" + customer: "" }, + title: "", + reportCharData: null, + reportCharBarData: null, data1: [], data2: [], data3: [], total1: 0, total2: 0, + roleTypes: "", + isZbOrQy: false, + roleId: this.$store.state.user.roleId, + entity: this.$store.state.user.entity, } }, mounted() { - + if (this.roleId.includes('103')) { + this.roleTypes = '103'; + this.isZbOrQy = true + this.title = '各区域中心待开发用户池数据情况' + console.log("总部账号", this.roleTypes); + } else if (this.roleId.includes('105')) { + this.isZbOrQy = true + this.roleTypes = '105'; + this.title = '待开发用户池总数量排名前8的预算主体数据情况' + console.log("区域账号", this.roleTypes); + } else { + this.isZbOrQy = false + this.roleTypes = '104'; + this.title = '近七天待开发用户池数据情况' + console.log("主体账号", this.roleTypes); + } }, computed: { @@ -103,13 +129,58 @@ this.initData() }, methods: { - async initData() { - this.fiscalYear = this.$u.timeFormat("", 'yyyy'); - await getStatisticsReport(this.fiscalYear).then(res => { + async getHistogram(query) { + const result = await getHistogram(query); + if (this.roleTypes === '105') { + this.reportCharBarData = this.findTopEightMaxSums(result.data); + } else if (this.roleTypes === '103') { + this.reportCharBarData = result.data; + } + console.log("柱状图数据", this.reportCharBarData); + }, + async getSevenDayData() { + const result = await getStatisticsChart(this.entity); + this.reportCharData = result.data; + console.log("近7天结果", this.reportCharData); + }, + //取最大的八个值 + findTopEightMaxSums(data) { + let sums = []; + // 循环遍历 data 数组 + for (let obj of data) { + let sum = + obj.list.reduce((acc, curr) => { + return ( + acc + + curr.commerceAndIndustry + + curr.customerRecoveryProgress + + curr.resident + ); + }, 0); + + sums.push(sum); + } + + // 取前八个和最大的索引 + let maxSumIndices = []; + for (let i = 0; i < 8; i++) { + let maxIndex = sums.indexOf(Math.max(...sums)); + if (maxIndex !== -1) { + maxSumIndices.push(maxIndex); + sums[maxIndex] = -Infinity; + } + } + // 获取前八个对象 + let topEightObjects = maxSumIndices.map((index) => data[index]); + return topEightObjects; + }, + async getStatisticsReport(data) { + let that = this; + await getStatisticsReport(data).then(res => { if (res.code === 200) { let data = res.data; - this.statistics.totalNum = data.pass + data.revise; - this.data1 = [{ + that.statistics.totalNum = parseInt(data.pass) + parseInt(data.review); + that.data1 = [{ value: data.submit, name: '待申报' }, @@ -130,40 +201,111 @@ name: '未创建' }, ] - this.total1 = data.total - console.log("报告", this.data1); + that.total1 = data.total + console.log("报告", that.data1); } }) - let query = { - roleIds: uni.getStorageSync('roleId') || null, - entity: uni.getStorageSync("entity") || null, - } + }, + async getStatisticsPool(query) { + let that = this; await getStatisticsPool(query).then(res => { if (res.code === 200) { let data = res.data; - this.statistics.resident = data.resident; - this.statistics.business = data.commerce; - this.statistics.industry = data.industry; - this.data2 = [{ - value: data.resident, - name: '待开发居民用户数' + that.statistics.resident = parseInt(data.residentDeveloping) + parseInt(data.residentUndeveloped); + that.statistics.residentDeveloping = data.residentDeveloping; + that.statistics.residentUndeveloped = data.residentUndeveloped; + that.statistics.business = data.commerceAndIndustry; + that.statistics.customer = data.customerRecoveryProgress; + that.data2 = [{ + value: data.residentDeveloping, + name: '居民_开发中小区总数' + }, + { + value: data.residentUndeveloped, + name: '居民_未开发中小区总数' }, { - value: data.commerce, + value: data.commerceAndIndustry, name: '待开发商业用户数' }, { - value: data.industry, + value: data.customer, name: '待开发工业用户数' }, ] - this.total2 = data.total + that.total2 = data.total } }) + }, + async initData() { + let query = { + roleIds: this.roleId || null, + entity: this.entity || null, + } + this.fiscalYear = this.$u.timeFormat("", 'yyyy'); + let data = { + ...query, + 'fiscalYear': this.fiscalYear + } + await this.getStatisticsReport(data); + await this.getStatisticsPool(query); + if (this.roleTypes === '104') { + await this.getSevenDayData(); + } else { + await this.getHistogram(query) + } + if (this.isZbOrQy && this.reportCharBarData.length) { + this.reportCharBarData.map(item => { + this.data3.push({ + time: item.entityName, + residentUserValue: item.list[0]?.resident || 0, + businessUserValue: item.list[0]?.commerceAndIndustry || 0, + customerUserValue: item.list[0]?.customerRecoveryProgress || 0 + }) + }) + console.log("区域或总部内容", this.data3); + } + if (!this.isZbOrQy && this.reportCharData) { + let { + residentLedger, + poolIndustryAndCommerce, + customerRecoveryProgress + } = this.reportCharData; + for (let i = 0; i <= 6; i++) { + let time = (residentLedger[i]?.days) || (poolIndustryAndCommerce[i]?.days) || (customerRecoveryProgress[i] + ?.days) || ''; + this.data3.push({ + time: time, + residentUserValue: residentLedger[i]?.count || 0, + businessUserValue: poolIndustryAndCommerce[i]?.count || 0, + customerUserValue: customerRecoveryProgress[i]?.count || 0 + }) + } + console.log("近七天待开发用户池数据情况", this.data3); + } this.refreshData() }, refreshData() { let that = this; + const series = [{ + name: '居民用户', + type: this.isZbOrQy ? 'bar' : 'line', + color: '#15c2c3', + data: this.data3.map(item => item.residentUserValue), + }, + { + name: '工商业用户', + type: this.isZbOrQy ? 'bar' : 'line', + color: '#3436c7', + data: this.data3.map(item => item.businessUserValue), + }, + { + name: '流失大客户', + type: this.isZbOrQy ? 'bar' : 'line', + color: '#f04864', + data: this.data3.map(item => item.customerUserValue), + } + ] this.pieOption = { tooltip: { trigger: 'item' @@ -181,7 +323,7 @@ series: [{ name: '摸底分析', type: 'pie', - right: 100, + right: 150, radius: ['65%', '80%'], avoidLabelOverlap: false, label: { @@ -224,7 +366,7 @@ legend: { orient: 'vertical', y: 'center', - right: 10, + right: 0, itemWidth: 8, itemGap: 14, icon: 'circle', @@ -235,7 +377,7 @@ series: [{ name: '待开发用户池数据分析', type: 'pie', - right: 100, + right: 150, radius: ['65%', '80%'], avoidLabelOverlap: false, label: { @@ -272,9 +414,6 @@ }] }; this.lineOption = { - // title: { - // text: 'Stacked Line' - // }, tooltip: { trigger: 'axis' }, @@ -285,7 +424,7 @@ itemWidth: 10, itemHeight: 2, itemGap: 20, - data: ['民居用户', '商业用户', '工业用户'] + data: series.map(item => item.name) }, grid: { left: '3%', @@ -293,41 +432,70 @@ bottom: '3%', containLabel: true }, + // dataZoom: [{ + // type: "slider", // 滑动条型数据区域缩放组件 + // show: true, // 是否显示组件(用于 x 轴使用) + // start: 70, // 数据窗口范围的起始百分比(范围是:0 ~ 100。表示 0% ~ 100%) + // end: 100, // 数据窗口范围的结束百分比(范围是:0 ~ 100。表示 0% ~ 100%) + // height: 30, // 组件的高度(水平布局默认 30,竖直布局默认自适应) + // handleSize: '30%', // 控制手柄的尺寸,可以是像素大小,也可以是相对于 dataZoom 组件宽度的百分比,默认跟 dataZoom 宽度相同 + // handleStyle: { + // // color: '#fff', // 图形的颜色 + // // borderColor: 'red', // 图形的描边颜色 + // // borderWidth: 1, // 描边线宽。为 0 时无描边 + // borderType: 'solid' // 描边类型 solid.实线(默认) dashed.虚线 dotted.点虚线 + // }, // 两侧缩放手柄的样式配置 + // showDataShadow: false, // 是否在 dataZoom-silder 组件中显示数据阴影。数据阴影可以简单地反应数据走势 + // }, { + // type: "inside", // 内置型数据区域缩放组件(即在坐标系内平移与缩放) + // start: 70, // 数据窗口范围的起始百分比(范围是:0 ~ 100。表示 0% ~ 100%) + // end: 100 // 数据窗口范围的结束百分比(范围是:0 ~ 100。表示 0% ~ 100%) + // }, { + // type: "slider", // 滑动条型数据区域缩放组件 + // show: false, // 是否显示组件(用于 y 轴使用) + // width: "5%", // 组件的宽度(竖直布局默认 30,水平布局默认自适应) + // height: "70%", // 组件的高度(水平布局默认 30,竖直布局默认自适应) + // yAxisIndex: 0, // 组件控制的 y 轴(即下方 yAxis 数组的索引值) + // filterMode: "empty", // none.不过滤数据只改变数轴范围 empty.当前数据窗口外的数据设置为空,不影响其他轴的数据范围 其他访问https://echarts.apache.org/zh/option.html#dataZoom-slider.filterMode + // handleSize: '30%', // 控制手柄的尺寸,可以是像素大小,也可以是相对于 dataZoom 组件宽度的百分比,默认跟 dataZoom 宽度相同 + // handleStyle: { + // // color: '#fff', // 图形的颜色 + // // borderColor: 'red', // 图形的描边颜色 + // // borderWidth: 1, // 描边线宽。为 0 时无描边 + // borderType: 'solid' // 描边类型 solid.实线(默认) dashed.虚线 dotted.点虚线 + // }, // 两侧缩放手柄的样式配置 + // showDataShadow: false, // 是否在 dataZoom-silder 组件中显示数据阴影。数据阴影可以简单地反应数据走势 + // left: "93%" // 组件离容器左侧的距离 + // }], // 区域缩放 toolbox: { feature: { saveAsImage: {} } }, xAxis: { + show: true, type: 'category', boundaryGap: true, - data: ['2020财年', '2021财年', '2021财年', '2023财年'] + data: this.data3.map(item => item.time), + axisLabel: { + fontSize: 14, + color: '#666666', + formatter: function(value) { + if (that.isZbOrQy) { + if (value.length > 3) { + return `${value.slice(0, 2)}...` + } + } + return value + }, + }, }, yAxis: { type: 'value' }, - series: [{ - name: '民居用户', - type: 'line', - stack: 'Total', - data: [120, 132, 101, 134, 90, 230, 210] - }, - { - name: '商业用户', - type: 'line', - stack: 'Total', - data: [220, 182, 191, 234, 290, 330, 310] - }, - { - name: '工业用户', - type: 'line', - stack: 'Total', - data: [150, 232, 201, 154, 190, 330, 410] - }, - ] + series: series } } - } } @@ -348,6 +516,9 @@ } .cardCss { + display: flex; + flex-direction: column; + justify-content: space-between; width: 220rpx; margin: 20rpx 0rpx; padding: 40rpx 25rpx; diff --git a/sitemap.json b/sitemap.json deleted file mode 100644 index ca02add..0000000 --- a/sitemap.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", - "rules": [{ - "action": "allow", - "page": "*" - }] -} \ No newline at end of file diff --git a/store/mudules/user.js b/store/mudules/user.js index 9dec450..b2ad474 100644 --- a/store/mudules/user.js +++ b/store/mudules/user.js @@ -151,4 +151,4 @@ const user = { } } } -export default user \ No newline at end of file +export default user -- libgit2 0.21.2