// components/toufang/index.ts namespace shiduan { const { line, upLine } = require("./F2"); let { getHour } = 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() { first && this.init() first = false }, /** * 组件的初始数据 */ data: { onInitChart: undefined, DayList: {}, select_act: 0, select: [ { text: "费用", proportionType: "fee", type: 3, unit: "元", }, { text: "时长", proportionType: "timeSize", type: 2, unit: "分", }, { text: "频次", proportionType: "pinci", type: 1, unit: "次", }, { text: "客户量", proportionType: "customer", type: 4, unit: "个", }, ] }, /** * 组件的方法列表 */ methods: { init() { let channelItem = this.data.channel; let arrayItem = this.data.array; Promise.all([ getHour({ channelId: channelItem.channelId, order: this.data.select[this.data.select_act].type, end: arrayItem.endDate, start: arrayItem.startDate }), ]).then((res: adDay[]) => { this.data.DayList = res[0]; this.setData({ onInitChart: line.bind(this) }) }) }, upData() { let channelItem = this.data.channel; let arrayItem = this.data.array; Promise.all([ getHour({ channelId: channelItem.channelId, order: this.data.select[this.data.select_act].type, end: arrayItem.endDate, start: arrayItem.startDate }), ]).then((res: adDay[]) => { this.data.DayList = res[0]; upLine.bind(this)() }) }, channelChange(event:wxPicker){ this.setData({ select_act: Number(event.detail.value) },()=>this.upData()) } } }) }