123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- namespace quanpanqushi {
- const { line, upLine } = require("./F2");
- const { line1, upLine1 } = require("./F21");
- let { getMarket } = require('../../../../utils/api')
- let first = true;
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- array: {
- type: Object
- },
- channel: {
- type: Object
- },
- },
- observers: {
- 'array': function () {
- !first && this.upData()
- !first && this.upData1()
- },
- 'channel': function () {
- !first && this.upData()
- !first && this.upData1()
- },
- },
- ready() {
- this.init();
- first = false;
- },
- /**
- * 组件的初始数据
- */
- data: {
- onInitChart: undefined,
- onInitChart1: undefined,
- DayList: {},
- DayList1: {},
- select_act: 0,
- select: [
- {
- text: "费用",
- proportionType: "fee",
- type: 3,
- unit: "元",
- },
- {
- text: "时长",
- proportionType: "timeSize",
- type: 2,
- unit: "分",
- },
- {
- text: "频次",
- proportionType: "pinci",
- type: 1,
- unit: "次",
- },
- ],
- select_act1: 0,
- select1: [
- {
- text: "时长",
- proportionType: "timeSize",
- type: 2,
- unit: "分",
- },
- {
- text: "频次",
- proportionType: "pinci",
- type: 1,
- unit: "次",
- },
- ]
- },
- /**
- * 组件的方法列表
- */
- methods: {
- init() {
- let channelItem = this.data.channel;
- Promise.all([
- getMarket({
- dataType: this.data.select[this.data.select_act].type,
- indexTime: this.data.array.index,
- tableType: 1
- }),
- getMarket({
- dataType: this.data.select[this.data.select_act].type,
- indexTime: this.data.array.index,
- tableType: 2
- }),
- ]).then((res: any[]) => {
- let li = res[0] || []
- let list: adDay = {
- before: [],
- now: []
- }, beforeKey = li[0].linkType, key = this.data.select[this.data.select_act].proportionType;
- for (let i = 0; i < li.length; i++) {
- const v = li[i];
- v[key] = Number(v[key] || 0)
- v.linkType === beforeKey ? list.before.push(v) : list.now.push(v)
- }
-
- let li1 = res[1] || []
- let list1: adDay = {
- before: [],
- now: []
- }, beforeKey1 = li1[0].linkType, key1 = this.data.select1[this.data.select_act1].proportionType;
- for (let i = 0; i < li1.length; i++) {
- const v = li1[i];
- v[key1] = Number(v[key1] || 0)
- v.linkType === beforeKey1 ? list1.before.push(v) : list1.now.push(v)
- }
- this.setData({
- DayList1: list1,
- DayList: list,
- onInitChart: line.bind(this),
- onInitChart1: line1.bind(this)
- })
- })
- },
- upData() {
- let channelItem = this.data.channel;
- Promise.all([
- getMarket({
- dataType: this.data.select[this.data.select_act].type,
- indexTime: this.data.array.index,
- tableType: 1
- }),
- ]).then((res: any[]) => {
- let li = res[0] || []
- let list: adDay = {
- before: [],
- now: []
- }, beforeKey = li[0].linkType, key = this.data.select[this.data.select_act].proportionType;
- for (let i = 0; i < li.length; i++) {
- const v = li[i];
- v[key] = Number(v[key] || 0)
- v.linkType === beforeKey ? list.before.push(v) : list.now.push(v)
- }
- this.setData({
- DayList: list,
- },()=>{
- upLine.bind(this)()
- })
- })
- },
- upData1() {
- Promise.all([
- getMarket({
- dataType: this.data.select[this.data.select_act].type,
- indexTime: this.data.array.index,
- tableType: 2
- }),
- ]).then((res: any[]) => {
- let li = res[0] || []
- let list: adDay = {
- before: [],
- now: []
- }, beforeKey = li[0].linkType, key = this.data.select1[this.data.select_act1].proportionType;
- for (let i = 0; i < li.length; i++) {
- const v = li[i];
- v[key] = Number(v[key] || 0)
- v.linkType === beforeKey ? list.before.push(v) : list.now.push(v)
- }
- this.setData({
- DayList1: list,
- },()=>{
- upLine1.bind(this)()
- })
- })
- },
- channelChange(event: wxPicker) {
- this.setData({
- select_act: Number(event.detail.value)
- }, () => this.upData())
- },
- channelChange1(event: wxPicker) {
- this.setData({
- select_act1: Number(event.detail.value)
- }, () => this.upData1())
- }
- }
- })
- }
|