//试玩游戏脚本

cc.Class({
    extends: cc.Component,

    properties: {
        // lingjinbi:cc.Node,
        game_list:cc.Prefab,
        game_content:cc.Node,
        goldStacksTipsUI: cc.Node,  //领取奖励金币节点
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        var self = this;
        if (cc.sys.platform === cc.sys.WECHAT_GAME) {
            sdk.Post(sdk.ip2+"/tuijian/trylist",{"uid":sdk.getUser().uid},function(data){
                var move_down_arr = [];
                console.log("右边游戏",data);
                for(let i = 0;i<data.d.length;i++){
                    var gamePre = cc.instantiate(self.game_list);
                    gamePre.getComponent("gameList").init(data.d[i],self);
                    gamePre.parent = self.game_content;
                    if(gamePre.getComponent("gameList")._status == 1){
                        move_down_arr.push(gamePre);
                    }
                }
                for(let i = 0;i<move_down_arr.length;i++){
                    move_down_arr[i].getComponent("gameList").playingBtn.active = false;
                    move_down_arr[i].getComponent("gameList").startBtn.active = true;
                    self.game_content.insertChild(move_down_arr[i],self.game_content.childrenCount);
                }
                self.game_content.getComponent(cc.Layout).updateLayout();

            })
        }
    },

   
    onClose: function(){
        this.node.active = false;
    },

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