"use strict"; cc._RF.push(module, '89234ljtEdJ+p+0ojnwtmdf', 'ladder_top_three_window'); // Scripts/mod/ladder/view/ladder_top_three_window.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 天梯英雄殿 //
Create: 2019-07-24 16:55:47 // -------------------------------------------------------------------- var PathTool = require("pathtool"); var LadderController = require("ladder_controller"); var LadderEvent = require("ladder_event"); var RoleEvent = require("role_event"); var RoleController = require("role_controller"); var FriendController = require("friend_controller"); var LadderConst = require("ladder_const"); var Ladder_top_threeWindow = cc.Class({ "extends": BaseView, ctor: function ctor() { this.prefabPath = PathTool.getPrefabPath("ladder", "ladder_top_three_window"); this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意 this.win_type = WinType.Big; //是否是全屏窗体 WinType.Full, WinType.Big, WinType.Mini, WinType.Tips }, // 初始化一些配置数据,可以用于声明一些变量之类的 initConfig: function initConfig() { this.state_list = {}; this.ctrl = LadderController.getInstance(); this.model = this.ctrl.getModel(); }, // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件 openCallBack: function openCallBack() { this.background = this.seekChild("background"); this.background.scale = FIT_SCALE; var main_container = this.seekChild("main_container"); var title_label = this.seekChild(main_container, "title_label", cc.Label); title_label.string = Utils.TI18N("英雄殿"); var tips_label = this.seekChild(main_container, "tips_label", cc.Label); tips_label.string = Utils.TI18N("*每日点赞可获天梯积分奖励"); this.close_btn = this.seekChild("close_btn"); for (var i = 1; i <= 3; i++) { var statue = this.seekChild(main_container, "statue_" + i); var desc = statue.getChildByName("desc").getComponent(cc.Label); desc.string = Utils.TI18N("虚位以待"); var state_data = {}; state_data.model = statue.getChildByName("model"); state_data.role_name = statue.getChildByName("role_name").getComponent(cc.Label); state_data.guild_name = statue.getChildByName("guild_name").getComponent(cc.Label); state_data.worship_btn = statue.getChildByName("worship_btn").getComponent(cc.Button); state_data.label = statue.getChildByName("label").getComponent(cc.Label); state_data.btn_check = statue.getChildByName("btn_check").getComponent(cc.Button); state_data.desc = desc; state_data.worship_num = 0; this.state_list[i] = state_data; } }, // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent registerEvent: function registerEvent() { var _this = this; Utils.onTouchEnd(this.close_btn, function () { this.ctrl.openLadderTopThreeWindow(false); }.bind(this), 2); Utils.onTouchEnd(this.background, function () { this.ctrl.openLadderTopThreeWindow(false); }.bind(this), 2); var _loop = function _loop(i) { var state_data = _this.state_list[i]; if (state_data && state_data.worship_btn) { state_data.worship_btn.node.on("click", function () { this._onClickBtnWorship(i); }.bind(_this)); } if (state_data && state_data.btn_check) { state_data.btn_check.node.on("click", function () { this._onClickBtnCheck(i); }.bind(_this)); } }; for (var i = 1; i <= 3; i++) { _loop(i); } this.addGlobalEvent(LadderEvent.UpdateLadderTopThreeRoleData, function (data) { this.setData(data); }, this); this.addGlobalEvent(RoleEvent.WorshipOtherRole, function (rid, srv_id, idx) { if (idx != null && this.state_data[idx]) { var state_panel = this.state_list[idx]; state_panel.worship_num = state_panel.worship_num + 1; state_panel.label.string = state_panel.worship_num; Utils.setGreyButton(state_panel.worship_btn); } }, this); }, // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了 openRootWnd: function openRootWnd(params) { this.ctrl.requestTopThreeRoleData(); }, _onClickBtnWorship: function _onClickBtnWorship(index) { var data = this.getRoleDataByRank(index); if (data) { var rid = data.rid; var srv_id = data.srv_id; RoleController.getInstance().sender10316(rid, srv_id, index, WorshipType.ladder); } }, _onClickBtnCheck: function _onClickBtnCheck(index) { var data = this.getRoleDataByRank(index); if (data) { var rid = data.rid; var srv_id = data.srv_id; FriendController.getInstance().openFriendCheckPanel(true, { srv_id: srv_id, rid: rid }); } }, setData: function setData(data) { data = data || {}; this.data = data; for (var i = 1; i <= 3; i++) { var state_panel = this.state_list[i]; var role_data = this.getRoleDataByRank(i); if (role_data) { state_panel.model.x = 5000; state_panel.role_name.node.x = 5000; state_panel.guild_name.node.x = 5000; state_panel.worship_btn.node.x = 5000; state_panel.desc.node.x = 5000; state_panel.role_name.string = role_data.name; var gname = role_data.gname; if (!gname || gname == "") { gname = Utils.TI18N("暂无"); } state_panel.guild_name.string = cc.js.formatStr(Utils.TI18N("公会:%s"), gname); state_panel.label.string = role_data.worship; state_panel.worship_num = role_data.worship; if (role_data.worship_status == 0) {} } } }, getRoleDataByRank: function getRoleDataByRank(rank) { this.data = this.data || {}; var role_data = null; for (var k in this.data) { var v = this.data[k]; if (v.rank == rank) { role_data = v; break; } } return role_data; }, // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象 closeCallBack: function closeCallBack() { this.model.updateLadderRedStatus(LadderConst.RedType.TopThree, false); this.ctrl.openLadderTopThreeWindow(false); } }); cc._RF.pop();