// packageH/schoolCompany/schoolCompanyBind/schoolCompanyBind.js
var app = getApp();
Page({

  /**
	 * 页面的初始数据
	 */
  data: {
    school_id: 0,
    detailInfo: {},
    status: 1
  },

  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function (options) {
    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] == 'school_id') {
            this.setData({
              school_id: chil_arr[1]
            });
          }
        }
      }
    }

    this.getDetails();

  },

  getDetails() {
    let {
      school_id
    } = this.data;
    let urlStr = app.getNetAddresss('plugin.school-company.api.school');
    app._postNetWork({
      url: urlStr,
      data: {
        school_id
      },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result != 1) return app.tips(res.msg);

        this.setData({
          detailInfo: res.data
        });
      }
    });
  },

  sendBtn() {
    let {
      school_id
    } = this.data;
    let urlStr = app.getNetAddresss('plugin.school-company.api.school.bind-school');
    app._postNetWork({
      url: urlStr,
      data: {
        school_id
      },
      success: (resdata) => {
        var res = resdata.data;
        app.tips(res.msg);
        if (res.result != 1) return;
        this.setData({
          status: 2
        });
      }
    });
  },

  gotoIndex() {
    wx.navigateTo({
      url: '/packageG/index/index',
    });
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
});