// packageH/superior_payment/superiorPaymentDetails/superiorPaymentDetails.js
var app = getApp();
let plugin_name="上级代付";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    details: {},
    goodList: [],
    totalNum: 0,
    totalPrice: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.id && options.id != 0) {
      this.getDetails();
    } else app.tips("参数错误");

  },

  getDetails(id) {
    let urlStr = app.getNetAddresss('plugin.parent-payment.frontend.modules.payment.controllers.detail.index');
    app._postNetWork({
      url: urlStr,
      data: {
        record_id: id
      },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result != 1) return app.tips(res.msg);

        let goodList = res.data.order_goods;
        let total = 0;
        goodList.forEach(item => {
          total += item.total;
        });
        this.setData({
          details: res.data,
          totalPrice: res.data.price,
          goodList,
          totalNum: total
        });
        wx.setNavigationBarTitle({
          title: res.data.plugin_name || plugin_name,
        });

      }
    });
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
});