// pages/cashier_stat/cashier_stat.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { language: '', is_hotel: false, hotel_id: '', store: { name: "", thumb: "", store_id: "" }, startDate: "", endDate: "", income: { money_total: 0.0, sure_withdraw_money: 0.0 }, stat: {}, integral:"", }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { console.log(wx.getStorageSync('integral')); let integral = ''; try { integral = wx.getStorageSync('integral'); } catch (error) { console.log(error); } this.setData({ integral: integral }); if (app._isTextEmpty(options.hotel_id)) { this.setData({ is_hotel: false }); this.getStoreInfo(); } else { this.setData({ is_hotel: true, hotel_id: options.hotel_id }); this.getHotelInfo(); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { let language = wx.getStorageSync('langIndex'); this.setData({ 'language': language.en}); }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }, getStoreInfo() { let that = this; let urlStr = app.getNetAddresss('plugin.store-cashier.frontend.cashier.center.index'); app._getNetWork({ url: urlStr, success: function(resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ store: res.data.store, income: res.data.income }); that.getStat(); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } }, fail: function(res) { console.log(res); } }); }, getStat(is_time) { let that = this; let urlStr = ''; if (!is_time) { is_time = 0; } if (app._isTextEmpty(this.data.hotel_id)) { urlStr = app.getNetAddresss('plugin.store-cashier.frontend.cashier.Statistics.index'); urlStr += "&store_id=" + that.data.store.store_id; urlStr += "&is_time=" + is_time; } else { urlStr = app.getNetAddresss('plugin.hotel.frontend.cashier.Statistics.index'); urlStr += "&hotel_id=" + that.data.hotel_id; urlStr += "&is_time=" + is_time; } app._getNetWork({ url: urlStr, success: function(resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ stat: res.data }); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } }, fail: function(res) { console.log(res); } }); }, getStatbtn() { this.getStat(1); }, getHotelInfo() { let that = this; let urlStr = app.getNetAddresss('plugin.hotel.frontend.cashier.center.index'); urlStr += '&hotel_id=' + this.data.hotel_id; app._getNetWork({ url: urlStr, success: function(resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ store: res.data.hotel }); that.getStat(); } }, fail: function(res) { console.log(res); } }); } });