var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
      isShow: true,
      currentTab: 1,
      points:[],
      record:[],
  },

  swichNav: function (e) {
      var current = e.currentTarget.dataset.current
      this.setData({
          currentTab: current
      })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    console.log(options)
      wx.showLoading({
        title: '加载中',
      })
      var urls = options.zhuanpanurl;
      // 传到授权登录接口
      var u_openid = options.u_openid;
      app.getUserInfo(function (cb, userInfo) {
        that.setData({
          userInfo: userInfo,
        })
      }, u_openid)
      var that = this;
      //中奖纪录
      wx.request({
        // url: app.globalData.serverUrl + '/BigWheel/winning_log',//中奖纪录
        url: app.globalData.hostname + urls,//中奖纪录
        method: 'POST',
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        data: {
          user_id: wx.getStorageSync('users_id'),
          business_id: app.globalData.business_id
        },
        success: function (res) {
          console.log(res);
          that.setData({
            record:res.data.data,
          })
        },
          fail:function(res){},
          complete:function(res){
            wx.hideLoading()
          }             
      })
    
  },
  

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

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

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

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

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

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

  /**
     * 用户点击右上角分享
     */
  onShareAppMessage: function (res) {
    var userid = wx.getStorageSync('openId')
    // var userid = 1

    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: app.globalData.share_title,
      path: '/pages/index/index?u_openid=' + userid,
      success: function (res) {
        var pages = getCurrentPages()    //获取加载的页面
        var currentPage = pages[pages.length - 1]    //获取当前页面的对象
        //点击分享传进userid 截取userid 从onload拿到
        var url = currentPage.route + '?u_openid=' + userid;  //当前页面url
        console.log(url, '/pages/index/index?u_openid=' + userid);
      },
      fail: function (res) {
        // 转发失败
      },
    }
  },
})