196 lines
5.5 KiB
JavaScript
196 lines
5.5 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '0696560KNxAe4PIL63EvDVl', 'cmp.guild.members.wnd');
|
||
|
|
// Scripts/mod/guild/member/cmps/cmp.guild.members.wnd.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 联盟成员列表
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var FxSVC = require("nx.fx.sv.expand");
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var TipsController = require("tips_controller");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
var GuildConst = require("guild_const");
|
||
|
|
var GuildEvent = require("guild_event");
|
||
|
|
var GuildController = require("guild_controller");
|
||
|
|
|
||
|
|
// 工会职位
|
||
|
|
var GPT = GuildConst.PositionType;
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
svcList: {
|
||
|
|
"default": null,
|
||
|
|
type: FxSVC
|
||
|
|
},
|
||
|
|
nodMemebers: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodAssistants: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodOps: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
isMgr: {
|
||
|
|
"default": false,
|
||
|
|
displayName: "管理模式"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 显示
|
||
|
|
onEnable: function onEnable() {
|
||
|
|
var _this = this;
|
||
|
|
this.ctrl = GuildController.getInstance();
|
||
|
|
this.model = this.ctrl.getModel();
|
||
|
|
nx.gui.setActive(this.nodOps, "impeach", false);
|
||
|
|
|
||
|
|
// 事件监听
|
||
|
|
this.bindGEvent(GuildEvent.UpdateMyMemberListEvent, this.onFreshList.bind(this));
|
||
|
|
this.bindGEvent(GuildEvent.UpdateAssistantNumEvent, this.onFreshAssistantCount.bind(this));
|
||
|
|
|
||
|
|
// 更新成员列表
|
||
|
|
this.ctrl.reqMemberList(function (_ret, _data) {
|
||
|
|
if (!_ret) {
|
||
|
|
nx.tbox(_data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
_this.onFreshAssistantCount();
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// 关闭
|
||
|
|
onDisable: function onDisable() {
|
||
|
|
this.unbindGEvents();
|
||
|
|
},
|
||
|
|
// 成员更新
|
||
|
|
onFreshList: function onFreshList(_type) {
|
||
|
|
var list = this.model.getGuildMemberList();
|
||
|
|
this.svcList.rebuild(list);
|
||
|
|
|
||
|
|
// 弹劾操作检查
|
||
|
|
this.checkImpeach();
|
||
|
|
},
|
||
|
|
// 管理数量更新
|
||
|
|
onFreshAssistantCount: function onFreshAssistantCount() {
|
||
|
|
// 总人数
|
||
|
|
var info = this.model.getMyGuildInfo();
|
||
|
|
nx.gui.setString(this.nodMemebers, "cur", info.members_num);
|
||
|
|
nx.gui.setString(this.nodMemebers, "max", info.members_max);
|
||
|
|
|
||
|
|
// 副盟主
|
||
|
|
var key = Utils.getNorKey(GPT.Assistant, info.lev);
|
||
|
|
var cfg = game.configs.guild_data.data_post[key];
|
||
|
|
if (cfg) {
|
||
|
|
var num = this.model.getAssistantSum();
|
||
|
|
nx.gui.setString(this.nodAssistants, "cur", num);
|
||
|
|
nx.gui.setString(this.nodAssistants, "max", cfg.num);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 弹劾操作检查
|
||
|
|
checkImpeach: function checkImpeach() {
|
||
|
|
// 弹劾操作控制
|
||
|
|
var role = RoleController.getInstance().getRoleVo();
|
||
|
|
if (role.position == GPT.Leader) {
|
||
|
|
nx.gui.setActive(this.nodOps, "impeach", false);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 盟主离线时间检查
|
||
|
|
var show = false;
|
||
|
|
var list = this.model.getGuildMemberList();
|
||
|
|
var time = game.configs.guild_data.data_const.impeach_offline_day2.val;
|
||
|
|
for (var i in list) {
|
||
|
|
var member = list[i];
|
||
|
|
if (!member || member.post != GPT.Leader) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
var dt = client.socket.getTime() - member.login_time;
|
||
|
|
if (dt >= 86400 * time) {
|
||
|
|
show = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this.nodOps, "impeach", show);
|
||
|
|
},
|
||
|
|
// 帮助
|
||
|
|
onTouchHelp: function onTouchHelp() {
|
||
|
|
var TC = TipsController.getInstance();
|
||
|
|
var config = game.configs.guild_data.data_const.game_rule;
|
||
|
|
if (TC && config && nx.dt.strNEmpty(config.desc)) {
|
||
|
|
TC.showTextPanel("tip", nx.text.getKey(config.desc));
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 弹劾
|
||
|
|
onTouchImpeach: function onTouchImpeach() {
|
||
|
|
var cost = gdata("guild_data", "data_const", "impeach_gold");
|
||
|
|
var id = cost.val[0][0];
|
||
|
|
var num = cost.val[0][1];
|
||
|
|
if (!nx.dt.numPositive(id, false) || !nx.dt.numPositive(num, false)) {
|
||
|
|
nx.error("无效弹劾消耗配置!");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var self = this;
|
||
|
|
var txt = nx.text.format("GuildImpeachTip", id, num);
|
||
|
|
nx.mbox(txt, ['cancel', 'confirm'], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == 'confirm') {
|
||
|
|
self.ctrl.send13565(function (_ret, _data) {
|
||
|
|
if (!_ret) {
|
||
|
|
nx.tbox(_data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
self.checkImpeach();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// 退帮
|
||
|
|
onTouchQuit: function onTouchQuit() {
|
||
|
|
// 解散帮派
|
||
|
|
var self = this;
|
||
|
|
var role = RoleController.getInstance().getRoleVo();
|
||
|
|
if (role.position == GPT.Leader) {
|
||
|
|
var _key2 = role.guild_quit_time == 0 ? "GuildDissolveAskFst" : "GuildDissolveAsk";
|
||
|
|
var _msg = nx.text.format(_key2, role.gname);
|
||
|
|
nx.mbox(_msg, ['cancel', 'confirm'], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == 'confirm') {
|
||
|
|
self.ctrl.reqDissolve(function (_ret, _data) {
|
||
|
|
if (!_ret) {
|
||
|
|
nx.tbox(_data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.bridge.closePanel("WndGuild");
|
||
|
|
self.model.clearMyGuildInfo();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 普通退帮
|
||
|
|
var key = role.guild_quit_time == 0 ? "GuildQuitAskFst" : "GuildQuitAsk";
|
||
|
|
var msg = nx.text.format(key, role.gname);
|
||
|
|
nx.mbox(msg, ['cancel', 'confirm'], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == 'confirm') {
|
||
|
|
self.ctrl.reqQuit(function (_ret, _data) {
|
||
|
|
if (!_ret) {
|
||
|
|
nx.tbox(_data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.bridge.closePanel("WndGuild");
|
||
|
|
self.model.clearMyGuildInfo();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|