|
|
@@ -9,11 +9,15 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
info:{},
|
|
|
+ analyse:{},
|
|
|
day:'',
|
|
|
ec: {
|
|
|
// onInit: initChart
|
|
|
lazyLoad: true
|
|
|
},
|
|
|
+ page:0,
|
|
|
+ casci:0,
|
|
|
+ act:0
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -26,7 +30,7 @@ Page({
|
|
|
this.setData({
|
|
|
day: y + '-' + m + '-' + d
|
|
|
})
|
|
|
- options.id=2;
|
|
|
+ // options.id=2;
|
|
|
wx.showNavigationBarLoading()
|
|
|
wx.request({
|
|
|
url: host + '/api/casci/detail',
|
|
|
@@ -40,30 +44,108 @@ Page({
|
|
|
this.setData({
|
|
|
info:res.data.data
|
|
|
})
|
|
|
+ this.setChart()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/casci/analyse',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ id: options.id
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ wx.hideNavigationBarLoading()
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ this.setData({
|
|
|
+ analyse: res.data.data
|
|
|
+ })
|
|
|
|
|
|
- var records = res.data.data.days7_casci, xdata = [], ydata = [];
|
|
|
- if (records.length <= 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- for (let i = 0; i < records.length; i++) {
|
|
|
- xdata.push(records[i].name)
|
|
|
- ydata.push(records[i].value)
|
|
|
- xdata.push(records[i].name)
|
|
|
- ydata.push(2500)
|
|
|
- xdata.push(records[i].name)
|
|
|
- ydata.push(1800)
|
|
|
- }
|
|
|
- // xdata = xdata.reverse()
|
|
|
- // ydata = ydata.reverse()
|
|
|
- this.oneComponent = this.selectComponent('#mychart');
|
|
|
- this.init_one(xdata, ydata)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
},
|
|
|
- init_one: function (xdata, ydata) { //初始化第一个图表
|
|
|
+ checkpage:function(e){
|
|
|
+ this.setData({
|
|
|
+ act: e.target.dataset.id
|
|
|
+ })
|
|
|
+ if (e.target.dataset.id == 0){
|
|
|
+ this.setChart()
|
|
|
+ }
|
|
|
+ if (e.target.dataset.id == 1) {
|
|
|
+ this.setChart1()
|
|
|
+ this.setChart2()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ check:function(e){
|
|
|
+ this.setData({
|
|
|
+ casci:e.target.dataset.id
|
|
|
+ })
|
|
|
+ this.setChart()
|
|
|
|
|
|
+ },
|
|
|
+ checknum: function (e) {
|
|
|
+ this.setData({
|
|
|
+ page: e.target.dataset.id
|
|
|
+ })
|
|
|
+ this.setChart2()
|
|
|
+
|
|
|
+ },
|
|
|
+ setChart:function(){
|
|
|
+ var records = [], xdata = [], ydata = [];
|
|
|
+ if (this.data.casci == 0) {
|
|
|
+ records = this.data.info.days7_casci;
|
|
|
+ } else {
|
|
|
+ records = this.data.info.days30_casci;
|
|
|
+ }
|
|
|
+ if (records.length <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (let i = 0; i < records.length; i++) {
|
|
|
+ xdata.push(records[i].name)
|
|
|
+ ydata.push(records[i].value)
|
|
|
+ }
|
|
|
+ this.oneComponent = this.selectComponent('#mychart');
|
|
|
+ this.init_one(xdata, ydata)
|
|
|
+ },
|
|
|
+ setChart1: function () {
|
|
|
+ console.log(2333)
|
|
|
+ var records = [], xdata = [], ydata = [];
|
|
|
+ records = this.data.analyse.days7_casci_zhuanfa;
|
|
|
+ if (records.length <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (let i = 0; i < records.length; i++) {
|
|
|
+ xdata.push(records[i].name)
|
|
|
+ ydata.push(records[i].value)
|
|
|
+ }
|
|
|
+ this.oneComponent1 = this.selectComponent('#mychart1');
|
|
|
+ this.init_two(xdata, ydata)
|
|
|
+ },
|
|
|
+ setChart2: function () {
|
|
|
+ var records = [], xdata = [], ydata = [];
|
|
|
+ if (this.data.page == 0) {
|
|
|
+ records = this.data.info.days7_casci_read;
|
|
|
+ } else if (this.data.page == 0) {
|
|
|
+ records = this.data.info.days7_casci_zan;
|
|
|
+ }else{
|
|
|
+ records = this.data.info.days7_casci_zhuanfa;
|
|
|
+ }
|
|
|
+ records = this.data.analyse.days7_casci_zhuanfa;
|
|
|
+ if (records.length <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (let i = 0; i < records.length; i++) {
|
|
|
+ xdata.push(records[i].name)
|
|
|
+ ydata.push(records[i].value)
|
|
|
+ }
|
|
|
+ this.oneComponent2 = this.selectComponent('#mychart2');
|
|
|
+ this.init_three(xdata, ydata)
|
|
|
+ },
|
|
|
+ init_one: function (xdata, ydata) { //初始化第一个图表
|
|
|
this.oneComponent.init((canvas, width, height, dpr) => {
|
|
|
const chart = echarts.init(canvas, null, {
|
|
|
width: width,
|
|
|
@@ -73,8 +155,33 @@ Page({
|
|
|
setOption(chart, xdata, ydata)
|
|
|
this.chart = chart;
|
|
|
return chart;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ init_two: function (xdata, ydata) { //初始化第一个图表
|
|
|
+ this.oneComponent1.init((canvas, width, height, dpr) => {
|
|
|
+ const chart = echarts.init(canvas, null, {
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
+ devicePixelRatio: dpr
|
|
|
+ });
|
|
|
+ setOption(chart, xdata, ydata)
|
|
|
+ this.chart = chart;
|
|
|
+ return chart;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ init_three: function (xdata, ydata) { //初始化第一个图表
|
|
|
+ this.oneComponent2.init((canvas, width, height, dpr) => {
|
|
|
+ const chart = echarts.init(canvas, null, {
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
+ devicePixelRatio: dpr
|
|
|
+ });
|
|
|
+ setOption(chart, xdata, ydata)
|
|
|
+ this.chart = chart;
|
|
|
+ return chart;
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
@@ -133,7 +240,7 @@ function setOption(chart, xdata, ydata) {
|
|
|
backgroundColor:'#F1F4F6',
|
|
|
grid: {
|
|
|
x: 50,
|
|
|
- y: 40,
|
|
|
+ y: 30,
|
|
|
x2: 10,
|
|
|
y2: 35
|
|
|
},
|
|
|
@@ -206,4 +313,4 @@ function setOption(chart, xdata, ydata) {
|
|
|
}]
|
|
|
};
|
|
|
chart.setOption(option)
|
|
|
-}
|
|
|
+}
|