
var app = getApp()
var that=null
var sopenFrame=null
Page( {
  data: {
    loadingHidden:false,
    orderpayHidden:true,
    topuser:{},
    musers:[],
    keyword:"",
    uid:0,
    dcid:0,
    topid:0,
    sycid:0
  },

  onLoad: function() {
      that = this
      that.rdata()
    
  },rdata: function() {
      var userId = wx.getStorageSync("userId")
      var LoginId = wx.getStorageSync("LoginId")
      wx.request({
        url: app.globalData.apiurl + "/xapiajax.ashx", 
        data: { 
           action:"getmynetmap",
           keyword:that.data.keyword,
           id:that.data.uid,
           userId:(userId==null?"":userId),
           LoginId:(LoginId==null?"":LoginId)
        },
        method:"GET",
        dataType:"json", 
        header: { 
          "content-type": "application/json" // 默认值
        }, 
        success (res) { 
    
            if(res.data.status==1){
              if(res.data.topuser.dcid!=-1){
                that.setData({
                     dcid:res.data.topuser.dcid
                })
              }
              that.setData({
                  topid:res.data.topuser.id,
                  sycid:res.data.sycid,
                  keyword:res.data.topuser.UserName,
                  topuser: res.data.topuser,
                  musers: res.data.muser,
                  loadingHidden:true
              })

            }else{
              wx.showToast({
                title: res.data.msg,
                icon: "none",
                duration: 3000
             })
            }
          }
      })
    },getkeyword:function(e) {
      var keyword = e.detail.value
      that.setData({
           keyword:keyword
      })
    },onsearch:function(e) {
      that.setData({
         uid:0
      })
      that.rdata()
  },zhiding:function(e) {
      if(that.data.dcid==that.data.topid)
      {
          wx.showToast({
              title: "已经是最高代数了",
              icon: "none",
              duration: 3000
          })
      }else{
          that.setData({
              uid:0,
              keyword:""
           })
           that.rdata()
      }
  },topsyc:function(e) {
    if(that.data.dcid==that.data.topid)
    {
        wx.showToast({
            title: "已经是最高代数了",
            icon: "none",
            duration: 3000
        })
    }else{
        that.setData({
            uid:that.data.sycid,
            keyword:""
         })
         that.rdata()
    }
},onsettop:function(e) {
  var id=e.currentTarget.dataset.id
       that.setData({
          uid:id,
          keyword:""
       })
       that.rdata()
  
},ondetail:function(e) {
  var id = e.currentTarget.dataset.id
  wx.navigateTo({  
    url: "../details/index?id=" + id
   })
}
})
