239 lines
5.8 KiB
JavaScript
239 lines
5.8 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'bd19d19oi9KjY+11mTXKbqA', 'cmp.personal.wnd');
|
|
// Scripts/mod/personal/cmps/cmp.personal.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 个人信息
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var RoleController = require("role_controller");
|
|
var TipController = require("tips_controller");
|
|
var HeroController = require("hero_controller");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
nodAvatar: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodUID: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodServer: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodLevel: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodUnion: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodDan: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodName: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
lstPartners: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
onLoad: function onLoad() {
|
|
// 主角信息
|
|
var RC = RoleController.getInstance();
|
|
this.role = RC ? RC.getRoleVo() : null;
|
|
if (!this.role) {
|
|
return;
|
|
}
|
|
|
|
// 基本信息
|
|
|
|
// UID
|
|
nx.gui.setString(this.nodUID, "txt", this.role.rid);
|
|
|
|
// 服务器
|
|
nx.gui.setString(this.nodServer, "txt", nx.text.getKey(this.role.srv_id));
|
|
|
|
// 名字
|
|
this.updateName();
|
|
|
|
// 头像更新
|
|
this.updateAvatar();
|
|
|
|
// 头像框更新
|
|
this.updateFrame();
|
|
|
|
// 等级
|
|
nx.gui.setString(this.nodLevel, "txt", this.role.lev);
|
|
|
|
// 工会
|
|
var txt = this.role.gname;
|
|
if (nx.dt.strEmpty(txt)) {
|
|
txt = "PLNoGuild";
|
|
}
|
|
nx.gui.setString(this.nodUnion, "txt", txt);
|
|
|
|
// 当前阵容
|
|
this.freshCurrentTeam();
|
|
|
|
// 段位
|
|
|
|
// 监听绑定
|
|
this.roleHandler = this.role.bind(EventId.UPDATE_ROLE_ATTRIBUTE, this.onRoleAttrUpdate, this);
|
|
},
|
|
onOpenConfigs: function onOpenConfigs(_params) {},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 监听绑定解除
|
|
if (this.roleHandler) {
|
|
this.role.unbind(this.roleHandler);
|
|
this.roleHandler = null;
|
|
}
|
|
},
|
|
// 角色属性改变
|
|
onRoleAttrUpdate: function onRoleAttrUpdate(_key, _val) {
|
|
// 名字
|
|
if (_key == "name") {
|
|
this.updateName();
|
|
return;
|
|
}
|
|
|
|
// 头像更新
|
|
if (_key == "face_id") {
|
|
this.updateAvatar();
|
|
return;
|
|
}
|
|
|
|
// 头像框更新
|
|
if (_key == "avatar_base_id") {
|
|
this.updateFrame();
|
|
return;
|
|
}
|
|
},
|
|
// 名字更新
|
|
updateName: function updateName() {
|
|
var name = this.role ? this.role.name : "";
|
|
nx.gui.setString(this.nodName, "txt", name);
|
|
},
|
|
// 头像更新
|
|
updateAvatar: function updateAvatar() {
|
|
nx.bridge.setAvatarByFaceId(this.nodAvatar, "mask/img", this.role.face_id);
|
|
},
|
|
// 头像框更新
|
|
updateFrame: function updateFrame() {
|
|
var path = cc.path.join('resDB/aframes', this.role.avatar_base_id);
|
|
nx.gui.setSpriteFrame(this.nodAvatar, "frame", path);
|
|
},
|
|
// 当前阵容
|
|
freshCurrentTeam: function freshCurrentTeam() {
|
|
this.teammates = [];
|
|
var model = HeroController.getInstance().getModel();
|
|
var list = model.getMyPosList() || [];
|
|
var chds = this.lstPartners.children;
|
|
for (var i = 0; i < 5; ++i) {
|
|
var cmp = nx.gui.getComponent(chds[i], "", "cmp.partner.inbag");
|
|
var ifo = list[i + 1];
|
|
var partner = ifo ? model.getHeroById(ifo.id) : null;
|
|
if (partner) {
|
|
cmp.setData(partner);
|
|
} else {
|
|
cmp.setEmpty();
|
|
}
|
|
cmp.node.index = i;
|
|
this.teammates.push(partner);
|
|
}
|
|
},
|
|
// 点击成员
|
|
onTouchTeammate: function onTouchTeammate(_touch) {
|
|
var index = _touch.currentTarget.parent.index;
|
|
var focus = this.teammates[index];
|
|
if (focus) {
|
|
var HC = HeroController.getInstance();
|
|
HC.openHeroMainInfoWindow(true, focus, this.teammates);
|
|
} else {
|
|
// 打开编队
|
|
var _HC = HeroController.getInstance();
|
|
if (_HC) {
|
|
_HC.openFormMainWindow(true);
|
|
}
|
|
}
|
|
this.close();
|
|
},
|
|
// 改名
|
|
onTouchRename: function onTouchRename() {
|
|
var TC = TipController.getInstance();
|
|
var RC = RoleController.getInstance();
|
|
var self = this;
|
|
var modify = function modify(_name, _box) {
|
|
var sex = Math.min(1, self.role.sex);
|
|
RC.changeRoleName(_name, sex, function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
_box.close();
|
|
});
|
|
};
|
|
var role = RC.getRoleVo();
|
|
var tip = role.is_first_rename ? "PLRenameFirstTip" : "PLRenameTip";
|
|
TC.showInputString({
|
|
tip: tip,
|
|
limit: [4, 12],
|
|
cb: function cb(_box, _str) {
|
|
modify(_str, _box);
|
|
}
|
|
});
|
|
},
|
|
// 换头像
|
|
onTouchSwapAvatar: function onTouchSwapAvatar() {
|
|
nx.bridge.createPanel("WndPersonalAvatarChange");
|
|
},
|
|
// 兑换码
|
|
onTouchExchange: function onTouchExchange() {
|
|
var self = this;
|
|
var RC = RoleController.getInstance();
|
|
var exchange = function exchange(_code) {
|
|
RC.sender10945(_code);
|
|
};
|
|
nx.bridge.createPanel("WndPersonalExchange", {
|
|
cb: function cb(_box, _code) {
|
|
_box.close();
|
|
exchange(_code);
|
|
}
|
|
});
|
|
},
|
|
// 点击冒险形象
|
|
onTouchFigure: function onTouchFigure() {
|
|
var RC = RoleController.getInstance();
|
|
RC.fetchFigureData(function (_ret, _data) {
|
|
if (!_ret) {
|
|
nx.tbox(_data);
|
|
return;
|
|
}
|
|
nx.bridge.createPanel("WndPersonalFigure", _data);
|
|
});
|
|
},
|
|
// 点击个性装饰
|
|
onTouchDecorate: function onTouchDecorate() {
|
|
nx.bridge.createPanel("WndPersonalAvatarChange");
|
|
},
|
|
// 点击秘书组
|
|
onTouchClerk: function onTouchClerk() {
|
|
nx.bridge.createPanel("WndPersonalClerk");
|
|
nx.bridge.closePanel("WndPersonal");
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |