var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        isShow: true,
        currentTab: 1,
        points: [],
        record_b: '',
        record_g: '',
        record_e: '',
        user_id:'',
        current:1
    },

    swichNav: function (e) {
        var current = e.currentTarget.dataset.current
        this.setData({
            currentTab: current
        })
    },


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

        var share_id = options.userid;
        app.getUserInfo(function (userInfo) { }, share_id)

        //获取user_id
        // wx.request({
        //     url: app.globalData.hostname + 'Api/Api/getUserInfo',
        //     data: {
        //         openid: wx.getStorageSync('openid')
        //     },
        //     header: {
        //         'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
        //     },
        //     method: 'POST',
        //     success: function (res) {
                var user_id = wx.getStorageSync('openid');
                // var user_id = res.data.data.id

                //大转盘
                wx.request({
                    url: app.globalData.hostadmin + 'Game/wheel_winning_log',
                    // url: app.globalData.hostadmin + 'Api/BigWheel/winning_log',
                    data: {
                        user_id: user_id
                    },
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                    },
                    method: 'POST',
                    success: function (res) {
                        that.setData({
                            record_b: res.data.data
                        })
                    }
                })

                //刮刮卡
                wx.request({
                    url: app.globalData.hostadmin + 'Game/card_winning_log',
                    // url: app.globalData.hostname + 'Api/ScratchCard/winning_log',
                    data: {
                        user_id: user_id
                    },
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                    },
                    method: 'POST',
                    success: function (res) {
                        that.setData({
                            record_g: res.data.data
                        })
                    }
                })

                //砸金蛋
                wx.request({
                    url: app.globalData.hostadmin + 'Game/eggs_winning_log',
                    data: {
                        user_id: user_id
                    },
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                    },
                    method: 'POST',
                    success: function (res) {
                        that.setData({
                            record_e: res.data.data
                        })
                    }
                })
        //     },
        // })
    },


    //转发
    onShareAppMessage: function (res) {
        return {
            // title: '辣妈乐淘商城',
            path: '/pages/index/index?share=' + wx.getStorageSync('openid'),
            success: function (res) {
                //转发成功
            },
        }
    },

    //选项卡
    tabs:function (e) {
        var current = e.currentTarget.dataset.current
        this.setData({
            current: current
        })
    }
})