pubgv3/assets/scripts/UI/userinfo/UINameCard.js
zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

50 lines
1.0 KiB
JavaScript

var gameConfig = require("gameConfig");
var NetManage = require("NetManage");
var httpclient = require("httpclient");
cc.Class({
extends: cc.Component,
properties: {
lb_count: {
default: null,
type: cc.Label,
},
editbox: {
default: null,
type: cc.EditBox,
},
},
// LIFE-CYCLE CALLBACKS:
onLoad() {
cc.Notifier.on("ongetItemList", this, this.ongetItemList.bind(this));
},
onDestroy() {
cc.Notifier.off("ongetItemList", this);
},
ongetItemList() {
this.onclose();
},
initdata(itemid) {
this.itemid = itemid;
this.lb_count.string = cc.playerData.getItemCount(itemid);
},
onclose() {
this.node.destroy();
},
onok() {
if (this.editbox.string == "") {
cc.uiHelper.showTips("Please enter a name");
return;
}
var self = this;
var cb = function (obj) {
NetManage.useitem(self.itemid, 1, obj.name, obj.name_sign);
};
NetManage.checkName(this.editbox.string, cb);
},
// update (dt) {},
});