var t = getApp(), a = require("../../provider/dataApi.js");

require("../../provider/pipe.js");

Page({
    data: {
        statusBarHeight: "",
        titleBarHeight: "",
        typelist: [],
        total: 0,
        day_have_err: 2,
        all_have_err: 2
    },
    onLoad: function(t) {
        this.setData({
            statusBarHeight: getApp().globalData.statusBarHeight,
            titleBarHeight: getApp().globalData.titleBarHeight
        });
    },
    goToday: function() {
        t.globalData.op = "todayerr_question", wx.getStorageSync("uid") ? 2 == this.data.day_have_err ? wx.showToast({
            icon: "none",
            title: "今日无错题~"
        }) : wx.navigateTo({
            url: "../practice/practice"
        }) : wx.navigateTo({
            url: "../login/login"
        });
    },
    goAll: function() {
        t.globalData.op = "allerr_question", wx.getStorageSync("uid") ? 2 == this.data.all_have_err ? wx.showToast({
            icon: "none",
            title: "暂无错题~"
        }) : wx.navigateTo({
            url: "../practice/practice"
        }) : wx.navigateTo({
            url: "../login/login"
        });
    },
    goType: function(a) {
        wx.getStorageSync("uid") ? (t.globalData.op = "geterr_bytype", t.globalData.id = a.currentTarget.id, 
        wx.navigateTo({
            url: "../practice/practice"
        })) : wx.navigateTo({
            url: "../login/login"
        });
    },
    bindWechat: function() {
        wx.showModal({
            title: "绑定微信",
            content: "需要绑定微信才能进行下一步操作,点击确定去绑定",
            showCancel: !0,
            confirmText: "确定",
            success: function(t) {
                console.log(t), t.confirm && wx.navigateTo({
                    url: "../bindWechat/bindWechat"
                });
            }
        });
    },
    onShow: function() {
        this.getuserinfo(), this.myerrList();
    },
    getuserinfo: function() {
        a.userinfo({
            uid: wx.getStorageSync("uid"),
            op: "getinfo"
        }).then(function(t) {
            console.log(t), wx.setStorageSync("userinfo", t.data.info), wx.setStorageSync("http", t.data.http);
        }).catch(function(t) {
            console.log(t);
        });
    },
    myerrList: function() {
        var t = this;
        a.myerrList({
            uid: wx.getStorageSync("uid")
        }).then(function(a) {
            console.log(a), t.setData({
                total: a.data.total,
                typelist: a.data.typelist,
                day_have_err: a.data.day_have_err,
                all_have_err: a.data.all_have_err
            }), console.log(a.data.total);
        }).catch(function(t) {
            console.log(t);
        });
    },
    onShareAppMessage: function() {}
});