require("../../49539051658710DF2F35F8564970FAA0.js");

var e = getApp(), i = wx.cloud.database();

i.command, i.command.aggregate;

Page({
    data: {},
    onLoad: function(t) {
        var a = this, n = [ {
            url: "/pages/more/authorize/authorize",
            title: "授权微信登录",
            iconSrc: "/images/icons/intro.png",
            note: "登录或更新昵称和头像"
        }, {
            url: "/pages/more/guide/guide",
            title: "使用指南",
            iconSrc: "/images/icons/intro.png",
            note: "联系客服"
        }, {
            url: "",
            title: "不显示比赛示例",
            iconSrc: "/images/icons/intro.png",
            note: ""
        }, {
            url: "/pages/more/intro/intro",
            title: "关于赛易评",
            iconSrc: "/images/icons/intro.png",
            note: ""
        } ];
        i.collection("competitions").where({
            _id: "example",
            focus: e.globalData.openid
        }).count().then(function(e) {
            0 == e.total && n.splice(2, 1), a.setData({
                listMenu: n
            });
        });
    },
    onShow: function(e) {
        var t = this;
        i.collection("users").where({
            _openid: wx.getStorageSync("openid")
        }).field({
            nickName: !0,
            avatarUrl: !0,
            vipExpiryTime: !0,
            vipType: !0
        }).get().then(function(e) {
            var i = e.data[0];
            if (i.nickName) {
                t.setData({
                    userInfo: {
                        nickName: i.nickName,
                        avatarUrl: i.avatarUrl
                    },
                    authorized: !0
                });
                var a = new Date();
                "specialVip" != i.vipType && a < i.vipExpiryTime && t.setData({
                    vipExp: i.vipExpiryTime.getFullYear() + "年" + (i.vipExpiryTime.getMonth() + 1) + "月" + i.vipExpiryTime.getDate() + "日"
                });
            } else t.setData({
                authorized: !1
            });
        }).catch(function(e) {
            console.log(e);
        });
    },
    navigateToAuthorization: function(e) {
        wx.navigateTo({
            url: "/pages/more/authorize/authorize?page=more"
        });
    },
    viewVipExp: function(e) {
        var i = this.data.vipExp;
        i && wx.showActionSheet({
            itemList: [ "VipExp：" + i ],
            success: function(e) {},
            fail: function(e) {}
        });
    },
    onShareAppMessage: function() {
        return {
            title: "我发现了一款高效好用的比赛评分小程序",
            path: "/pages/index/index",
            imageUrl: "/images/sharePic.png"
        };
    }
});