const utils = require('../../utils/util') const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isPickerRender: false, isPickerShow: false, pickerConfig: { endDate: true, dateLimit: true, initStartTime: "2020-01-01", initEndTime: "2020-12-01", limitStartTime: "2015-01-01", limitEndTime: "2095-01-01", }, searchParams: { startTime: "2019-01-01 ", endTime: "2019-12-01", pageNo: 1, pageSize: 10, createTime_begin:"", createTime_end:"", tradingStatus:0, storeName:"" }, dataStr: '', totalAmount:0, loadding: false, pullUpOn: true, list:[], }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.setData({ ["searchParams.pageNo"]: 1, pullUpOn: true, loadding: false, list: [] }) this.getList() setTimeout(() => { wx.stopPullDownRefresh() }, 300); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { //只是测试效果,逻辑以实际数据为准 let that = this; this.setData({ loadding: true, pullUpOn: true }) this.setData({ ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1 }) this.getList() }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, timePickerShow: function () { this.setData({ isPickerShow: true, isPickerRender: true, chartHide: true }); }, pickerHide: function () { this.setData({ isPickerShow: false, chartHide: false }); }, setPickerTime: function (val) { let data = val.detail; let startTime = utils.formatDate(data.startTime,'yyyy-MM-dd') let endTime = utils.formatDate(data.endTime,'yyyy-MM-dd') this.setData({ ["searchParams.startTime"]: data.startTime, ["searchParams.endTime"]: data.endTime, dataStr: startTime +" ~ "+ endTime, ["searchParams.createTime_begin"]: data.startTime, ["searchParams.createTime_end"]: data.endTime, list:[] }); this.getList(); }, getList() { var that = this utils.request(utils.api.withdrawList, that.data.searchParams, "GET", true, false, app.globalData.token).then((res) => { if (res.code == 200) { console.log(res) if (res.result.records.length > 0) { if (that.data.searchParams.pageNo > 0) { let list = that.data.list res.result.records.forEach((e)=>{ list.push(e) }) that.setData({ list: list }) }else{ that.setData({ list: res.result.records }) } } else { that.setData({ loadding: false, pullUpOn: false, ["searchParams.pageNo"]:that.data.searchParams.pageNo-1 }) } var allList = that.data.list; var allNumber = 0; for (let i = 0; i < allList.length; i++) { allNumber+=allList[i].number==null?0:allList[i].number; } that.setData({ totalAmount: allNumber.toFixed(2), }) } }).catch((res) => {}) }, })