ItemPay.ts 914 B

123456789101112131415161718192021222324252627282930
  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 { Pay } from './Pay';
  5. const { ccclass } = _decorator;
  6. @ccclass('ItemPay')
  7. export class ItemPay extends ViewItemPro {
  8. private sp_icon: Sprite = null;
  9. private lb_count: Label = null;
  10. private data = null;
  11. protected onLoad(){
  12. UtilsPanel.getAllNeedCom(this, this.node, false);
  13. UtilsPanel.addBtnEvent(this.node, this.onClick, this);
  14. }
  15. public init(data: any, index?: number, p?: any): void {
  16. if(index > 5)index = 5;
  17. this.data = index;
  18. this.lb_count.string = "" + index * 1000;
  19. UtilsPanel.setItemIcon(Pay.bundle_name, "texture/2"+index+"/spriteFrame", this.sp_icon);
  20. }
  21. public onClick(){
  22. game.emit("select_item", this.data);
  23. }
  24. }