namespace ruanzhifenbu { const { line, upLine } = require("./F2"); let { getProgramTypeDistribution } = 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; }, /** * 组件的初始数据 */ data: { onInitChart: undefined, DayList: {}, select_act: 0, select: [ { text: "时长", proportionType: "timeSize", type: 2, unit: "分", }, { text: "频次", proportionType: "pinci", type: 1, unit: "次", }, { text: "客户数", proportionType: "custom", type: 4, unit: "个", }, ], }, /** * 组件的方法列表 */ methods: { init() { let channelItem = this.data.channel; Promise.all([ getProgramTypeDistribution({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let li = res[0] ? res[0].data : [] , key = this.data.select[this.data.select_act].proportionType, total = 0; li.map((v:any)=>{ total += Number(v[key]) }) this.setData({ DayList: li.map((v:any)=>{ v.type = '0'; v[key] = Number(v[key] || 0) v.value = v[key] / total*100 return v }), onInitChart: line.bind(this), }) }) }, upData() { let channelItem = this.data.channel; Promise.all([ getProgramTypeDistribution({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let li = res[0] ? res[0].data : [] , key = this.data.select[this.data.select_act].proportionType, total = 0; li.map((v:any)=>{ total += Number(v[key]) }) this.setData({ DayList: li.map((v:any)=>{ v.type = '0'; v[key] = Number(v[key] || 0) v.value = v[key] / total*100 return v }), },()=>{ upLine.bind(this)() }) }) }, channelChange(event: wxPicker) { this.setData({ select_act: Number(event.detail.value) }, () => this.upData()) }, } }) }