// pages/storeManagement/storeManagement.js
let app = getApp();
Page({

  /**
	 * 页面的初始数据
	 */
  data: {
    shopName: '',
    storeName: "",
    number: '',
    money: '',
    dispatch_type_id: 2,
    goods_id: 408,
    store_id: 9,
    wait_adverts: []
  },

  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function(options) {
    var value = wx.getStorageSync('storeMessage');
    if (value.store_name) {
      this.setData({
        storeName: value.store_name,
        shopName: value.shop_name
      });
    }
    this.getData();
  },
  getData() {
    let that = this;
    let _wx_token = '';
    wx.showLoading({
      title: '加载中',
    });
    try {
      var value = wx.getStorageSync('wx_token');
      if (value) {
        _wx_token = value;
      }
    } catch (e) {
      console.log(e);
    }
    wx.request({
      url: app.getFrogproNetAddresss('plugin.store-cashier.frontend.app.cashier.statistic.index'),
      header: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Cookie': 'PHPSESSID=' + _wx_token
      },
      method: "get",
      success: function(resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            money: res.data.today.amount,
            number: res.data.today.count
          });
        } else {
          // wx.showToast({
          // 	title: res.msg,
          // 	icon: 'none',
          // 	duration: 1500
          // })
          console.error(res,'result != 1');
        }
        wx.hideLoading();
      },
      fail: function(res) {
        // wx.showToast({
        // 	title: res,
        // 	icon: 'none',
        // 	duration: 1500
        // })
        console.error(res,'请求错误');
      }
    });
  },
  /**
	 * 生命周期函数--监听页面初次渲染完成
	 */
  onReady: function() {

  },

  /**
	 * 生命周期函数--监听页面显示
	 */
  onShow: function() {

  },

  /**
	 * 生命周期函数--监听页面隐藏
	 */
  onHide: function() {

  },

  /**
	 * 生命周期函数--监听页面卸载
	 */
  onUnload: function() {
    wxfaceapp.postMsg({
      targetAppid: app.data.accept_message_id,
      content: JSON.stringify({
        bolshow: false,
        moneyBol: true
      }),
      success(res) {

      },
      fail(res) {
        // wx.showToast({
        // 	title: res.reply,
        // 	icon: 'none',
        // 	duration: 2000
        // })
      }
    });
  },

  /**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
  onPullDownRefresh: function() {

  },

  /**
	 * 页面上拉触底事件的处理函数
	 */
  onReachBottom: function() {

  },

  /**
	 * 用户点击右上角分享
	 */
  onShareAppMessage: function() {

  },
  gatheringBtn() {
    wx.navigateTo({
      url: '/packageC/frogpro/cashier_desk/cashier_desk'
    });
  },
  quitLogin() {
    wx.redirectTo({
      url: '/packageC/frogpro/backScreenlogin/backScreenlogin'
    });
  }
});
