ItemPay.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 node_dis: Node = null;
  13. private lb_dis: Label = null;
  14. private data: RateInfo = null;
  15. protected onLoad(){
  16. UtilsPanel.getAllNeedCom(this, this.node, true);
  17. UtilsPanel.addBtnEvent(this.node, this.onClick, this);
  18. }
  19. public init(data:RateInfo, index: number, p0?: any): void {
  20. this.data = data;
  21. this.lb_count.string = UtilsFormat.formatMoney(data.Gold);
  22. this.node_dis.active = data.ShowRate > 0;
  23. if(data.ShowRate > 0){
  24. this.lb_dis.string = data.ShowRate + "%";
  25. }
  26. if(index > 4)index = 4;
  27. UtilsPanel.setItemIcon(nav_info.bundle, "texture/1"+index+"/spriteFrame", this.sp_icon);
  28. }
  29. public onClick(){
  30. game.emit("select_item", this.data, this.node);
  31. }
  32. }