var a, t;

a = getApp(), t = require("../../utils/util.js"), Page({
    data: {
        list: a.globalData.xzwdata,
        hei: a.globalData.sheight,
        infodata: null,
        modalHidden: !1,
        showModalStatus: !1,
        mengshow: !1,
        bottom: "-100%",
        sharelayer: !1,
        sharebox: !1,
        sharemodal: !1,
        bot: "-100%",
        openSettingBtnHidden: !0,
        hide_qcode: 1,
        id: 1,
        name: "白羊座",
        currentTab: 0,
        tab: [ "今日", "明日", "本周", "本月", "今年", "爱情" ],
        userInfo: "",
        hasUserInfo: !1,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        show: !0,
        date: [],
        showTabs: !1
    },
    onLoad: function(e) {
        var o = this, s = this, n = s.options.id || s.data.id;
        if (isNaN(n)) {
            n = n.toLowerCase();
            for (var i = 0; i < s.data.list.length; i++) n == s.data.list[i].en.toLowerCase() && (n = i + 1);
        }
        var d = decodeURIComponent(this.options.scene);
        if (d) {
            var r = a._get(d, "id");
            r && (n = r), s.setData({
                id: n
            });
        }
        t.getData(n, s, "xz", function() {
            encodeURIComponent("id=" + n);
        }), a.globalData.userInfo ? this.setData({
            userInfo: a.globalData.userInfo,
            hasUserInfo: !0
        }) : this.data.canIUse ? a.userInfoReadyCallback = function(a) {
            o.setData({
                userInfo: a.userInfo,
                hasUserInfo: !0
            });
        } : wx.getUserInfo({
            success: function(t) {
                a.globalData.userInfo = t.userInfo, o.setData({
                    userInfo: t.userInfo,
                    hasUserInfo: !0
                });
            }
        }), s.data.infodata && drawImg.downImg(img_user, "user_" + s.data.userInfo.nickName);
    },
    swichNav: function(a) {
        var t = a.target.dataset.current;
        if (t || (t = a.detail.current + 1), this.data.currentTab === t - 1) return !1;
        this.setData({
            currentTab: t - 1,
            showTabs: !1
        });
    },
    changexz: function(a) {
        var e = this, o = a.currentTarget.dataset.index;
        if (o === e.data.id) return t.hideModal(e), !1;
        t.getData(o, e, "xz", function() {
            var a = "https://api.xzw.com/static/image/xcx/xz_" + o + ".png";
            drawImg.downImg(a, "xzimg_" + o);
            var t = "https://api.xzw.com/cp/wxcode?sid=2&hyaline=1&color=5566e4&scene=" + encodeURIComponent("id=" + o);
            drawImg.downImg(t, "qcode_" + o);
        }), t.hideModal(e, "showModalStatus", "mengshow", "bottom");
    },
    showModal: function() {
        t.showModal(this, "modalHidden", "showModalStatus", "mengshow", "bottom");
    },
    hideModal: function() {
        t.hideModal(this, "showModalStatus", "mengshow", "bottom");
    },
    showShareModal: function() {
        this.setData({
            showTabs: !1
        }), t.showModal(this, "sharebox", "sharemodal", "sharelayer", "bot");
    },
    hideShareModal: function() {
        t.hideModal(this, "sharemodal", "sharelayer", "bot");
    },
    getUserInfo: function(t) {
        console.log(t), a.globalData.userInfo = t.detail.userInfo, this.setData({
            userInfo: t.detail.userInfo,
            hasUserInfo: !0
        }), drawImg.downImg(t.detail.userInfo.avatarUrl, "user_" + t.detail.userInfo.nickName), 
        drawImg.setData({
            userInfo: t.detail.userInfo
        });
    },
    share: function() {
        var a = this;
        t.hideModal(a, "sharemodal", "sharelayer", "bot"), drawImg.setData({
            xzimg: wx.getStorageSync("xzimg_" + a.data.id),
            img_user: wx.getStorageSync("user_" + a.data.userInfo.nickName),
            qcode: wx.getStorageSync("qcode_" + a.data.id),
            userInfo: a.data.userInfo,
            desc: a.data.infodata[a.data.currentTab],
            currentTab: a.data.currentTab,
            xzname: a.data.name,
            date: a.data.date
        }), a.setData({
            hide_qcode: 0
        }), drawImg.draw(a);
    },
    closeQcode: function() {
        this.setData({
            hide_qcode: 1
        });
    },
    handleSetting: function(a) {
        a.detail.authSetting["scope.writePhotosAlbum"] && (this.setData({
            openSettingBtnHidden: !0
        }), drawImg.save_file(this));
    },
    inbtn: function(a) {
        console.log("in");
    },
    onShareAppMessage: function(a) {
        return "button" === a.from && console.log(a.target), {
            title: "星座运势详情",
            path: "/pages/fortune_astro/fortune_info?id=" + this.data.id,
            success: function(a) {},
            fail: function(a) {}
        };
    },
    showTabs: function() {
        var a = !this.data.showTabs;
        this.setData({
            showTabs: a
        });
    },
    hideTabs: function() {
        this.setData({
            showTabs: !1
        });
    }
});