ItemPay.ts 988 B

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