
import { _decorator, Component, game, Label, Node, Sprite } from 'cc';
import { UtilsPanel } from '../../scene/script/UtilsPanel';
import { ViewItemPro } from '../../scene/script/components/ViewItemPro';
import { nav_info } from '../../scene/script/NavInfo';
import { ShopData } from './Pay';
const { ccclass } = _decorator;

@ccclass('ItemPay')
export class ItemPay extends ViewItemPro {

    private sp_icon: Sprite = null;
	private lb_count: Label = null;

    private index = null;
	protected onLoad(){
		UtilsPanel.getAllNeedCom(this, this.node, false);
        UtilsPanel.addBtnEvent(this.node, this.onClick, this);
	}

    public init(data:ShopData, index?: number, p?: any): void {
        if(index > 5)index = 5;
        this.index = index;
        this.lb_count.string = "" + data.Extra[0].Count;
        UtilsPanel.setItemIcon(nav_info.bundle, "texture/2"+index+"/spriteFrame", this.sp_icon);
    }

    public onClick(){
        game.emit("select_item", this.index);
    }
}
