DebuguAlert.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. },
  11. onLoad () {
  12. this._super();
  13. },
  14. onEnable () {
  15. this._super();
  16. },
  17. onDisable () {
  18. cc.game.targetOff(this);
  19. this._super();
  20. },
  21. reloadData (data, cb) {
  22. },
  23. debuguItemAddOnClicked() {
  24. if (this.itemIdEB.string.length == 0) {
  25. return;
  26. }
  27. let itemid = parseInt(this.itemIdEB.string);
  28. let num = this.itemNumEB.string.length == 0 ? 1 : parseInt(this.itemNumEB.string);
  29. this.requestAddItems([
  30. {
  31. id: itemid,
  32. count: num
  33. }
  34. ]);
  35. },
  36. requestAddItems (items) {
  37. let uid = G.UserMgr.getUid();
  38. if (!uid) return;
  39. let info = {
  40. uid: uid,
  41. items: items
  42. };
  43. G.NetworkMgr.sendSocketRequest('test_add_items', info, this.responseAddItems.bind(this));
  44. },
  45. responseAddItems (data) {
  46. let requestInfo = data.requestInfo;
  47. let responseInfo = data.responseInfo;
  48. if (responseInfo.code === 200) {
  49. for (const item of requestInfo.items) {
  50. if (item.count > 0) {
  51. G.AppUtils.getSceneCtrl().addToast('获得: ' + item.id + "&&数量:" + item.count);
  52. }
  53. if (item.count < 0) {
  54. G.AppUtils.getSceneCtrl().addToast('删除: ' + item.id + "&&数量:" + Math.abs(item.count));
  55. }
  56. }
  57. }
  58. },
  59. });