// pages/saleOutStore/outStoreDetail/outStoreDetail.js

var network = require("../../../utils/net.js");

Page({
  data: {
    dataArr : [ ],
    balance : 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that =this;
    var detailItemID = parseInt(options.detailItemID);
    let arrayLast = [];
    let totalMoney = 0;
    let method = '/MainSystem/B3MiniProgramRpc/Rpcs/CustomerRpc/SaleOutStoreRpc/GetSaleOutStoreDetail';
    let params = [detailItemID];
    network.transfer_request(method, params, function (res) {
      var array = res.result;
      for (var i = 0; i < array.length; i++) {
        if (array[i].Money) {
          totalMoney = totalMoney + parseFloat(array[i].Money);
        }
        var dmo = {
          goodsName: array[i].Goods_Name,
          goodsMoney: array[i].Money,
          goodsNum: array[i].Number,
          goodsPrice: array[i].Price,
        }
        arrayLast.push(dmo);
      }
      if (!totalMoney){
        totalMoney = 0;
      }
      that.setData({
        dataArr : arrayLast,
        balance : totalMoney,
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

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

  },

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

  },

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

  }
})