Files
小鱼开发 3bf5c948d8 Initial commit
2024-05-24 14:16:05 +08:00

163 lines
3.6 KiB
JavaScript

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 lineChartData;
function lineChart(canvas, width, height, dpr) {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
canvas.setChart(chart);
let option = lineChartData
chart.setOption(option);
return chart;
}
Page({
data: {
imgUrl:_.config.imgUrl,
materialArray: [],
materialobj: [],
materialIndex:-1,
dateTime:'',
calList: [],
showLineChart:false,//是否显示Line图表
ecLine:{},
},
onLoad(options) {
for (let key in options) {
this.setData({
[key]: options[key]
})
}
// popularData.getDateLater(0,0).then(res => {
// this.setData({
// dateTime:res[0],
// })
// })
this.getMaterialStatistics()
this.getMaterialStatisticsChart()
},
onShow: function () {
},
//数据分析_首页
getMaterialStatistics(){
_.apiQuery.getMaterialStatistics().then(res => {
wx.setNavigationBarTitle({
title:res.data.title,
})
let materialArray = []
res.data.topic_list.forEach(item => {
materialArray.push(item.title)
})
this.setData({
biz_name:res.data.biz_name,
materialArray:materialArray,
materialobj: res.data.topic_list,
materialIndex:-1,
})
this.getMaterialStatisticsCal()
});
},
//数据分析_累计数据
getMaterialStatisticsCal(){
let params = {};
if(this.data.dateTime != ''){
params['day'] = this.data.dateTime;
}
if(this.data.materialIndex>-1){
params['t_id'] = this.data.materialobj[this.data.materialIndex].id;
}
_.apiQuery.getMaterialStatisticsCal(params).then(res => {
this.setData({
calList:res.data,
})
});
},
//数据分析-订单数据
getMaterialStatisticsChart(){
this.setData({
ecLine:{},
showLineChart:false,
})
let params = {};
// if(this.data.dateTime != ''){
// params['day'] = this.data.dateTime;
// }
// if(this.data.materialIndex>-1){
// params['t_id'] = this.data.materialobj[this.data.materialIndex].id;
// }
_.apiQuery.getMaterialStatisticsChart(params).then(res => {
lineChartData = {
"tooltip":{"trigger":"axis"},
"legend":{
"top":"bottom",
"data":[]
},
"grid":{"top":"10%","left":"2%","right":"5%","bottom":"15%","containLabel":true},
"xAxis":{
"type":"category",
"boundaryGap":false,
"data":[]
},
"yAxis":{"type":"value"},
"series":[]
}
lineChartData.legend.data = res.data.legend
lineChartData.xAxis.data = res.data.xAxis
lineChartData.series = res.data.series
this.setData({
showLineChart:true,
['ecLine.onInit']:lineChart,
})
});
},
//日期选择
changeDate(e){
this.setData({
dateTime: e.detail.value,
})
this.getMaterialStatisticsCal()
},
//选择素材
changeMaterial(e) {
this.setData({
materialIndex: e.detail.value
})
this.getMaterialStatisticsCal()
},
//推送链接
pushLink(e) {
if(e.currentTarget.dataset.url){
_.$router.openUrlScheme(e.currentTarget.dataset.url)
}
},
//页面相关事件处理函数--监听用户下拉动作
onPullDownRefresh: function () {
this.getMaterialStatistics()
this.getMaterialStatisticsChart()
},
})