ItemPay.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { _decorator, Component, game, Label, Node, Sprite } from 'cc';
  2. import { UtilsPanel } from '../../scene/script/UtilsPanel';
  3. import { ViewItemPro } from '../../scene/script/components/ViewItemPro';
  4. import { nav_info } from '../../scene/script/NavInfo';
  5. import { Pay, RateInfo, ShopData } from './Pay';
  6. import { UtilsFormat } from '../../scene/script/UtilsFormat';
  7. const { ccclass } = _decorator;
  8. @ccclass('ItemPay')
  9. export class ItemPay extends ViewItemPro {
  10. private sp_icon: Sprite = null;
  11. private lb_count: Label = null;
  12. private data: RateInfo = null;
  13. protected onLoad(){
  14. UtilsPanel.getAllNeedCom(this, this.node, false);
  15. UtilsPanel.addBtnEvent(this.node, this.onClick, this);
  16. }
  17. public init(data:RateInfo, index: number, p0?: any): void {
  18. this.data = data;
  19. this.lb_count.string = UtilsFormat.formatMoney(data.Gold);
  20. if(index > 4)index = 4;
  21. UtilsPanel.setItemIcon(nav_info.bundle, "texture/1"+index+"/spriteFrame", this.sp_icon);
  22. }
  23. public onClick(){
  24. game.emit("select_item", this.data, this.node);
  25. }
  26. }