From 706cf3a087b631321f955d401fec899f95250ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=8F=B6?= Date: Fri, 12 Aug 2022 17:19:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commons/js/config.js | 2 + commons/js/utils/apiQuery.js | 14 + pages/storeData/customerData/index.js | 260 ++++++++++++++++-- pages/storeData/customerData/index.json | 1 - pages/storeData/customerData/index.wxml | 10 +- pages/storeData/index.js | 129 ++++++++- pages/storeData/index.wxml | 14 +- pages/storeData/orderData/index.js | 333 +++++++++++++++++++++--- pages/storeData/orderData/index.wxml | 10 +- pages/storeData/wechatData/index.js | 167 ++++++++++-- pages/storeData/wechatData/index.json | 1 - pages/storeData/wechatData/index.wxml | 8 +- 12 files changed, 836 insertions(+), 113 deletions(-) diff --git a/commons/js/config.js b/commons/js/config.js index a74bc94..5664437 100644 --- a/commons/js/config.js +++ b/commons/js/config.js @@ -154,6 +154,8 @@ api = { appBizStats:'app/biz/stats', //门店数据首页 appBizStats_customer:'app/biz/stats_customer', //客户数据 appBizStats_wxqy:'app/biz/stats_wxqy', //企微数据 + appBizStats_order:'app/biz/stats_order', //订单数据 + appBizStats_days:'app/biz/stats_days', //客户/订单走势图 diff --git a/commons/js/utils/apiQuery.js b/commons/js/utils/apiQuery.js index 80b955c..cda2c28 100644 --- a/commons/js/utils/apiQuery.js +++ b/commons/js/utils/apiQuery.js @@ -917,4 +917,18 @@ apiQuery.getAppBizStats_wxqy = function (params) { }) } +//订单数据 +apiQuery.getAppBizStats_order = function (params) { + return new Promise(function (resolve, reject) { + HttpRequest(false, Config.api.appBizStats_order, 2, params, "GET", resolve, reject) + }) +} + +//客户/订单走势图 +apiQuery.getAppBizStats_days = function (params) { + return new Promise(function (resolve, reject) { + HttpRequest(false, Config.api.appBizStats_days, 2, params, "GET", resolve, reject) + }) +} + export default apiQuery; \ No newline at end of file diff --git a/pages/storeData/customerData/index.js b/pages/storeData/customerData/index.js index 0793791..5ab3f02 100644 --- a/pages/storeData/customerData/index.js +++ b/pages/storeData/customerData/index.js @@ -52,7 +52,6 @@ function Pie2Chart(canvas, width, height, dpr) { Page({ data: { imgUrl: _.config.imgUrl,//静态图片路径 - isShowKefu:false, showPie1Chart:false,//是否显示Pie1图表 ecPie1:{}, showPie2Chart:false,//是否显示Pie2图表 @@ -72,56 +71,275 @@ Page({ this.setData({ s_date:res[0], e_date:res[1], + current_date:res[1], }) }) - this.getAppStatisticsHcust() + this.getAppBizStats_customer() }, - //选择开始日期 + //选择日期 changeDate(e){ if(e.currentTarget.dataset.type=="s_date"){ - this.setData({ - s_date: e.detail.value, - }) + let begin = new Date(e.detail.value).getTime(); + let end = new Date(this.data.e_date).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + s_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let s_date = this.data.e_date + let e_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats_customer() + } } if(e.currentTarget.dataset.type=="e_date"){ - this.setData({ - e_date: e.detail.value, - }) + let begin = new Date(this.data.s_date).getTime(); + let end = new Date(e.detail.value).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + e_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let e_date = this.data.s_date + let s_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats_customer() + } } }, - //数据分析-客户数据 - getAppStatisticsHcust(){ + //客户数据 + getAppBizStats_customer(){ this.setData({ showPie1Chart:false, showPie2Chart:false, + showBarChart:false, }) - - Pie1ChartData = getPie1Option() + let params = {}; + params['s_time'] = this.data.s_date; + params['e_time'] = this.data.e_date; + _.apiQuery.getAppBizStats_customer(params).then(res => { + + wx.setNavigationBarTitle({ + title: res.data.title + }) + + // Pie1ChartData = getPie1Option() + Pie1ChartData = { + tooltip: { + trigger: 'item', + formatter: '{b}: {c} ({d}%)' + }, + series: [ + { + name: 'Access From', + type: 'pie', + selectedMode: 'single', + radius: [0, '30%'], + label: { + position: 'inner', + fontSize: 10 + }, + labelBar: { + show: false + }, + data: [] + }, + { + name: 'Access From', + type: 'pie', + radius: ['45%', '65%'], + labelLine: { + fontSize:5, + length:10 + }, + label: { + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', + backgroundColor: '#F6F8FC', + borderColor: '#8C8D8E', + borderWidth: 1, + borderRadius: 4, + rich: { + hr: { + borderColor: '#8C8D8E', + width: '100%', + borderWidth: 1, + height: 0 + }, + b: { + color: '#4C5058', + fontSize:10, + lineHeight:20, + align: 'center', + }, + c: { + color: '#4C5058', + fontSize:8, + lineHeight:20, + align: 'center', + }, + } + }, + data: [] + }, + ] + }; + + Pie1ChartData.series[0].data = res.data.pie1.series_data_1 + Pie1ChartData.series[1].data = res.data.pie1.series_data_2 this.setData({ + Pie1title:res.data.pie1.title, showPie1Chart:true, ['ecPie1.onInit']:Pie1Chart, }) - Pie2ChartData = getPie2Option() + // Pie2ChartData = getPie2Option() + Pie2ChartData = { + tooltip: { + trigger: 'item', + formatter: '{b}: {c} ({d}%)' + }, + series: [ + { + name: 'Access From', + type: 'pie', + selectedMode: 'single', + radius: [0, '30%'], + label: { + position: 'inner', + fontSize: 10 + }, + labelBar: { + show: false + }, + data: [] + }, + { + name: 'Access From', + type: 'pie', + radius: ['45%', '65%'], + labelLine: { + fontSize:5, + length:10 + }, + label: { + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', + backgroundColor: '#F6F8FC', + borderColor: '#8C8D8E', + borderWidth: 1, + borderRadius: 4, + rich: { + hr: { + borderColor: '#8C8D8E', + width: '100%', + borderWidth: 1, + height: 0 + }, + b: { + color: '#4C5058', + fontSize:10, + lineHeight:20, + align: 'center', + }, + c: { + color: '#4C5058', + fontSize:8, + lineHeight:20, + align: 'center', + }, + } + }, + data: [] + }, + ] + }; + + Pie2ChartData.series[0].data = res.data.pie2.series_data_1 + Pie2ChartData.series[1].data = res.data.pie2.series_data_2 this.setData({ + Pie2title:res.data.pie2.title, showPie2Chart:true, ['ecPie2.onInit']:Pie2Chart, }) - BarChartData = getBarOption() + //BarChartData = getBarOption() + BarChartData = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + xAxis: { + type: 'category', + data: [] + }, + yAxis: { + type: 'value' + }, + grid: { + top: '5%', + left: '2%', + right: '5%', + bottom: '3%', + containLabel: true + }, + series: [ + { + data: [], + type: 'bar', + top: 0, + bottom:'0', + } + ] + }; + + BarChartData.xAxis.data = res.data.bar.xAxis_data + BarChartData.series[0].data = res.data.bar.series_data this.setData({ + Bartitle:res.data.bar.title, showBarChart:true, ['ecBar.onInit']:BarChart, }) wx.stopPullDownRefresh() + }); }, //推送链接 @@ -131,17 +349,10 @@ Page({ } }, - //联系客服 - optShowKefu(e) { - this.setData({ - isShowKefu:!this.data.isShowKefu, - }) - }, - //页面相关事件处理函数--监听用户下拉动作 onPullDownRefresh: function () { - //this.getDistributionHome() + this.getAppBizStats_customer() }, }) @@ -180,7 +391,7 @@ function getPie1Option() { length:10 }, label: { - formatter: '{b|{b}}{abg|}\n{hr|}\n{c| {c}({d}%) }', + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', backgroundColor: '#F6F8FC', borderColor: '#8C8D8E', borderWidth: 1, @@ -312,7 +523,6 @@ function getBarOption() { containLabel: true }, series: [ - { data: [120, 200, 150, 80, 70, 110, 130, 10], type: 'bar', diff --git a/pages/storeData/customerData/index.json b/pages/storeData/customerData/index.json index e76d255..2c9e21c 100644 --- a/pages/storeData/customerData/index.json +++ b/pages/storeData/customerData/index.json @@ -1,5 +1,4 @@ { - "navigationBarTitleText": "客户数据", "navigationBarTextStyle": "white", "navigationBarBackgroundColor": "#ff7052", "backgroundColor": "#ffffff", diff --git a/pages/storeData/customerData/index.wxml b/pages/storeData/customerData/index.wxml index 74ecada..3ae8ac2 100644 --- a/pages/storeData/customerData/index.wxml +++ b/pages/storeData/customerData/index.wxml @@ -1,14 +1,14 @@ - + {{s_date}} - + {{e_date}} @@ -20,7 +20,7 @@ - 客户来源(录入) + {{Pie1title}} @@ -33,7 +33,7 @@ - 客户来源(进店) + {{Pie2title}} @@ -46,7 +46,7 @@ - 顾问录入客户 + {{Bartitle}} diff --git a/pages/storeData/index.js b/pages/storeData/index.js index 7381c67..05a7a2c 100644 --- a/pages/storeData/index.js +++ b/pages/storeData/index.js @@ -35,6 +35,8 @@ Page({ ecFunnel:{}, showLineChart:false,//是否显示Line图表 ecLine:{}, + daysIndex:0, + daysArray:['近7日','近30日'], }, onLoad: function (options) { @@ -48,33 +50,82 @@ Page({ this.setData({ s_date:res[0], e_date:res[1], + current_date:res[1], }) }) this.getAppBizStats() + this.getAppBizStats_days() }, - //选择开始日期 + //选择日期 changeDate(e){ if(e.currentTarget.dataset.type=="s_date"){ - this.setData({ - s_date: e.detail.value, - }) + let begin = new Date(e.detail.value).getTime(); + let end = new Date(this.data.e_date).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + s_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let s_date = this.data.e_date + let e_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats() + } } if(e.currentTarget.dataset.type=="e_date"){ - this.setData({ - e_date: e.detail.value, - }) + let begin = new Date(this.data.s_date).getTime(); + let end = new Date(e.detail.value).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + e_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let e_date = this.data.s_date + let s_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats() + } } }, - //数据分析-客户数据 + //门店数据-漏斗 getAppBizStats(){ this.setData({ showFunnelChart:false, - showLineChart:false, }) let params = {}; @@ -135,10 +186,14 @@ Page({ } ] }; - + if(res.data.funnel.actual_data[0].value==0&&res.data.funnel.actual_data[1].value==0&&res.data.funnel.actual_data[2].value==0){ + FunnelChartData.series[1].itemStyle.opacity = 0 + } + FunnelChartData.series[0].data = res.data.funnel.expected_data FunnelChartData.series[1].data = res.data.funnel.actual_data this.setData({ + funneltitle:res.data.funnel.title, showFunnelChart:true, ['ecFunnel.onInit']:FunnelChart, }) @@ -146,15 +201,66 @@ Page({ wx.stopPullDownRefresh() }); + }, - lineChartData = getLineOption() + //客户/订单走势图 + getAppBizStats_days(){ + this.setData({ + showLineChart:false, + }) + + let params = {}; + params['days'] = this.data.daysIndex == 0?'7':'30'; + _.apiQuery.getAppBizStats_days(params).then(res => { + + // lineChartData = getLineOption() + lineChartData = { + tooltip: { + trigger: 'axis' + }, + legend: { + top: 'bottom', + data: [] + }, + grid: { + top: '3%', + left: '2%', + right: '5%', + bottom: '20%', + containLabel: true + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: [] + }, + yAxis: { + type: 'value' + }, + series: [] + }; + + lineChartData.legend.data = res.data.legend_data + lineChartData.xAxis.data = res.data.xAxis + lineChartData.series = res.data.series this.setData({ + linetitle:res.data.title, showLineChart:true, ['ecLine.onInit']:lineChart, }) wx.stopPullDownRefresh() + }); + + }, + + //选择天数 + changeDays(e) { + this.setData({ + daysIndex: e.detail.value + }) + this.getAppBizStats_days() }, //推送链接 @@ -167,6 +273,7 @@ Page({ //页面相关事件处理函数--监听用户下拉动作 onPullDownRefresh: function () { this.getAppBizStats() + this.getAppBizStats_days() }, }) diff --git a/pages/storeData/index.wxml b/pages/storeData/index.wxml index 092ccdd..2366dc2 100644 --- a/pages/storeData/index.wxml +++ b/pages/storeData/index.wxml @@ -1,14 +1,14 @@ - + {{s_date}} - + {{e_date}} @@ -37,7 +37,7 @@ - 线索转化漏斗 + {{funneltitle}} + diff --git a/pages/storeData/orderData/index.js b/pages/storeData/orderData/index.js index 3c81b7f..78af00b 100644 --- a/pages/storeData/orderData/index.js +++ b/pages/storeData/orderData/index.js @@ -44,7 +44,6 @@ function Pie2Chart(canvas, width, height, dpr) { let option = Pie2ChartData chart.setOption(option); chart.on('click',function(e){ - console.log(e.name) _.eventBus.emit("pinpai",e.name) }); return chart; @@ -53,7 +52,6 @@ function Pie2Chart(canvas, width, height, dpr) { Page({ data: { imgUrl: _.config.imgUrl,//静态图片路径 - isShowKefu:false, showPie1Chart:false,//是否显示Pie1图表 ecPie1:{}, showPie2Chart:false,//是否显示Pie2图表 @@ -73,15 +71,91 @@ Page({ this.setData({ s_date:res[0], e_date:res[1], + current_date:res[1], }) }) - this.getAppStatisticsHcust() + this.getAppBizStats_order() //消息通讯 是否显示授权用户信息按钮 _.eventBus.on("pinpai", this, function(res){ - console.log(111111) - console.log(res) + this.setData({ + showPie2Chart:false, + }) + + Pie2ChartData = { + tooltip: { + fontSize:10, + trigger: 'item', + formatter: '{b}: {c} ({d}%)' + }, + series: [ + { + name: 'Access From', + type: 'pie', + selectedMode: 'single', + radius: [0, '30%'], + label: { + position: 'inner', + fontSize: 10 + }, + labelLine: { + show: false + }, + data: [] + }, + { + name: 'Access From', + type: 'pie', + radius: ['45%', '65%'], + labelLine: { + fontSize:5, + length:10 + }, + label: { + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', + backgroundColor: '#F6F8FC', + borderColor: '#8C8D8E', + borderWidth: 1, + borderRadius: 4, + rich: { + hr: { + borderColor: '#8C8D8E', + width: '100%', + borderWidth: 1, + height: 0 + }, + b: { + color: '#4C5058', + fontSize:10, + lineHeight:20, + align: 'center', + }, + c: { + color: '#4C5058', + fontSize:8, + lineHeight:20, + align: 'center', + }, + } + }, + data: [] + }, + ] + }; + + Pie2ChartData.series[0].data = this.data.pie2.series_data + if(res == '成交数'){ + Pie2ChartData.series[1].data = this.data.pie2.series_data_1 + } + else if(res == '退定数'){ + Pie2ChartData.series[1].data = this.data.pie2.series_data_2 + } + + this.setData({ + showPie2Chart:true, + ['ecPie2.onInit']:Pie2Chart, + }) }) }, @@ -93,49 +167,256 @@ Page({ }, - //选择开始日期 + //选择日期 changeDate(e){ if(e.currentTarget.dataset.type=="s_date"){ - this.setData({ - s_date: e.detail.value, - }) + let begin = new Date(e.detail.value).getTime(); + let end = new Date(this.data.e_date).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + s_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let s_date = this.data.e_date + let e_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats_order() + } } if(e.currentTarget.dataset.type=="e_date"){ - this.setData({ - e_date: e.detail.value, - }) + let begin = new Date(this.data.s_date).getTime(); + let end = new Date(e.detail.value).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + e_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let e_date = this.data.s_date + let s_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats_order() + } } }, - //数据分析-客户数据 - getAppStatisticsHcust(){ + //订单数据 + getAppBizStats_order(){ this.setData({ showPie1Chart:false, showPie2Chart:false, + showBarChart:false, }) - - Pie1ChartData = getPie1Option() + let params = {}; + params['s_time'] = this.data.s_date; + params['e_time'] = this.data.e_date; + _.apiQuery.getAppBizStats_order(params).then(res => { + + wx.setNavigationBarTitle({ + title: res.data.title + }) + + // Pie1ChartData = getPie1Option() + Pie1ChartData = { + series: [ + { + name: 'Access From', + type: 'pie', + bottom:'10%', + radius: ['40%', '70%'], + avoidLabelOverlap: false, + itemStyle: { + borderRadius: 10, + borderColor: '#fff', + borderWidth: 2 + }, + label: { + show: false, + position: 'center' + }, + labelLine: { + fontSize:5, + length:10 + }, + label: { + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', + backgroundColor: '#F6F8FC', + borderColor: '#8C8D8E', + borderWidth: 1, + borderRadius: 4, + rich: { + hr: { + borderColor: '#8C8D8E', + width: '100%', + borderWidth: 1, + height: 0 + }, + b: { + color: '#4C5058', + fontSize:10, + lineHeight:20, + align: 'center', + }, + c: { + color: '#4C5058', + fontSize:8, + lineHeight:20, + align: 'center', + }, + } + }, + data: [] + } + ] + }; + + Pie1ChartData.series[0].data = res.data.pie1.series_data this.setData({ + Pie1title:res.data.pie1.title, showPie1Chart:true, ['ecPie1.onInit']:Pie1Chart, }) - Pie2ChartData = getPie2Option() + // Pie2ChartData = getPie2Option() + Pie2ChartData = { + tooltip: { + fontSize:10, + trigger: 'item', + formatter: '{b}: {c} ({d}%)' + }, + series: [ + { + name: 'Access From', + type: 'pie', + selectedMode: 'single', + radius: [0, '30%'], + label: { + position: 'inner', + fontSize: 10 + }, + labelLine: { + show: false + }, + data: [] + }, + { + name: 'Access From', + type: 'pie', + radius: ['45%', '65%'], + labelLine: { + fontSize:5, + length:10 + }, + label: { + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', + backgroundColor: '#F6F8FC', + borderColor: '#8C8D8E', + borderWidth: 1, + borderRadius: 4, + rich: { + hr: { + borderColor: '#8C8D8E', + width: '100%', + borderWidth: 1, + height: 0 + }, + b: { + color: '#4C5058', + fontSize:10, + lineHeight:20, + align: 'center', + }, + c: { + color: '#4C5058', + fontSize:8, + lineHeight:20, + align: 'center', + }, + } + }, + data: [] + }, + ] + }; + + Pie2ChartData.series[0].data = res.data.pie2.series_data + Pie2ChartData.series[1].data = res.data.pie2.series_data_1 this.setData({ + Pie2title:res.data.pie2.title, showPie2Chart:true, ['ecPie2.onInit']:Pie2Chart, + pie2:res.data.pie2, }) - BarChartData = getBarOption() + //BarChartData = getBarOption() + BarChartData = { + tooltip: { + trigger: 'axis' + }, + grid: { + top: '8%', + left: '5%', + right: '5%', + bottom: '5%', + containLabel: true + }, + calculable: true, + xAxis: [ + { + type: 'category', + data: [] + } + ], + yAxis: [ + { + type: 'value' + } + ], + series: [] + }; + + BarChartData.xAxis.data = res.data.bar.xAxis_data + BarChartData.series = res.data.bar.series this.setData({ + Bartitle:res.data.bar.title, showBarChart:true, ['ecBar.onInit']:BarChart, }) wx.stopPullDownRefresh() + }); }, //推送链接 @@ -145,17 +426,9 @@ Page({ } }, - //联系客服 - optShowKefu(e) { - this.setData({ - isShowKefu:!this.data.isShowKefu, - }) - }, - - //页面相关事件处理函数--监听用户下拉动作 onPullDownRefresh: function () { - //this.getDistributionHome() + this.getAppBizStats_order() }, }) @@ -187,7 +460,7 @@ function getPie1Option() { length:10 }, label: { - formatter: '{b|{b}}{abg|}\n{hr|}\n{c| {c}({d}%) }', + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', backgroundColor: '#F6F8FC', borderColor: '#8C8D8E', borderWidth: 1, @@ -245,7 +518,7 @@ function getPie2Option() { show: false }, data: [ - { value: 258, name: '成交数' }, + { value: 258, name:'成交数',selected:true}, { value: 77, name: '退定数' }, ] }, @@ -258,7 +531,7 @@ function getPie2Option() { length:10 }, label: { - formatter: '{b|{b}}{abg|}\n{hr|}\n{c| {c}({d}%) }', + formatter: '{b| {b} }{abg|}\n{hr|}\n{c| {c}({d}%) }', backgroundColor: '#F6F8FC', borderColor: '#8C8D8E', borderWidth: 1, diff --git a/pages/storeData/orderData/index.wxml b/pages/storeData/orderData/index.wxml index 3cc5cda..3ae8ac2 100644 --- a/pages/storeData/orderData/index.wxml +++ b/pages/storeData/orderData/index.wxml @@ -1,14 +1,14 @@ - + {{s_date}} - + {{e_date}} @@ -20,7 +20,7 @@ - 订单来源 + {{Pie1title}} @@ -33,7 +33,7 @@ - 品牌分布 + {{Pie2title}} @@ -46,7 +46,7 @@ - 顾问成交情况 + {{Bartitle}} diff --git a/pages/storeData/wechatData/index.js b/pages/storeData/wechatData/index.js index 49b3658..c2d966c 100644 --- a/pages/storeData/wechatData/index.js +++ b/pages/storeData/wechatData/index.js @@ -5,8 +5,6 @@ const app = getApp() let Bar1ChartData; let Bar2ChartData; -let Pie1ChartData; -let Pie2ChartData; function Bar1Chart(canvas, width, height, dpr) { const chart = echarts.init(canvas, null, { width: width, @@ -39,7 +37,6 @@ function Bar2Chart(canvas, width, height, dpr) { Page({ data: { imgUrl: _.config.imgUrl,//静态图片路径 - isShowKefu:false, showBar1Chart:false,//是否显示Bar图表 ecBar1:{}, showBar2Chart:false,//是否显示Bar图表 @@ -57,47 +54,177 @@ Page({ this.setData({ s_date:res[0], e_date:res[1], + current_date:res[1], }) }) - this.getAppStatisticsHcust() + this.getAppBizStats_wxqy() }, - //选择开始日期 + //选择日期 changeDate(e){ if(e.currentTarget.dataset.type=="s_date"){ - this.setData({ - s_date: e.detail.value, - }) + let begin = new Date(e.detail.value).getTime(); + let end = new Date(this.data.e_date).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + s_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let s_date = this.data.e_date + let e_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats_wxqy() + } } if(e.currentTarget.dataset.type=="e_date"){ - this.setData({ - e_date: e.detail.value, - }) + let begin = new Date(this.data.s_date).getTime(); + let end = new Date(e.detail.value).getTime(); + let day = 0 + if(end>=begin){ + day = (end - begin)/(24*60*60*1000); + this.setData({ + e_date: e.detail.value, + }) + } + else{ + day = (begin - end)/(24*60*60*1000); + let e_date = this.data.s_date + let s_date = e.detail.value + this.setData({ + s_date, + e_date, + }) + } + if (day > 365) { + wx.showToast({ + title: '请选择一年时间内', + icon: 'none' + }) + } + else{ + this.getAppBizStats_wxqy() + } } }, - //数据分析-客户数据 - getAppStatisticsHcust(){ + //企微数据 + getAppBizStats_wxqy(){ this.setData({ + showBar1Chart:false, + showBar2Chart:false, }) + let params = {}; + params['s_time'] = this.data.s_date; + params['e_time'] = this.data.e_date; + _.apiQuery.getAppBizStats_wxqy(params).then(res => { - Bar1ChartData = getBar1Option() + wx.setNavigationBarTitle({ + title: res.data.title + }) + + //Bar1ChartData = getBar1Option() + Bar1ChartData = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + xAxis: { + type: 'category', + data: [] + }, + yAxis: { + type: 'value' + }, + grid: { + top: '5%', + left: '2%', + right: '5%', + bottom: '3%', + containLabel: true + }, + series: [ + + { + data: [], + type: 'bar', + top: 0, + bottom:'0', + } + ] + }; + + Bar1ChartData.xAxis.data = res.data.bar1.xAxis_data + Bar1ChartData.series[0].data = res.data.bar1.series_data this.setData({ + Bar1title:res.data.bar1.title, showBar1Chart:true, ['ecBar1.onInit']:Bar1Chart, }) - Bar2ChartData = getBar2Option() + //Bar2ChartData = getBar2Option() + Bar2ChartData = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + xAxis: { + type: 'category', + data: [] + }, + yAxis: { + type: 'value' + }, + grid: { + top: '5%', + left: '2%', + right: '5%', + bottom: '3%', + containLabel: true + }, + series: [ + + { + data: [], + type: 'bar', + top: 0, + bottom:'0', + } + ] + }; + + Bar2ChartData.xAxis.data = res.data.bar2.xAxis_data + Bar2ChartData.series[0].data = res.data.bar2.series_data this.setData({ + Bar2title:res.data.bar2.title, showBar2Chart:true, ['ecBar2.onInit']:Bar2Chart, }) wx.stopPullDownRefresh() + }); }, //推送链接 @@ -107,17 +234,9 @@ Page({ } }, - //联系客服 - optShowKefu(e) { - this.setData({ - isShowKefu:!this.data.isShowKefu, - }) - }, - - //页面相关事件处理函数--监听用户下拉动作 onPullDownRefresh: function () { - //this.getDistributionHome() + this.getAppBizStats_wxqy() }, }) diff --git a/pages/storeData/wechatData/index.json b/pages/storeData/wechatData/index.json index f4f27a2..2c9e21c 100644 --- a/pages/storeData/wechatData/index.json +++ b/pages/storeData/wechatData/index.json @@ -1,5 +1,4 @@ { - "navigationBarTitleText": "企微数据", "navigationBarTextStyle": "white", "navigationBarBackgroundColor": "#ff7052", "backgroundColor": "#ffffff", diff --git a/pages/storeData/wechatData/index.wxml b/pages/storeData/wechatData/index.wxml index eef2268..5f2ae43 100644 --- a/pages/storeData/wechatData/index.wxml +++ b/pages/storeData/wechatData/index.wxml @@ -1,14 +1,14 @@ - + {{s_date}} - + {{e_date}} @@ -20,7 +20,7 @@ - 企微添加好友 + {{Bar1title}} @@ -33,7 +33,7 @@ - 企微添加点亮 + {{Bar2title}}