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 node_dis: Node = null; private lb_dis: Label = null; private data: RateInfo = null; protected onLoad(){ UtilsPanel.getAllNeedCom(this, this.node, true); 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); this.node_dis.active = data.ShowRate > 0; if(data.ShowRate > 0){ this.lb_dis.string = data.ShowRate + "%"; } 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); } }