const utils = require('../../utils/util') const util = require('../../utils/util.js'); 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", startTime: '', endTime: '', storeId: '', storeName: '', orderSn: '', }, orderList: { status: '', }, dataStr: '', storeList: { id: '', storeName: '' }, selectH: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // this.bindOrderList(); this.bindStoreList(); this.submitSearch(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.setData({ ["searchParams.pageNo"]: 1, pullUpOn: true, loadding: false, orderList: [] }) this.bindOrderList() setTimeout(() => { wx.stopPullDownRefresh() }, 300); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { var that = this //只是测试效果,逻辑以实际数据为准 this.setData({ loadding: true, pullUpOn: true }) this.setData({ ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1 }) this.bindOrderList() }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, timePickerShow: function () { this.setData({ isPickerShow: true, isPickerRender: true, chartHide: true }); }, pickerHide: function () { this.setData({ isPickerShow: false, chartHide: false }); }, setPickerTime: function (val) { console.log(val); let data = val.detail; let startTime = utils.formatDate(data.startTime) let endTime = utils.formatDate(data.endTime) var et = endTime.split(" "); var entt = et[0]+" 23:59:59" this.setData({ ["searchParams.startTime"]: data.startTime, ["searchParams.endTime"]: data.entt, dataStr: startTime + " ~ " + entt }); this.data.searchParams.startTime = data.startTime; this.data.searchParams.entt = data.entt; }, bindStorePickerChange: function (e) { var item = this.data.storeList[e.detail.value] console.log(item) this.setData({ ['searchParams.storeId']: item.id, ['searchParams.storeName']: item.storeName }) this.data.searchParams.storeId = item.id; // this.data.searchParams.storeName }, showSearchModel: function () { this.setData({ selectH: 450, }) }, hideSearchModel: function () { this.setData({ selectH: 0 }) }, clearSearch() { this.setData({ ['searchParams.storeName']: '', ['searchParams.storeId']: '', ['searchParams.startTime']: '', ['searchParams.endTime']: '', dataStr: '', }) }, submitSearch() { if (this.data.searchParams.storeId === undefined) { this.data.searchParams.storeId = '' } if (this.data.searchParams.storeName === undefined) { this.data.searchParams.storeName = '' } this.setData({ selectH: 0, ["searchParams.pageNo"]: 1, pullUpOn: true, loadding: false, orderList: [] }) this.bindOrderList() }, bindOrderList() { var that = this if (this.data.searchParams.storeId === undefined) { this.data.searchParams.storeId = '' } if (this.data.searchParams.storeName === undefined) { this.data.searchParams.storeName = '' } util.request(util.api.orderListPage, that.data.searchParams, "GET", false, true, app.globalData.token).then((res) => { if (res.code == 200) { if (res.result.records.length > 0) { if (that.data.orderList.length > 0) { let list = that.data.orderList var records = res.result.records records.forEach(record => { list.push(record) }); that.setData({ orderList: list }) } else { that.setData({ orderList: res.result.records }) } } else { that.setData({ loadding: false, pullUpOn: false }) } } }).catch((res) => {}) }, bindStoreList() { var that = this util.request(util.api.storeList, that.searchParams, "GET", false, true, app.globalData.token).then((res) => { if (res.code == 200) { that.setData({ storeList: res.result, ['searchParams.storeId']: res.result.id, ['searchParams.storeName']: res.result.storeName }) } }).catch((res) => {}) }, searchOrder() { if (this.data.searchParams.storeId === undefined) { this.data.searchParams.storeId = '' } if (this.data.searchParams.storeName === undefined) { this.data.searchParams.storeName = '' } this.bindOrderList() }, inputedit: function (e) { let _this = this; let dataset = e.currentTarget.dataset; let value = e.detail.value; let name = dataset.name; _this.data[name] = value; _this.setData({ [name]: _this.data[name] }); }, toDetail(e) { const agentmoney = e.currentTarget.dataset.agentmoney?e.currentTarget.dataset.agentmoney:0 const areaAgentMoney = e.currentTarget.dataset.areaagentmoney?e.currentTarget.dataset.areaagentmoney:0 const storeCommission = e.currentTarget.dataset.storecommission?e.currentTarget.dataset.storecommission:0 var url = '/pages/order/detail/index?orderSn=' + e.currentTarget.dataset.id + '&agentMoney=' + agentmoney + '&areaAgentMoney=' + areaAgentMoney + '&storeCommission=' + storeCommission wx.navigateTo({ url: url }) }, })