namespace fenzhongdiankehu { let { getImportantCustomer } = require('../../../../utils/api') let first = true; Component({ /** * 组件的属性列表 */ properties: { array: { type: Object }, channel: { type: Object }, isshow: { type: Boolean } }, observers: { 'array': function () { !first && this.upData() }, 'channel': function () { !first && this.upData() }, }, ready() { 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: "次", }, ], }, /** * 组件的方法列表 */ methods: { init() { let channelItem = this.data.channel, key = this.data.select[this.data.select_act].proportionType; Promise.all([ getImportantCustomer({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let hard = (res[0] || []).harddata; let soft= (res[0] || []).softdata; this.setData({ DayList: hard.splice(0,10).map((v:any, i:number)=>{ v[key] = Number(v[key] || 0) v.feiyong = Number(v.feiyong|| 0) v.huanbi = Number(v.huanbi|| 0) return v }), DayList1: soft.splice(0,10).map((v:any, i:number)=>{ v[key] = Number(v[key]) v.huanbi = Number(v.huanbi|| 0) return v }), }) }) }, upData() { let channelItem = this.data.channel,key = this.data.select[this.data.select_act].proportionType;; Promise.all([ getImportantCustomer({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { let hard = (res[0] || []).harddata; let soft= (res[0] || []).softdata; this.setData({ DayList: hard.splice(0,10).map((v:any, i:number)=>{ v[key] = Number(v[key] || 0) v.feiyong = Number(v.feiyong|| 0) v.huanbi = Number(v.huanbi|| 0) return v }), DayList1: soft.splice(0,10).map((v:any, i:number)=>{ v[key] = Number(v[key]) v.huanbi = Number(v.huanbi|| 0) return v }), }) }) }, channelChange(event: wxPicker) { this.setData({ select_act: Number(event.detail.value) }, () => this.upData()) }, }, }) }