From 9dd8f5e358771c680d53dd9889c179db27e3fe49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=8F=B6?= Date: Wed, 14 Jun 2023 11:36:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BA=8C=E7=BA=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 2 +- commons/js/config.js | 3 +- commons/js/utils/apiQuery.js | 7 + pages/storeData/customerData/index.js | 27 +- pages/storeData/customerData/index.wxml | 2 + pages/storeData/orderData/index.js | 32 ++- pages/storeData/orderData/index.wxml | 4 +- pages/storeData/orderData/subData/index.js | 66 ----- pages/storeData/orderData/subData/index.json | 3 - pages/storeData/orderData/subData/index.wxml | 2 - pages/storeData/orderData/subData/index.wxss | 1 - pages/storeData/subData/index.js | 266 +++++++++++++++++++ pages/storeData/subData/index.json | 10 + pages/storeData/subData/index.wxml | 36 +++ pages/storeData/subData/index.wxss | 1 + 15 files changed, 374 insertions(+), 88 deletions(-) delete mode 100644 pages/storeData/orderData/subData/index.js delete mode 100644 pages/storeData/orderData/subData/index.json delete mode 100644 pages/storeData/orderData/subData/index.wxml delete mode 100644 pages/storeData/orderData/subData/index.wxss create mode 100644 pages/storeData/subData/index.js create mode 100644 pages/storeData/subData/index.json create mode 100644 pages/storeData/subData/index.wxml create mode 100644 pages/storeData/subData/index.wxss diff --git a/app.json b/app.json index cf5f7c1..da63ebf 100644 --- a/app.json +++ b/app.json @@ -62,7 +62,7 @@ "pages/order/editVoucherImg/index", "pages/dataAnalysis/detail/index", "pages/order/editBuyer/index", - "pages/storeData/orderData/subData/index" + "pages/storeData/subData/index" ], "echarts": [ { diff --git a/commons/js/config.js b/commons/js/config.js index d70acc6..82fd22b 100644 --- a/commons/js/config.js +++ b/commons/js/config.js @@ -1,4 +1,4 @@ -const env = "p"; +const env = "d"; const version = 1, @@ -162,6 +162,7 @@ api = { appBizStats_wxqy:'app/biz/stats_wxqy', //企微数据 appBizStats_order:'app/biz/stats_order', //订单数据 appBizStats_days:'app/biz/stats_days', //客户/订单走势图 + appBizStats_customer_pid:'app/biz/stats_customer_pid', //客户数据二级 appOptions:'app/options', //获取车辆选装包 diff --git a/commons/js/utils/apiQuery.js b/commons/js/utils/apiQuery.js index 80c6a40..313aa5e 100644 --- a/commons/js/utils/apiQuery.js +++ b/commons/js/utils/apiQuery.js @@ -931,6 +931,13 @@ apiQuery.getAppBizStats_days = function (params) { }) } +//客户数据二级 +apiQuery.getAppBizStats_customer_pid = function (params) { + return new Promise(function (resolve, reject) { + HttpRequest(false, Config.api.appBizStats_customer_pid, 2, params, "GET", resolve, reject) + }) +} + //获取渠道经理数据分析入口数据 apiQuery.getAppStatisticsStats = function (params) { return new Promise(function (resolve, reject) { diff --git a/pages/storeData/customerData/index.js b/pages/storeData/customerData/index.js index 60cff2b..e071b60 100644 --- a/pages/storeData/customerData/index.js +++ b/pages/storeData/customerData/index.js @@ -30,7 +30,12 @@ function Pie1Chart(canvas, width, height, dpr) { let option = Pie1ChartData chart.setOption(option); chart.on('click',function(e){ - console.log(e) + if(e.data.id>0){ + let obj = {} + obj.type = 1 + obj.id = e.data.id + _.eventBus.emit("stats",obj) + } }); return chart; } @@ -44,7 +49,12 @@ function Pie2Chart(canvas, width, height, dpr) { let option = Pie2ChartData chart.setOption(option); chart.on('click',function(e){ - console.log(e) + if(e.data.id>0){ + let obj = {} + obj.type = 0 + obj.id = e.data.id + _.eventBus.emit("stats",obj) + } }); return chart; } @@ -76,9 +86,22 @@ Page({ // }) this.getAppBizStats_customer() + + let that = this + //消息通讯 是否显示授权用户信息按钮 + _.eventBus.on("stats", this, function(res){ + let url = '/pages/storeData/subData/index?type=' + res.type + '&id=' + res.id + '&s_date=' + that.data.s_date + '&e_date=' + that.data.e_date + '¤t_date=' + that.data.current_date + _.$router.openUrlScheme(url) + }) }, + //生命周期函数--监听页面卸载 + onUnload: function () { + //卸载消息通讯 是否显示授权用户信息 + _.eventBus.remove('stats',this); + }, + //选择日期 changeDate(e){ if(e.currentTarget.dataset.type=="s_date"){ diff --git a/pages/storeData/customerData/index.wxml b/pages/storeData/customerData/index.wxml index a9dd6fc..31dd67c 100644 --- a/pages/storeData/customerData/index.wxml +++ b/pages/storeData/customerData/index.wxml @@ -28,6 +28,7 @@ + 点击分类卡片查看具体数据 @@ -42,6 +43,7 @@ + 点击分类卡片查看具体数据 diff --git a/pages/storeData/orderData/index.js b/pages/storeData/orderData/index.js index 2859762..15eb0e5 100644 --- a/pages/storeData/orderData/index.js +++ b/pages/storeData/orderData/index.js @@ -30,7 +30,12 @@ function Pie1Chart(canvas, width, height, dpr) { let option = Pie1ChartData chart.setOption(option); chart.on('click',function(e){ - console.log(e) + if(e.data.id>0){ + let obj = {} + obj.type = 2 + obj.id = e.data.id + _.eventBus.emit("stats",obj) + } }); return chart; } @@ -44,8 +49,13 @@ function Pie2Chart(canvas, width, height, dpr) { let option = Pie2ChartData chart.setOption(option); chart.on('click',function(e){ - _.eventBus.emit("pinpai",e.name) - console.log(e) + _.eventBus.emit("stats",e.name) + if(e.data.id>0){ + let obj = {} + obj.type = 3 + obj.id = e.data.id + _.eventBus.emit("stats",obj) + } }); return chart; } @@ -78,18 +88,20 @@ Page({ this.getAppBizStats_order() + let that = this //消息通讯 是否显示授权用户信息按钮 - _.eventBus.on("pinpai", this, function(res){ - console.log(res) + _.eventBus.on("stats", this, function(res){ + let url = '/pages/storeData/subData/index?type=' + res.type + '&id=' + res.id + '&s_date=' + that.data.s_date + '&e_date=' + that.data.e_date + '¤t_date=' + that.data.current_date + _.$router.openUrlScheme(url) }) }, - // //生命周期函数--监听页面卸载 - // onUnload: function () { - // //卸载消息通讯 是否显示授权用户信息 - // _.eventBus.remove('pinpai',this); - // }, + //生命周期函数--监听页面卸载 + onUnload: function () { + //卸载消息通讯 是否显示授权用户信息 + _.eventBus.remove('stats',this); + }, //选择日期 diff --git a/pages/storeData/orderData/index.wxml b/pages/storeData/orderData/index.wxml index 490a088..1628d8f 100644 --- a/pages/storeData/orderData/index.wxml +++ b/pages/storeData/orderData/index.wxml @@ -29,7 +29,7 @@ {{pie1Bottom}} - + 点击分类卡片查看具体数据 @@ -45,7 +45,7 @@ {{pie2Bottom}} - + 点击分类卡片查看具体数据 diff --git a/pages/storeData/orderData/subData/index.js b/pages/storeData/orderData/subData/index.js deleted file mode 100644 index eba0bbf..0000000 --- a/pages/storeData/orderData/subData/index.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/storeData/orderData/subData/index.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/storeData/orderData/subData/index.json b/pages/storeData/orderData/subData/index.json deleted file mode 100644 index 8835af0..0000000 --- a/pages/storeData/orderData/subData/index.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/pages/storeData/orderData/subData/index.wxml b/pages/storeData/orderData/subData/index.wxml deleted file mode 100644 index 7a26e8a..0000000 --- a/pages/storeData/orderData/subData/index.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/storeData/orderData/subData/index.wxml diff --git a/pages/storeData/orderData/subData/index.wxss b/pages/storeData/orderData/subData/index.wxss deleted file mode 100644 index f3bc0f7..0000000 --- a/pages/storeData/orderData/subData/index.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/storeData/orderData/subData/index.wxss */ \ No newline at end of file diff --git a/pages/storeData/subData/index.js b/pages/storeData/subData/index.js new file mode 100644 index 0000000..d10abcc --- /dev/null +++ b/pages/storeData/subData/index.js @@ -0,0 +1,266 @@ +import _ from '../../../commons/js/commons'; +import popularData from '../../../commons/js/lib/popularData'; +import * as echarts from '../../../ecCanvas/components/ec-canvas/echarts'; +const app = getApp() + +let Pie1ChartData; +function Pie1Chart(canvas, width, height, dpr) { + const chart = echarts.init(canvas, null, { + width: width, + height: height, + devicePixelRatio: dpr // new + }); + canvas.setChart(chart); + let option = Pie1ChartData + chart.setOption(option); + chart.on('click',function(e){ + console.log(e) + }); + return chart; +} + +Page({ + data: { + imgUrl: _.config.imgUrl,//静态图片路径 + showPie1Chart:false,//是否显示Pie1图表 + ecPie1:{}, + }, + + onLoad: function (options) { + for (let key in options) { + this.setData({ + [key]: options[key] + }) + } + this.getAppBizStats_customer_pid() + + }, + + + //选择日期 + changeDate(e){ + if(e.currentTarget.dataset.type=="s_date"){ + 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_pid() + } + } + if(e.currentTarget.dataset.type=="e_date"){ + 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_pid() + } + } + + }, + + //订单数据 + getAppBizStats_customer_pid(){ + this.setData({ + showPie1Chart:false, + }) + + let params = {}; + params['type'] = this.data.type; + params['id'] = this.data.id; + params['s_time'] = this.data.s_date; + params['e_time'] = this.data.e_date; + _.apiQuery.getAppBizStats_customer_pid(params).then(res => { + + wx.setNavigationBarTitle({ + title: res.data.title + }) + + // this.setData({ + // Pie1title:res.data.title, + // }) + if(res.data.series_data.length==0){ + this.setData({ + pie1noData:true, + }) + }else{ + Pie1ChartData = { + tooltip: { + trigger: 'item', + formatter: '{b}: {c} ({d}%)' + }, + series: [ + { + name: 'Access From', + type: 'pie', + bottom:'15%', + 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.series_data + this.setData({ + pie1noData:false, + showPie1Chart:true, + ['ecPie1.onInit']:Pie1Chart, + }) + } + wx.stopPullDownRefresh() + + }); + }, + + //页面相关事件处理函数--监听用户下拉动作 + onPullDownRefresh: function () { + this.getAppBizStats_customer_pid() + }, + +}) + +function getPie1Option() { + return { + // tooltip: { + // trigger: 'item', + // formatter: '{b}: {c} ({d}%)' + // }, + 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: [ + { value: 48, name: '转介绍' }, + { value: 35, name: '网络推广' }, + { value: 30, name: '外展外拓' }, + { value: 21, name: '自媒体' }, + ] + } + ] + }; +} \ No newline at end of file diff --git a/pages/storeData/subData/index.json b/pages/storeData/subData/index.json new file mode 100644 index 0000000..71c5e29 --- /dev/null +++ b/pages/storeData/subData/index.json @@ -0,0 +1,10 @@ +{ + "navigationBarTitleText": "数据看板", + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#ff7052", + "backgroundColor": "#ffffff", + "backgroundColorTop": "#ff7052", + "usingComponents": { + "ec-canvas": "../../../ecCanvas/components/ec-canvas/ec-canvas" + } +} \ No newline at end of file diff --git a/pages/storeData/subData/index.wxml b/pages/storeData/subData/index.wxml new file mode 100644 index 0000000..299900e --- /dev/null +++ b/pages/storeData/subData/index.wxml @@ -0,0 +1,36 @@ + + + + + + {{s_date}} + + + + + + + {{e_date}} + + + + + + + + + + + + + + + {{pie1Bottom}} + + + + + + \ No newline at end of file diff --git a/pages/storeData/subData/index.wxss b/pages/storeData/subData/index.wxss new file mode 100644 index 0000000..1b81f79 --- /dev/null +++ b/pages/storeData/subData/index.wxss @@ -0,0 +1 @@ +/* pages/storeData/index.wxss */ \ No newline at end of file