namespace hangyejiegou { const { line, upLine } = require("./F2"); const { line1, upLine1 } = require("./F21"); let { getMarket } = 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() { console.log(this.data.array.index) this.init(); first = false; }, /** * 组件的初始数据 */ data: { onInitChart: undefined, onInitChart1: undefined, DayList: [], DayList1: [], select_act: 0, select: [ { text: "时长", proportionType: "timeSize", type: 2, unit: "分", }, { text: "频次", proportionType: "pinci", type: 1, unit: "次", }, { text: "客户数", proportionType: "custom", type: 4, unit: "个", }, ], }, /** * 组件的方法列表 */ methods: { init() { Promise.all([ getMarket({ dataType: this.data.select[this.data.select_act].type, indexTime: this.data.array.index, tableType: 3 }), getMarket({ dataType: this.data.select[this.data.select_act].type, indexTime: this.data.array.index, tableType: 4 }), ]).then((res: any[]) => { let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType this.setData({ DayList: li.map((v:any)=>{ v.type = '0'; v[key] = Number(v[key] || 0) return v }), DayList1: li1.map((v:any)=>{ v.type = '0'; v[key] = Number(v[key] || 0) return v }), onInitChart: line.bind(this), onInitChart1: line1.bind(this) }) }) }, upData() { Promise.all([ getMarket({ dataType: this.data.select[this.data.select_act].type, indexTime: this.data.array.index, tableType: 3 }), getMarket({ dataType: this.data.select[this.data.select_act].type, indexTime: this.data.array.index, tableType: 4 }), ]).then((res: any[]) => { let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType; this.setData({ DayList: li.map((v:any)=>{ v.type = '0'; v[key] = Number(v[key] || 0) return v }), DayList1: li1.map((v:any)=>{ v.type = '0'; 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()) }, } }) }