ShopItemAlert.js 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const JMAlertBase = require('JMAlertBase');
  2. cc.Class({
  3. extends: JMAlertBase,
  4. editor: {
  5. menu: 'Shop/ShopItemAlert'
  6. },
  7. properties: {
  8. shopItemPrefab: cc.Prefab,
  9. shopItemNode: cc.Node
  10. },
  11. reloadData(data) {
  12. this._data = data;
  13. this.initUI();
  14. },
  15. initUI () {
  16. if (!this._data) return;
  17. let itemNode = cc.instantiate(this.shopItemPrefab);
  18. let shopItemCtr = itemNode.getComponent('ShopItem');
  19. shopItemCtr.reloadData(this._data);
  20. shopItemCtr.enabelClick(false);
  21. this.shopItemNode.addChild(itemNode);
  22. },
  23. certainOnClicked () {
  24. let goldNum = G.BagMgr.getItemNumById(JMC.ITEM_ID.GOLD);
  25. if (goldNum < this._data.cost) {
  26. G.AppUtils.getSceneCtrl().addToast('金币不足,分解饰品可获得');
  27. }
  28. else {
  29. G.ShopMgr.requestShopBuyItem(this._data.config.id, 1);
  30. this.close();
  31. }
  32. }
  33. });