var app = getApp(); const config = require('../../config/config.js') const util = require('../../utils/util.js') const Http = require('../../utils/HttpBasics.js') Page({ data: { data: { list: [] }, //数据 crollTop: 0, scrollHeight: 0, house_type: 0, //户型 house_style: 0, //风格 house_area: 0, //面积 flagdate: null, list: [], tabTxt: [{ title: '全部', idss: 0 }, { title: '日期', idss: 1 }, // { // title: '类型', // idss: 2 // }, { title: '状态', idss: 3 }, // { // title: '来源', // idss: 4 // } ], showList: null, loading: "", tab: [true, true, true, true, true], disabled: false, //加载更多按钮状态 page: 1, //当前页码 hasMore: false, //加载更多按钮 moreTxt: '点击加载更多', dataNull: true, status: '', type: '', source: '', date: "", date2: "", idss: 0, subsidy: '', pageNum: 1, //第几页 height: null, statustypes: [ { name: '进行中', status: 1, id: 1 }, { name: '已过期', status: 3, id: 3 }, { name: '未开始', status: 4, id: 4 } ], starttime: null, endtime: null, billTypeValue: null }, // 选项卡 filterTab: function (e) { let that = this; console.log(e); that.setData({ loading: "" }) that.setData({ idss: e.target.dataset.idss || e.currentTarget.dataset.idss, pageNum: 1 }) if (e.currentTarget.dataset.idss === 0) { this.setData({ source: '', type: '', status: '', date: '', date2: '' }) this.getList(1) this.getTotleData() } var data = [true, true, true, true, true], index = e.currentTarget.dataset.index; data[index] = !that.data.tab[index]; that.setData({ tab: data }) }, bindDateChange1: function (e) { if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()) { wx.showToast({ title: '抱歉,开始日期不能大于结束日期', icon: 'none', duration: 2000, mask: false }); return; } this.setData({ date: e.detail.value, }) }, bindDateChange2: function (e) { if (new Date(e.detail.value).getTime() < new Date(this.data.date).getTime()) { wx.showToast({ title: '抱歉,结束日期不能小于开始日期', icon: 'none', duration: 2000, mask: false }); return; } this.setData({ date2: e.detail.value }) }, search(e) { console.log(e.currentTarget.dataset.ids) let type = e.currentTarget.dataset.ids; if (type == 0) { this.setData({ source: '', type: '', status: '', date: '', date2: '' }) } else if (type == 1) { if (!this.data.date) { wx.showToast({ title: '抱歉请选择开始日期', icon: 'none', duration: 2000, mask: false }); return; } else if (!this.data.date2) { wx.showToast({ title: '抱歉请选择结束日期', icon: 'none', duration: 2000, mask: false }); return; } } else if (type == 2) { this.setData({ type: e.currentTarget.dataset.id }) } else if (type == 3) { console.log(e.currentTarget.dataset.id) this.setData({ status: e.currentTarget.dataset.id }) } else if (type == 4) { this.setData({ source: e.currentTarget.dataset.id }) } var data = [true, true, true, true, true]; this.setData({ tab: data }) this.getList(1) this.getTotleData() }, onShow() { this.getList(1) this.getTotleData() }, formatData(data) { let arr = []; data.map((item, index) => { let a = {}; a.value = [item]; a.dateR = item.createDate01; let indexSt = 0; let haveIf = false; console.log(item, this.data.auditWayOptions, 1111) console.log(item.sourceStr, item.typeStr, item.statusStr, 222) arr.map((item01, index01) => { if (item.id == item01.id) { indexSt = index01; haveIf = true; } }) if (haveIf && (new Date(item.createDate)).valueOf() >= (new Date(this.data.date + ' 00:00:00')).valueOf() && (new Date(item.createDate)).valueOf() <= (new Date(this.data.date2 + ' 23:59:59')).valueOf()) { arr[indexSt].value.push(item) } else if ((new Date(item.createDate)).valueOf() >= (new Date(this.data.date + ' 00:00:00')).valueOf() && (new Date(item.createDate)).valueOf() <= (new Date(this.data.date2 + ' 23:59:59')).valueOf()) { arr.push(a) } }) this.setData({ allBillList: arr }) console.log(arr, 888888888888) }, getTotleData() { let _this = this; Http.get({ url: config.api.getSubsidySummary, data: { startdate: this.data.date ? this.data.date + " 00:00:00" : '', enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '', source: this.data.source, type: this.data.type, status: this.data.status } }) .then(res => { _this.setData({ subsidy: Number(Number(res.data.subsidy) / 100).toFixed(2) }) wx.stopPullDownRefresh(); }) .catch(err => { wx.stopPullDownRefresh(); wx.showToast({ title: err.message, icon: 'none', duration: 2000, mask: false }); }); }, getList: function (page) { let _this = this; Http.get({ url: config.api.cashbackList, data: { pageNum: page, pageSize: 10, begin: this.data.date ? this.data.date + " 00:00:00" : '', enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '', status: this.data.status } }) .then(res => { wx.stopPullDownRefresh(); let data = res.data.list; let allBillList = []; if (page == 1) { allBillList = res.data.list; } else { allBillList = _this.data.allBillList; } allBillList.map((item, index) => { let haveIf = false; item.startDate = util.formatTime(item.startTime, 'yyyy-MM-dddd') item.endDate = util.formatTime(item.endTime, 'yyyy-MM-dddd') // hh:mm:ss item.statusStr = this.data.statustypes.find(e => e.status === item.status)?.name item.isStart = item.startTime > new Date().getTime() if (item.startTime > new Date().getTime()) { item.startBtn = '活动未开始' item.startFlag = 0 } else if (item.endTime < new Date().getTime()) { // item.startBtn = '活动已结束' // item.startFlag = 1 item.startBtn = '参加活动' item.startFlag = 2 } else { item.startBtn = '参加活动' item.startFlag = 2 } }) if (res.data.pages <= page) { _this.setData({ allBillList, pageNum: res.data.pages - 1, content: '已经加载全部数据!' }) } else { _this.setData({ allBillList, loading: false, content: '小主,我在玩命加载中...' }) } }) .catch(err => { wx.stopPullDownRefresh(); wx.showToast({ title: err.message, icon: 'none', duration: 2000, mask: false }); }); }, onPullDownRefresh: function (e) { let that = this; that.setData({ pageNum: 1, list: [] }); that.getList(1); this.getTotleData() }, onReachBottom() { var that = this; that.data.pageNum++; that.setData({ pageNum: that.data.pageNum, loading: true }); that.getList(that.data.pageNum); this.getTotleData() }, viewDetail(e) { let id = e.currentTarget.dataset.id let flag = e.currentTarget.dataset.flag if (flag === 2) { wx.navigateTo({ url: `/pages/cashContent/cashContent?id=${id}`, }) } } });