namespace zhouzoushi { const { line, upLine, clearchart } = require("./F2"); let { getLastWeekTrend } = 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() }, /** * 组件的初始数据 */ 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([ getLastWeekTrend({ type: this.data.select[this.data.select_act].type, industryId: channelItem.channelId, dataType: this.data.array.index }), ]).then((res: any[]) => { console.log(res[0]) let li = res[0] ? res[0] : { hardData: [], softData: [] } ; this.setData({ DayList: li, onInitChart: line.bind(this), }) }) }, upData() { let channelItem = this.data.channel; Promise.all([ getLastWeekTrend({ 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] : { hardData: [], softData: [] } ; this.setData({ DayList: li, },()=>{ upLine.bind(this)() }) }) }, channelChange(event: wxPicker) { this.setData({ select_act: Number(event.detail.value) }, () => this.upData()) }, } }) }