var a, t;

a = getApp(), t = require("../../utils/util.js"), Page({
    data: {
        sx: [ "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" ],
        array: [ "肖鼠", "肖牛", "肖虎", "肖兔", "肖龙", "肖蛇", "肖马", "肖羊", "肖猴", "肖鸡", "肖狗", "肖猪" ],
        maleid: 0,
        smaleid: 0,
        topNum: a.globalData.topNum
    },
    onLoad: function(a) {
        var t = this, o = a.maleid;
        if (o) {
            for (var n = 0; n < t.data.topNum.length; n++) o == t.data.topNum[n] && (o = n);
            this.setData({
                maleid: o,
                smaleid: o
            });
        }
        t.startPair(t.data.maleid);
    },
    bindPickerChange: function(a) {
        this.setData({
            smaleid: a.detail.value
        });
    },
    startPair: function(a) {
        this.setData({
            maleid: this.data.smaleid
        }), console.log("id", this.data.maleid), this.showInfo(parseInt(this.data.maleid) + 1);
    },
    showInfo: function(a) {
        var o = this;
        t.getPairTopData(o, "sx", a, function() {
            o.data.infodata, console.log("数据", o.data.infodata), o.dealArr(o.data.infodata);
        });
    },
    dealArr: function(a) {
        for (var t = 0; t < a.length; t++) {
            var o = a[t];
            o.female.cont = o.female.cont.substring(0, 30) + "...", o.male.cont = o.male.cont.substring(0, 30) + "...", 
            o.id = this.data.sx.findIndex(function(a) {
                return a == o.name;
            }) + 1;
        }
        this.setData({
            pairList: a
        });
    },
    scrollTop: function() {
        wx.pageScrollTo({
            scrollTop: 0,
            duration: 300
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function(a) {
        return "button" === a.from && console.log(a.target), {
            title: "生肖配对排行",
            path: "/pages/pairtop_sx/pairtop_sx?maleid=" + this.data.maleid
        };
    }
});