ItemPay.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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, 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 money = 0;
  12. private gold = 0;
  13. protected onLoad(){
  14. UtilsPanel.getAllNeedCom(this, this.node, false);
  15. UtilsPanel.addBtnEvent(this.node, this.onClick, this);
  16. }
  17. public init(data:any, index: number, p0?: any): void {
  18. let p = Pay.data_shop;
  19. if(index == p.DefaultPrice.length){
  20. this.money = -1;
  21. this.lb_count.string = "أدخل المبلغ";
  22. }
  23. else{
  24. this.money = p.DefaultPrice[index];
  25. this.gold = Pay.clacGold(this.money);
  26. this.lb_count.string = "" + this.gold;
  27. }
  28. if(index > 5)index = 5;
  29. UtilsPanel.setItemIcon(nav_info.bundle, "texture/1"+index+"/spriteFrame", this.sp_icon);
  30. }
  31. public onClick(){
  32. if(this.money == -1){
  33. nav_info.scene.showByUrl("prefab/paycustom");
  34. }
  35. else{
  36. game.emit("select_item", this.money, this.gold);
  37. }
  38. }
  39. }