var app = getApp()
var that=null
var sopenFrame=null
var areas = null;
Page( {
  data: {
    loadingHidden:false,
    IFDefault:true,
    loginurl:app.globalData.apiurl+"/gl.aspx?g=0&tt=0000000",
    userid:"",
    userpwd:"",
    userpwd0:"",
    hkdjye:0,
    hkjdye:0,
    hkksye:0,
    productcount:0,
    productcount0:0,
    fhordercount0:0,
    fhordercount1:0,
    fhordercount2:0,
    kdordercount0:0,
    kdordercount1:0,
    kdordercount2:0,
    ztordercount0:0,
    ztordercount1:0,
    ztordercount2:0,
  },
  onLoad: function() {
      that = this
      that.rdata()
    },rdata: function() {
      var userId = wx.getStorageSync("userId")
      var LoginId = wx.getStorageSync("LoginId")
      var userInfodata = wx.getStorageSync("userInfo")
      var userInfo = JSON.parse(userInfodata)
      wx.request({
        url: app.globalData.apiurl + "/xapiajax.ashx", 
        data: { 
          action:"getmybusinessdata",
           userId:(!userId?"":userId),
           LoginId:(!LoginId?"":LoginId)
        },
        method:"GET",
        dataType:"json", 
        success (res) { 
          if(res.data.status==1){
            that.setData({
              userid:res.data.zh,
              userpwd:res.data.mm,
              userpwd:res.data.mm,
              hkdjye:res.data.userInfo.hkdjye,
              hkjdye:res.data.userInfo.hkjdye,
              hkksye:res.data.userInfo.hkksye,
              productcount:res.data.productcount,
              productcount0:res.data.productcount0,
              fhordercount0:res.data.fhordercount0,
              fhordercount1:res.data.fhordercount1,
              fhordercount2:res.data.fhordercount2,
              kdordercount0:res.data.kdordercount0,
              kdordercount1:res.data.kdordercount1,
              kdordercount2:res.data.kdordercount2,
              ztordercount0:res.data.ztordercount0,
              ztordercount1:res.data.ztordercount1,
              ztordercount2:res.data.ztordercount2,
              loadingHidden:true
             })
          }
        }
        })
            
    },changeisDefault:function(e) {
      var ifdefault = e.detail.value
      that.setData({
        IFDefault:ifdefault
       })
    },oncopy0:function(e) {
      var font = e.currentTarget.dataset.id
      wx.setClipboardData({
        data: font,
        success: function (res) { 
          wx.showToast({
            title: "复制成功"
          })
        }
      })
    },onlog:function(e) {
      var id = e.currentTarget.dataset.id
      var userId = wx.getStorageSync("userId")
      var LoginId = wx.getStorageSync("LoginId")
      var userInfodata = wx.getStorageSync("userInfo")
      var ifdl=true;
      if(!userId||!LoginId){
            ifdl=false;
            wx.navigateTo({  
              url: "../login/index"
             })
      }
      if(ifdl){
          var t = e.currentTarget.dataset.id
              wx.navigateTo({  
                  url: "../mybalance/index?t=" + t
              }) 
        }
    },onproduct:function(e) {
      var id = e.currentTarget.dataset.id
      var userId = wx.getStorageSync("userId")
      var LoginId = wx.getStorageSync("LoginId")
      var userInfodata = wx.getStorageSync("userInfo")
      var ifdl=true;
      if(!userId||!LoginId){
            ifdl=false;
            wx.navigateTo({  
              url: "../login/index"
             })
      }
      if(ifdl){
          var t = e.currentTarget.dataset.id
              wx.navigateTo({  
                  url: "../myproducts/index?t=" + t
              }) 
        }
    },onorders:function(e) {
      var id = e.currentTarget.dataset.id
      var userId = wx.getStorageSync("userId")
      var LoginId = wx.getStorageSync("LoginId")
      var userInfodata = wx.getStorageSync("userInfo")
      var ifdl=true;
      if(!userId||!LoginId){
            ifdl=false;
            wx.navigateTo({  
              url: "../login/index"
             })
      }
      if(ifdl){
          var index = e.currentTarget.dataset.index
          var id = e.currentTarget.dataset.id
              wx.navigateTo({  
                  url: "../myorder0/index?t=" + index + "&nav=" + id
              }) 
        }
    }
})
