// packageD/auction/auctioneer-manage/password_change/password_change.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    switch1Checked:false,
    id: wx.getStorageSync('yz_uid'),
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  blackbtn(e){
    wx.navigateBack({
      detail:1
    });
  },
  switch1Change(e){
    console.log(e);
    this.setData({
      switch1Checked: e.detail
    });
    var that = this;
    let urlStr = app.getNetAddresss('plugin.auction.api.index.getAuctionData');
    let json={
      status:that.data.switch1Checked?'1':'0',
      art:'updateStatus'
    };
    app._getNetWork({
      url: urlStr,
      data:json,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          if(res.data.updateStatus == '修改成功'){
            that.setData({
              switch1Checked:that.data.switch1Checked
            });
          }else{
            wx.showToast({
              title: res.data.updateStatus,
              icon:'none',
              duration:1000
            });
          }
          
        } else {
          wx.showToast({
            title: res.msg,
            icon: "none",
            duration: 1000
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  toset(){
    wx.navigateTo({
      url: '/packageD/auction/auctioneer-manage/set_password/set_password',
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

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

  },

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

  },

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

  },

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

  },

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

  },
  getData(){
    var that = this;
    let urlStr = app.getNetAddresss('plugin.auction.api.index.getAuctionData');
    let json = {
      member_id: that.data.id,
    };
    app._postNetWork({
      url: urlStr,
      data: json,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          console.log(res);
          that.setData({
            status: res.data.getVerify.status,
            is_verify: res.data.getVerify.is_verify
          });
          if (that.data.is_verify == 0 && that.data.status == 1) {
            that.setData({
              switch1Checked: true
            });
          } else {
            that.setData({
              switch1Checked: false
            });
          }
        } else {
          wx.showToast({
            title: res.msg,
            icon: "none",
            duration: 1000
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  }
});