123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- const JMAlertBase = require('JMAlertBase');
- cc.Class({
- editor: {
- menu: 'Debug/DebugAlert'
- },
- extends: JMAlertBase ,
- properties: {
- itemIdEB: cc.EditBox,
- itemNumEB: cc.EditBox,
- },
- onLoad () {
- this._super();
- },
- onEnable () {
- this._super();
- },
- onDisable () {
- cc.game.targetOff(this);
- this._super();
- },
- reloadData (data, cb) {
- },
-
- debuguItemAddOnClicked() {
- if (this.itemIdEB.string.length == 0) {
- return;
- }
- let itemid = parseInt(this.itemIdEB.string);
- let num = this.itemNumEB.string.length == 0 ? 1 : parseInt(this.itemNumEB.string);
- this.requestAddItems([
- {
- id: itemid,
- count: num
- }
- ]);
- },
- requestAddItems (items) {
- let uid = G.UserMgr.getUid();
- if (!uid) return;
- let info = {
- uid: uid,
- items: items
- };
- G.NetworkMgr.sendSocketRequest('test_add_items', info, this.responseAddItems.bind(this));
- },
- responseAddItems (data) {
- let requestInfo = data.requestInfo;
- let responseInfo = data.responseInfo;
- if (responseInfo.code === 200) {
- for (const item of requestInfo.items) {
- if (item.count > 0) {
- G.AppUtils.getSceneCtrl().addToast('获得: ' + item.id + "&&数量:" + item.count);
- }
- if (item.count < 0) {
- G.AppUtils.getSceneCtrl().addToast('删除: ' + item.id + "&&数量:" + Math.abs(item.count));
- }
- }
- }
- },
- });
|