cc.Class({
    extends: cc.Component,

    properties: {
        TopBtnImg_OnChecked: {
            default: null,
            type: cc.Texture2D,
            serializable: true,
        },
        TopBtnImg_UnChecked: {
            default: null,
            type: cc.Texture2D,
            serializable: true,
        },
        GoodsList_Diamonds: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        GoodsList_Tools: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        TopBtn_Diamond: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        TopBtn_Tools: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        PayPage: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        Tip_AfterPay: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        GoodsPriceList_Diamonds:null,
        GoodsPriceList_Tools:null,
    },

    OnActive()
    {

    },
    start () {
        this.GoodsPriceList_Diamonds=[
            {
                GoodsID: 0,
                GoodsPrice:1,
                GoodsNum:10
            },
            {
                GoodsID: 1,
                GoodsPrice:2,
                GoodsNum:20
            },
            {
                GoodsID: 2,
                GoodsPrice:3,
                GoodsNum:30
            },
            {
                GoodsID: 3,
                GoodsPrice:5,
                GoodsNum:80
            },
            {
                GoodsID: 4,
                GoodsPrice:10,
                GoodsNum:180
            },
            {
                GoodsID: 5,
                GoodsPrice:20,
                GoodsNum:500
            },
            ];
        this.GoodsPriceList_Tools=[
            {
                GoodsID: 0,
                GoodsName:'矿泉水',
                GoodsPrice:10,
                GoodsNum:1
            },
            {
                GoodsID: 1,
                GoodsName:'乳酸',
                GoodsPrice:20,
                GoodsNum:1
            }
        ]
    },
    //0钻石1道具
    ShopTypeOnChecked(event,customData){
        if(customData==0){
            this.TopBtn_Diamond.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_OnChecked);
            this.TopBtn_Tools.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_UnChecked);
            this.GoodsList_Diamonds.active = true;
            this.GoodsList_Tools.active = false;
        }else if(customData==1){
            this.TopBtn_Diamond.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_UnChecked);
            this.TopBtn_Tools.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_OnChecked);
            this.GoodsList_Diamonds.active = false;
            this.GoodsList_Tools.active = true;
        }
    },
    //钻石购买customData传回来GoodsID
    GoodsDiamondsPriceBtnOnClick(event,customData){
        for(var i = 0;i<this.GoodsPriceList_Diamonds.length;i++){
            if(customData == this.GoodsPriceList_Diamonds[i].GoodsID){
                var PayPageCtrl = this.PayPage.getComponent('PayPage');
                var Tip_AfterPayText = '钻石+'+this.GoodsPriceList_Diamonds[i].GoodsNum;
                PayPageCtrl.PayPageInit(Tip_AfterPayText,this.GoodsPriceList_Diamonds[i].GoodsPrice);
                this.PayPage.active = true;
            }
        }
    },
    //道具购买customData传回来GoodsID
    GoodsToolsPriceBtnOnClick(event,customData){
        for(var i = 0;i<this.GoodsPriceList_Tools.length;i++){
            if(customData == this.GoodsPriceList_Tools[i].GoodsID){
                var Tip_AfterPayText = this.GoodsPriceList_Tools[i].GoodsName+'+'+this.GoodsPriceList_Tools[i].GoodsNum;
                this.Tip_AfterPay.getChildByName('TipText').getComponent(cc.Label).string = Tip_AfterPayText;
                this.Tip_AfterPay.active = true;
                var animCtrl = this.Tip_AfterPay.getComponent(cc.Animation);
                animCtrl.play();
            }
        }
    },

});
