namespace hangyetoufang { const { line, upLine } = require("./F2"); const { line1, upLine1 } = require("./F21"); let { getTrendHard,getTrendSoft,getMarket } = require('../../../../utils/api') let first = true; Component({ /** * 组件的属性列表 */ properties: { array: { type: Object }, channel: { type: Object }, }, observers: { 'array': function () { !first && this.upData() !first && this.upData1() }, 'channel': function () { !first && this.upData() !first && this.upData1() }, }, ready() { this.init(); first = false; }, /** * 组件的初始数据 */ data: { onInitChart: undefined, onInitChart1: undefined, DayList: {}, DayList1: {}, select_act: 0, select: [ { text: "费用", proportionType: "feiyong", type: 3, unit: "元", }, { text: "时长", proportionType: "timeSize", type: 2, unit: "分", }, { text: "频次", proportionType: "pinci", type: 1, unit: "次", }, ], select_act1: 0, select1: [ { text: "时长", proportionType: "timeSize", type: 2, unit: "分", }, { text: "频次", proportionType: "pinci", type: 1, unit: "次", }, ] }, /** * 组件的方法列表 */ methods: { init() { let channelItem = this.data.channel; Promise.all([ getTrendHard({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), getTrendSoft({ type: this.data.select1[this.data.select_act1].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let li = res[0] || [] let list: adDay = { before: [], now: [] }, key = this.data.select[this.data.select_act].proportionType; for (let i = 0; i < (li.harddatabase || []).length; i++) { const v = (li.harddatabase || [])[i]; v[key] = Number(v[key] || 0) list.before.push(v) } for (let i = 0; i < (li.harddatacompare || []).length; i++) { const v = (li.harddatacompare || [])[i]; v[key] = Number(v[key] || 0) list.now.push(v) } let li1 = res[1] || [] let list1: adDay = { before: [], now: [] }, key1 = this.data.select1[this.data.select_act1].proportionType; for (let i = 0; i < (li1.softdatabase || []).length; i++) { const v = (li1.softdatabase || [])[i]; v[key1] = Number(v[key1] || 0) list1.before.push(v) } for (let i = 0; i < (li1.softdatacompare || []).length; i++) { const v = (li1.softdatacompare || [])[i]; v[key1] = Number(v[key1] || 0) list1.now.push(v) } this.setData({ DayList1: list1, DayList: list, onInitChart: line.bind(this), onInitChart1: line1.bind(this) }) }) }, upData() { let channelItem = this.data.channel; Promise.all([ getTrendHard({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let li = res[0] || [] let list: adDay = { before: [], now: [] }, key = this.data.select[this.data.select_act].proportionType; for (let i = 0; i < (li.harddatabase || []).length; i++) { const v = (li.harddatabase || [])[i]; v[key] = Number(v[key] || 0) list.before.push(v) } for (let i = 0; i < (li.harddatacompare || []).length; i++) { const v = (li.harddatacompare || [])[i]; v[key] = Number(v[key] || 0) list.now.push(v) } console.log(list) this.setData({ DayList: list, },()=>{ upLine.bind(this)() }) }) }, upData1() { let channelItem = this.data.channel; Promise.all([ getTrendSoft({ type: this.data.select1[this.data.select_act1].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let li = res[0] || [] let list: adDay = { before: [], now: [] }, key = this.data.select1[this.data.select_act1].proportionType; for (let i = 0; i < (li.softdatabase || []).length; i++) { const v = (li.softdatabase || [])[i]; v[key] = Number(v[key] || 0) list.before.push(v) } for (let i = 0; i < (li.softdatacompare || []).length; i++) { const v = (li.softdatacompare || [])[i]; v[key] = Number(v[key] || 0) list.now.push(v) } this.setData({ DayList1: list, },()=>{ upLine1.bind(this)() }) }) }, channelChange(event: wxPicker) { this.setData({ select_act: Number(event.detail.value) }, () => this.upData()) }, channelChange1(event: wxPicker) { this.setData({ select_act1: Number(event.detail.value) }, () => this.upData1()) } } }) }