const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        frameStyle: { useTop: true, name: '我的赛事', leftArrow: true, useBar: false },
        dialog: { title: '详细信息', show: false, type: '1' },
        // 选项卡
        tabs: {
            active: 'a',
            list: [
                { title: '小组赛', name: 'a' },
                { title: '淘汰赛', name: 'b' },

            ],
        },
        list: [
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            }, {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
            {
                match_time: '比赛时间',
                match_name: '比赛名称',
                grouping_name: '赛事组别',
                project_name: '组内项目',
                ground_name: '比赛场地',
            },
        ],
        // 详细信息
        info: {},
    },
    // 跳转菜单
    back(e) {
        wx.navigateBack({ delta: 1 })
    },
    // 选项卡
    tabsChange: function (e) {
        const that = this;
        const { name } = e.detail;
        that.setData({ 'tabs.active': name });
    },
    // 详细信息
    toView: async function (e) {
        const { item } = e.currentTarget.dataset;
        const that = this;
        that.setData({ info: item })
        that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
    },
    // 关闭弹框
    toClose: function () {
        const that = this;
        that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        const that = this;
        that.watchLogin();
    },
    // 监听用户是否登录
    watchLogin: async function () {
        const that = this;
        wx.getStorage({
            key: 'user',
            success: async res => {
                console.log(res);
            },
            fail: res => {
                wx.redirectTo({ url: '/pages/index/index', })
            }
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    }
})