DebuguAlert.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const JMAlertBase = require('JMAlertBase');
  2. cc.Class({
  3. editor: {
  4. menu: 'Debug/DebugAlert'
  5. },
  6. extends: JMAlertBase ,
  7. properties: {
  8. itemIdEB: cc.EditBox,
  9. itemNumEB: cc.EditBox,
  10. goodsIdEB: cc.EditBox,
  11. },
  12. onLoad () {
  13. this._super();
  14. },
  15. onEnable () {
  16. this._super();
  17. },
  18. onDisable () {
  19. cc.game.targetOff(this);
  20. this._super();
  21. },
  22. reloadData (data, cb) {
  23. },
  24. debuguItemAddOnClicked() {
  25. if (this.itemIdEB.string.length == 0) {
  26. return;
  27. }
  28. let itemid = parseInt(this.itemIdEB.string);
  29. let num = this.itemNumEB.string.length == 0 ? 1 : parseInt(this.itemNumEB.string);
  30. this.requestAddItems([
  31. {
  32. id: itemid,
  33. count: num
  34. }
  35. ]);
  36. },
  37. debuguGoodsBuyOnClicked() {
  38. if (this.goodsIdEB.string.length == 0) {
  39. return;
  40. }
  41. let goodid = parseInt(this.goodsIdEB.string);
  42. G.PayMgr.payGoods(goodid, true);
  43. },
  44. requestAddItems (items) {
  45. let uid = G.UserMgr.getUid();
  46. if (!uid) return;
  47. let info = {
  48. uid: uid,
  49. items: items
  50. };
  51. G.NetworkMgr.sendSocketRequest('test_add_items', info, this.responseAddItems.bind(this));
  52. },
  53. responseAddItems (data) {
  54. let requestInfo = data.requestInfo;
  55. let responseInfo = data.responseInfo;
  56. if (responseInfo.code === 200) {
  57. for (const item of requestInfo.items) {
  58. if (item.count > 0) {
  59. G.AppUtils.getSceneCtrl().addToast('获得: ' + item.id + "&&数量:" + item.count);
  60. }
  61. if (item.count < 0) {
  62. G.AppUtils.getSceneCtrl().addToast('删除: ' + item.id + "&&数量:" + Math.abs(item.count));
  63. }
  64. }
  65. }
  66. },
  67. });