
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 { Pay, RateInfo, ShopData } from './Pay';
import { UtilsFormat } from '../../scene/script/UtilsFormat';
const { ccclass } = _decorator;

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

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

    private data: RateInfo = null;

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

    public init(data:RateInfo, index: number, p0?: any): void {
        this.data = data;
        this.lb_count.string = UtilsFormat.formatMoney(data.Gold);
        if(index > 4)index = 4;
        UtilsPanel.setItemIcon(nav_info.bundle, "texture/1"+index+"/spriteFrame", this.sp_icon);
    }

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