namespace pindaofenbu { const { line, upLine,clearchart } = require("./F2"); const { line1, upLine1,clearchart1 } = require("./F21"); let { getChannelDistribution } = require('../../../../utils/api') let first = true; Component({ /** * 组件的属性列表 */ properties: { array: { type: Object }, channel: { type: Object }, }, observers: { 'array': function () { !first && this.upData() }, 'channel': function () { !first && this.upData() }, }, ready() { this.init(); first = false; }, detached: function() { // 在组件实例被从页面节点树移除时执行 clearchart() clearchart1() }, /** * 组件的初始数据 */ data: { onInitChart: undefined, onInitChart1: undefined, DayList: {}, DayList1: {}, select_act: 0, select: [ { text: "费用", proportionType: "kanlijia", type: 3, unit: "万元", }, { text: "时长", proportionType: "timeSize", type: 2, unit: "分", }, { text: "频次", proportionType: "pinci", type: 1, unit: "次", }, ], }, /** * 组件的方法列表 */ methods: { init() { let channelItem = this.data.channel; Promise.all([ getChannelDistribution({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let harddata = res[0].harddata || [], softdata = res[0].softdata || []; let key = this.data.select[this.data.select_act].proportionType; this.setData({ DayList1: softdata.map((v: any) => { v[key] = Number(v[key] || 0) return v }), DayList: harddata.map((v: any) => { v[key] = Number(v[key] || 0); return v }), onInitChart: line.bind(this), onInitChart1: line1.bind(this) }) }) }, upData() { let channelItem = this.data.channel; Promise.all([ getChannelDistribution({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let harddata = res[0].harddata || [], softdata = res[0].softdata || []; let key = this.data.select[this.data.select_act].proportionType; this.setData({ DayList1: softdata.map((v: any) => { v[key] = Number(v[key] || 0) return v }), DayList: harddata.map((v: any) => { v[key] = Number(v[key] || 0); return v }), }, () => { upLine.bind(this)() upLine1.bind(this)() }) }) }, channelChange(event: wxPicker) { this.setData({ select_act: Number(event.detail.value) }, () => this.upData()) }, } }) }