//签到界面脚本

cc.Class({
    extends: cc.Component,

    properties: {
        goldStacksTipsUI: cc.Node,  //领取奖励节点
        _data: null,
        shuru: cc.EditBox,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
    },

    onEnable: function(){
        if(this.node.getChildByName("xuanyao").getChildByName("gouxuan_on").active == false){
            this.node.getChildByName("xuanyao").getChildByName("gouxuan_on").active = true;
            this.node.getChildByName("xuanyao").getChildByName("gouxuan_off").active = false;    
        }    
    },

    init: function(data){
        this._data =data;
        console.log("签到签到签到签到签到签到签到",this._data);
    },

    //领取奖励
    onLingqu: function(){
        var self = this;
        if(this.node.getChildByName("xuanyao").getChildByName("gouxuan_on").active == true){
            //分享
            sdk.shareAppMessage({type:10,query:""});
            //埋点
            // sdk.setSceneEvent("签到","点击","领取按钮-已勾选炫耀一下",{},null);
        }else{
            //埋点
            // sdk.setSceneEvent("签到","点击","领取按钮-未勾选炫耀一下",{},null); 
        }

        sdk.Post(sdk.ip2+"/Sign/userSign",{"uid":sdk.getUser().uid},function(data){
        // sdk.Post(sdk.ip2+"/Sign/userSign?debugDate="+this.shuru.string,{"uid":sdk.getUser().uid},function(data){
            console.log(data);
            self.node.active = false;
            self.node.getChildByName("sure").active = true;
            self.node.getChildByName("lingqu").active = false;
            self.node.getChildByName("xuanyao").active = false;
            //签到领取奖励
            self.goldStacksTipsUI.getComponent("goldStacksTipsUI").init(self._Data,4,self._data);
            self.goldStacksTipsUI.active =true;
        });


    },

    //关闭签到面板
    onClose: function(){
        this.node.active = false;
        //显示投诉按钮
        cc.HQ.GameMgr.feedbackButtonShow();
    },
    
    //炫耀一下是否勾选
    onGouxuan: function(){
        if(this.node.getChildByName("xuanyao").getChildByName("gouxuan_off").active == true){
            this.node.getChildByName("xuanyao").getChildByName("gouxuan_off").active = false;
            this.node.getChildByName("xuanyao").getChildByName("gouxuan_on").active = true;
        }else{
            this.node.getChildByName("xuanyao").getChildByName("gouxuan_on").active = false;
            this.node.getChildByName("xuanyao").getChildByName("gouxuan_off").active = true;
        }
    }

    // update (dt) {},
});
