123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- // components/toufang/index.ts
- namespace kehuyoushi {
- let scrollType = 0;
- let { getDetail } = 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;
- },
- /**
- * 组件的初始数据
- */
- data: {
- onInitChart: undefined,
- DayList: {},
- timeout: undefined,
- scrollTop1: "",
- scrollTop2: "",
- // scrollTop1: 0,
- // scrollTop2: 0,
- 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([
- getDetail({
- channelId: channelItem.channelId,
- end: arrayItem.endDate,
- order: this.data.select[this.data.select_act].type,
- start: arrayItem.startDate
- }),
- ]).then((res: adDay[]) => {
- this.setData({
- DayList: res[0],
- })
- })
- },
- upData() {
- let channelItem = this.data.channel;
- let arrayItem = this.data.array;
- Promise.all([
- getDetail({
- channelId: channelItem.channelId,
- end: arrayItem.endDate,
- order: this.data.select[this.data.select_act].type,
- start: arrayItem.startDate
- }),
- ]).then((res: adDay[]) => {
- this.setData({
- DayList: res[0],
- })
- })
- },
- channelChange(event: wxPicker) {
- this.setData({
- select_act: Number(event.detail.value)
- }, () => this.upData())
- },
- dragEnd1(detail: any) {
- if (!this.data.DayList.now || !this.data.DayList.now.length || scrollType !== 0) return
- if (this.data.timeout) {
- clearTimeout(this.data.timeout);
- this.data.timeout = null;
- }
- this.data.timeout = setTimeout(() => {
- scrollType = 1;
- clearTimeout(this.data.timeout);
- this.data.timeout = null;
- let indiex = (detail.detail.scrollTop / 33).toFixed(0);
- let list = this.data.DayList.before[indiex] || {};
- let p = {
- scrollTop2: this.data.scrollTop2,
- scrollTop1: 'top' + indiex
- }
- for (let i = 0; i < this.data.DayList.now.length; i++) {
- const v = this.data.DayList.now[i];
- if (v.brand !== list.brand) continue
- // let ni = i - 2 > 0 ? i - 2 : 0
- p.scrollTop2 = 'bottom' + i
- // p.scrollTop2 = ni * 33
- break
- }
- this.setData(p)
- scrollType = 0
- }, 300);
- },
- dragEnd2(detail: any) {
- if (!this.data.DayList.now || !this.data.DayList.now.length || scrollType !== 0) return
- if (this.data.timeout) {
- clearTimeout(this.data.timeout);
- this.data.timeout = null;
- }
- console.log(this.data.timeout)
- this.data.timeout = setTimeout(() => {
- scrollType = 2;
- clearTimeout(this.data.timeout);
- this.data.timeout = null;
- let index = (detail.detail.scrollTop / 33).toFixed(0);
- let list = this.data.DayList.now[index] || {};
- let p = {
- scrollTop1: this.data.scrollTop1,
- scrollTop2: 'bottom' + index
- }
- for (let i = 0; i < this.data.DayList.before.length; i++) {
- const v = this.data.DayList.before[i];
- if (v.brand !== list.brand) continue
- console.log(v.brand)
- // let ni = i - 2 > 0 ? i - 2 : 0
- // p.scrollTop1 = ni * 33
- p.scrollTop1 = 'top' + i
- break
- }
- this.setData(p)
- scrollType = 0
- }, 300)
- },
- }
- })
- }
|