// packageE/others/application_market/binding_site/binding_site.js
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    plugin_id: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.checkdata();
    if (options.plugin_id) {
      this.setData({
        plugin_id: options.plugin_id,
      });
    }
  },
  toChange(e) {
    let str = e.currentTarget.dataset.new;
    if (str == "new") {
      wx.navigateTo({
        url:
          "/packageE/others/application_market/change_site/change_site?isNew=1&plugin_id=" +
          this.data.plugin_id,
      });
    } else {
      wx.navigateTo({
        url:
          "/packageE/others/application_market/change_site/change_site?plugin_id=" +
          this.data.plugin_id,
      });
    }
  },
  checkdata() {
    let url = "plugin.product-market.api.client.index";
    if (this.data.plugin_id == 58) {
      url = "plugin.market-sub.api.client.index";
    }
    let urlStr = app.getNetAddresss(url);
    app._getNetWork({
      url: urlStr,
      data: {},
      success: function (resdata) {
        var res = resdata.data;
        if (res.result != 1) {
          wx.showModal({
            title: "提示",
            content: res.msg,
            showCancel: false,
            success(res) {
              if (res.confirm) {
                wx.navigateBack({
                  delta: 1,
                });
              }
            },
          });
        }
      },
      fail: function (res) {
        console.log(res);
      },
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

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

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

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

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

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

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