// packageH/installationSever/installationSeverWrite/installationSeverWrite.js
var app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    take_sn: "",
    detailInfo: {},
    status: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.take_sn) {
      this.data.take_sn = options.take_sn;
    }
    if (options.scene) {
      let scene = decodeURIComponent(options.scene);
      console.log(scene);
      if (scene) {
        var info_arr = [];
        info_arr = scene.split("&");
        for (let i = 0; i < info_arr.length; i++) {
          let chil_arr = [];
          chil_arr = info_arr[i].split("=");
          console.log(chil_arr);
          if (chil_arr[0] == "take_sn") {
            this.setData({
              take_sn: chil_arr[1],
            });
          }
        }
      }
    }

    this.getDetails();
  },

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

  getDetails() {
    let { take_sn } = this.data;
    let urlStr = app.getNetAddresss("plugin.live-install.frontend.store-order.orderDetail");
    app._postNetWork({
      url: urlStr,
      data: { take_sn },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result != 1) return app.tips(res.msg);
        this.setData({ detailInfo: res.data });
      },
    });
  },

  sendBtn() {
    let { order_id } = this.data.detailInfo;
    let urlStr = app.getNetAddresss("plugin.live-install.frontend.store-order.takeOrder");
    app._postNetWork({
      url: urlStr,
      data: { order_id },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result != 1) return app.tips(res.msg);
        this.setData({ status: 2 });
      },
    });
  },

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

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

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

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

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

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