123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- namespace pindaofenbu {
- const { line, upLine,clearchart } = require("./F2");
- const { line1, upLine1,clearchart1 } = require("./F21");
- let { getChannelDistribution } = 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()
- clearchart1()
- },
- /**
- * 组件的初始数据
- */
- data: {
- onInitChart: undefined,
- onInitChart1: undefined,
- DayList: {},
- DayList1: {},
- select_act: 0,
- select: [
- {
- text: "费用",
- proportionType: "kanlijia",
- type: 3,
- unit: "万元",
- },
- {
- text: "时长",
- proportionType: "timeSize",
- type: 2,
- unit: "分",
- },
- {
- text: "频次",
- proportionType: "pinci",
- type: 1,
- unit: "次",
- },
- ],
- },
- /**
- * 组件的方法列表
- */
- methods: {
- init() {
- let channelItem = this.data.channel;
- Promise.all([
- getChannelDistribution({
- type: this.data.select[this.data.select_act].type,
- industryId: channelItem.channelId,
- dataType: this.data.array.index
- }),
- ]).then((res: any[]) => {
- let harddata = res[0].harddata || [],
- softdata = res[0].softdata || [];
- let key = this.data.select[this.data.select_act].proportionType;
- this.setData({
- DayList1: softdata.map((v: any) => {
- v[key] = Number(v[key] || 0)
- return v
- }),
- DayList: harddata.map((v: any) => {
- v[key] = Number(v[key] || 0);
- return v
- }),
- onInitChart: line.bind(this),
- onInitChart1: line1.bind(this)
- })
- })
- },
- upData() {
- let channelItem = this.data.channel;
- Promise.all([
- getChannelDistribution({
- type: this.data.select[this.data.select_act].type,
- industryId: channelItem.channelId,
- dataType: this.data.array.index
- }),
- ]).then((res: any[]) => {
- let harddata = res[0].harddata || [],
- softdata = res[0].softdata || [];
- let key = this.data.select[this.data.select_act].proportionType;
- this.setData({
- DayList1: softdata.map((v: any) => {
- v[key] = Number(v[key] || 0)
- return v
- }),
- DayList: harddata.map((v: any) => {
- 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())
- },
- }
- })
- }
|