"use strict"; cc._RF.push(module, '2dbf7Am47tNd4tWjYCt9GEt', 'guild_controller'); // Scripts/mod/guild/base/guild_controller.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2019-01-14 10:57:08 // -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var GuildConst = require("guild_const"); var GuildEvent = require("guild_event"); var RoleController = require("role_controller"); // 工会职位 var GPT = GuildConst.PositionType; var GuildController = cc.Class({ "extends": BridgeController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var GuildModel = require("guild_model"); this.model = new GuildModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() { if (this.login_event_success == null) { this.login_event_success = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () { gcore.GlobalEvent.unbind(this.login_event_success); this.login_event_success = null; this.role_vo = RoleController.getInstance().getRoleVo(); if (this.role_vo) { // this.requestInitProtocal(); if (this.role_assets_event == null) { this.role_assets_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, value) { if (key == "gid") { if (value == 0) { // 这个时候表示退帮了,需要关闭一些窗体 nx.bridge.closePanel("WndGuild"); nx.bridge.closePanel("WndGuildDonate"); nx.bridge.closePanel("WndGuildMemberList"); nx.bridge.closePanel("WndGuildMemberManager"); nx.bridge.closePanel("WndGuildActive"); this.model.clearMyGuildInfo(); } // this.requestInitProtocal() } else if (key == "position") { this.model.updateMemberByPosition(value); } }.bind(this)); } } }.bind(this)); } }, // 注册协议接受事件 registerProtocals: function registerProtocals() { // 基本信息 this.RegisterProtocal(13518, this.handle13518); // 本公会基础信息 this.RegisterProtocal(13501, this.handle13501); // 公会列表 // 成员相关 this.RegisterProtocal(13519, this.handle13519); // 本公会成员列表 this.RegisterProtocal(13542, this.hander13542); // 增删更新成员 this.RegisterProtocal(13576, this.handle13576); // 欢迎新人 this.RegisterProtocal(13513, this.handle13513); // 从公会中踢人 this.RegisterProtocal(13565, this.handle13565); // 弹劾 // 工会捐献 this.RegisterProtocal(13523, this.handle13523); // 玩家基础捐献信息 this.RegisterProtocal(13524, this.handle13524); // 捐献返回 this.RegisterProtocal(13574, this.handle13574); // 领取捐献宝箱情况 this.RegisterProtocal(13575, this.handle13575); // 更新当前捐献进度值 // 工会管理 this.RegisterProtocal(13500, this.handle13500); // 创建公会 this.RegisterProtocal(13503, this.handle13503); // 申请加入公会 this.RegisterProtocal(13514, this.handle13514); // 退帮 this.RegisterProtocal(13516, this.handle13516); // 解散公会 this.RegisterProtocal(13568, this.handle13568); // 修改公会名字 this.RegisterProtocal(13520, this.handle13520); // 职位设置 this.RegisterProtocal(13521, this.handle13521); // 修改宣言 this.RegisterProtocal(13522, this.handle13522); // 设置申请 this.RegisterProtocal(13525, this.handle13525); // 請求每日獎勵狀態 this.RegisterProtocal(13526, this.handle13526); // 請求領取每日獎勵返回 this.RegisterProtocal(13505, this.handle13505); // 操作申请成员的列表 this.RegisterProtocal(13507, this.handle13507); // 更新申请加入列表 this.RegisterProtocal(13573, this.handle13573); // 公会申请列表红点 this.RegisterProtocal(13558, this.handle13558); // 公会招募广告 // 工会活跃 this.RegisterProtocal(16900, this.handle16900); // 基本信息 this.RegisterProtocal(16901, this.handle16901); // 任务信息 this.RegisterProtocal(16902, this.handle16902); // 更新(新增)任务信息 this.RegisterProtocal(16903, this.handle16903); // 提交任务 this.RegisterProtocal(16904, this.handle16904); // 升级处理 }, reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["guild_data", "guild_quest_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.requestInitProtocal(_cb); }); }, // reqGuildBase: function( _cb ){ // this.reqDonateData(); // this.reqActBaseInfo(); // this.reqBase( _cb ); // }, // 请求公会相关协议 requestInitProtocal: function requestInitProtocal(_cb) { if (!this.role_vo || this.role_vo.gid == 0) { this.model.clearMyGuildInfo(); nx.dt.fnInvoke(_cb, true); return; } this.reqBase(_cb); this.reqDonateData(); this.reqActBaseInfo(); this.reqGetDailyReward(); if (this.role_vo && this.role_vo.position != GuildConst.PositionType.Member) { this.checkReqJoin(); } }, // =========================================================================== // 基本信息 // =========================================================================== // 请求工会信息 reqBase: function reqBase(_cb) { this.SendProtocal(13518, {}, _cb); }, // 更新自己公会的信息 handle13518: function handle13518(data) { // 更新 this.model.updateMyGuildInfo(data); // 管理职位 if (this.role_vo && this.role_vo.position != GPT.Member) { this.reqApplyJoinList(1, 15); } }, // 请求公会列表 // @page:页码 // @flag:是否显示满人的公会 0:不显示 1:显示 // @num:每页显示条数 // @name:如果不为“”表示是搜索 reqGuildList: function reqGuildList(page, flag, num, name, _cb) { var protocal = {}; protocal.page = page || 0; protocal.flag = flag || 1; protocal.num = num || 0; protocal.name = name || ""; this.SendProtocal(13501, protocal, _cb); }, //获取公会列表 handle13501: function handle13501(data) { this.model.updateGuildList(data.name, data.guilds); if (nx.dt.arrEmpty(data.guilds)) { nx.tbox("msg_searchGuildTip"); } }, // =========================================================================== // 成员相关 // =========================================================================== // 请求公会成员列表 reqMemberList: function reqMemberList(_cb) { this.SendProtocal(13519, {}, _cb); }, // 更新整个公会成员列表 handle13519: function handle13519(data) { this.model.updateMyGuildMemberList(data.members, 1); }, // 更新,增加或者删除成员 hander13542: function hander13542(data) { this.model.updateMyGuildMemberList(data.members, data.type); }, // 欢迎新人 welcomeNewMember: function welcomeNewMember(rid, srv_id) { var protocal = {}; protocal.rid = rid; protocal.srv_id = srv_id; this.SendProtocal(13576, protocal); }, // 欢迎新人 handle13576: function handle13576(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 从公会中踢人 requestKickoutMember: function requestKickoutMember(rid, srv_id, _cb) { this.SendProtocal(13513, { rid: rid, srv_id: srv_id }, _cb); }, // 踢人返回 handle13513: function handle13513(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } // if( data.code == 1 ) // this.openGuildOperationPostWindow( false ); }, // 弹劾帮主 send13565: function send13565(_cb) { this.SendProtocal(13565, {}, _cb); }, handle13565: function handle13565(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // =========================================================================== // 工会捐献 // =========================================================================== // 请求捐献信息 reqDonateData: function reqDonateData(_cb) { this.SendProtocal(13523, {}, _cb); }, // 捐献信息返回 handle13523: function handle13523(data) { this.model.updateDonateInfo(data.donate_list); this.model.updateDonateBoxInfo(data.boxes, data.donate_exp); }, // 请求捐献 reqDonate: function reqDonate(type, _cb) { this.SendProtocal(13524, { type: type }, _cb); }, // 捐献返回 handle13524: function handle13524(data) { if (data.code == 1) { this.model.setGuildDonateStatus(); } }, // 请求领取指定捐献宝箱 requestDonateBoxRewards: function requestDonateBoxRewards(box_id, _cb) { this.SendProtocal(13574, { box_id: box_id }, _cb); }, // 领取捐献宝箱返回 handle13574: function handle13574(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } if (data.code == 1) { this.model.setDonateBoxStatus(data.box_id); } }, // 更新捐献进度值 handle13575: function handle13575(data) { this.model.updateDonateActivity(data.donate_exp); }, // =========================================================================== // 工会管理 // =========================================================================== // 请求创建公会 // @name:公会名字 // @sign:宣言 // @apply_type:申请类型(0:自动审批 1:手动审批 2:不允许申请) // @apply_lev:最小等级要求 reqCreate: function reqCreate(name, sign, apply_type, apply_lev, apply_power, _cb) { var protocal = {}; protocal.name = name; protocal.sign = sign; protocal.apply_lev = apply_lev || 1; protocal.apply_type = apply_type || 0; protocal.apply_power = apply_power || 0; this.SendProtocal(13500, protocal, _cb); }, // 创建公会返回 handle13500: function handle13500(data) { // if( !nx.dt.strEmpty( data.msg ) ){ // nx.tbox( data.msg ); // } }, // 申请加入公会 reqJoin: function reqJoin(gid, gsrv_id, type, _cb) { if (gid == null || gsrv_id == null) return; var protocal = {}; protocal.gid = gid; protocal.gsrv_id = gsrv_id; protocal.type = type || 1; this.SendProtocal(13503, protocal, _cb); }, // 请求加入公会返回 handle13503: function handle13503(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } if (data.code == 1) { this.model.updateGuildApplyStatus(data.gid, data.gsrv_id, data.is_apply); this.reqGetDailyReward(); } }, // 退帮 reqQuit: function reqQuit(_cb) { this.SendProtocal(13514, {}, _cb); this.model.clearMyGuildInfo(); }, // 退帮 handle13514: function handle13514(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 解散 reqDissolve: function reqDissolve(_cb) { this.SendProtocal(13516, {}, _cb); }, // 解散 handle13516: function handle13516(data) { this.model.clearMyGuildInfo(); // if( !nx.dt.strEmpty( data.msg ) ){ // nx.tbox( data.msg ); // } if (!this.isGoodData(data)) { return; } }, // 请求改名 reqRename: function reqRename(name, _cb) { this.SendProtocal(13568, { name: name }, _cb); }, // 公会改名 handle13568: function handle13568(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 职位任命 requestOperationPost: function requestOperationPost(rid, srv_id, position, _cb) { this.SendProtocal(13520, { rid: rid, srv_id: srv_id, position: position }, _cb); }, handle13520: function handle13520(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 请求修改公会宣言 reqModifySign: function reqModifySign(sign, _cb) { this.SendProtocal(13521, { sign: sign }, _cb); }, // 公会宣言修改 handle13521: function handle13521(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } if (data.code == 1) { // this.openGuildChangeSignWindow( false ); } }, // 修改申请条件 reqModifyApplySetting: function reqModifyApplySetting(_type, _lev, _power, _cb) { this.SendProtocal(13522, { apply_type: _type, apply_lev: _lev, apply_power: _power }, _cb); }, // 设置权限返回 handle13522: function handle13522(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 獲取每日獎勵 reqGetDailyRewardStatus: function reqGetDailyRewardStatus(_cb) { this.SendProtocal(13525, {}, _cb); }, // 獲取 返回 handle13525: function handle13525(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 請求每日獎勵狀態 reqGetDailyReward: function reqGetDailyReward(_cb) { this.SendProtocal(13526, {}, _cb); }, // 獎勵狀態 返回 handle13526: function handle13526(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } nx.mTip.openTip("guild.dailyReward", data.flag == 0); }, // 工会申请检查 checkReqJoin: function checkReqJoin(_cb) { this.SendProtocal(13573, {}, _cb); }, // 公会申请红点 handle13573: function handle13573(data) { nx.mTip.openTip("guild.reqJoin", data.code == 1); }, // 请求当前申请加入的公会列表 reqApplyJoinList: function reqApplyJoinList(page, num, _cb) { this.SendProtocal(13507, { page: page, num: num }, _cb); }, // 更新申请列表 handle13507: function handle13507(data) { this.model.updateApplyJoinList(data.guids); }, // 会长或者副会长处理操作申请列表 reqApplyJoinAnswer: function reqApplyJoinAnswer(type, rid, srv_id, _cb) { this.SendProtocal(13505, { type: type, rid: rid, srv_id: srv_id }, _cb); }, // 操作申请玩家列表返回 handle13505: function handle13505(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } if (data.code == 1) this.model.deleteApplyInfo(data.rid, data.srv_id); }, // 招募广告 reqBroadcast: function reqBroadcast(_cb) { this.SendProtocal(13558, {}, _cb); }, // 招募广告返回 handle13558: function handle13558(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // =========================================================================== // 工会活跃 // =========================================================================== // 基本信息 reqActBaseInfo: function reqActBaseInfo() { this.SendProtocal(16900, {}); }, handle16900: function handle16900(data) { gcore.GlobalEvent.fire(GuildEvent.UpdataGuildGoalBasicData, data); this.model.freshActiveTips(data); }, // 任务信息 reqActTaskInfo: function reqActTaskInfo() { this.SendProtocal(16901, {}); }, handle16901: function handle16901(data) { gcore.GlobalEvent.fire(GuildEvent.UpdataGuildGoalTaskData, data); }, // 单条任务信息 handle16902: function handle16902(data) { gcore.GlobalEvent.fire(GuildEvent.UpdataGuildGoalSingleTaskData, data); }, // 提交任务 send16903: function send16903(id) { var protocal = {}; protocal.id = id; this.SendProtocal(16903, protocal); }, handle16903: function handle16903(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } }, // 活跃度升级 reqActLevelUp: function reqActLevelUp(_cb) { this.SendProtocal(16904, {}, _cb); }, handle16904: function handle16904(data) { if (!nx.dt.strEmpty(data.msg)) { nx.tbox(data.msg); } } }); module.exports = GuildController; cc._RF.pop();