"use strict"; cc._RF.push(module, '8434eOqrx1E85rTPOvfwOkV', 'action_seven_login_item_panel'); // Scripts/mod/action/view/action_seven_login_item_panel.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 七天登录活动单个 //
Create: 2019-04-17 16:29:20 // -------------------------------------------------------------------- var PathTool = require("pathtool"); var Action_seven_login_itemPanel = cc.Class({ "extends": BasePanel, ctor: function ctor() { this.prefabPath = PathTool.getPrefabPath("action", "action_seven_login_item"); }, // 可以初始化声明一些变量的 initConfig: function initConfig() { this.status = 1; }, // 初始化一些配置数据,可以用于声明一些变量之类的 initPanel: function initPanel() { this.main_container = this.root_wnd.getChildByName("main_container"); ; var title_bg = this.main_container.getChildByName("title_bg"); title_bg.zIndex = 21; this.title = this.main_container.getChildByName("title").getComponent(cc.Label); this.title.node.zIndex = 21; this.get = this.main_container.getChildByName("get"); this.get.active = false; this.select = this.main_container.getChildByName("select"); this.select.active = false; this.effect_node = this.seekChild("get_eff_node"); this.effect = this.seekChild("get_eff_node", sp.Skeleton); this.effect_node.active = false; this.effect_node.zIndex = 20; var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(257), "action"); this.loadRes(anima_path, function (ske_data) { this.effect.skeletonData = ske_data; this.effect.setAnimation(0, PlayerAction.action, true); }.bind(this)); this.icon = this.main_container.getChildByName("icon").getComponent(cc.Sprite); if (this.data) { this.updateInfo(); } if (this.isSelect != null) { this.setSelect(this.isSelect); } if (this.status != null) { this.setStatus(this.status); } else { this.setStatus(1); } }, // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent registerEvent: function registerEvent() { Utils.onTouchEnd(this.main_container, function () { if (this.callback) { this.callback(); } }.bind(this), 2); }, setData: function setData(index) { this.data = index; this.updateInfo(); }, updateInfo: function updateInfo() { if (!this.root_wnd || !this.data) return; // -- var config = deepCopy(Config.ItemData.data_get_data(Config.LoginDaysData.data_day[index].rewards[1][1])) // -- config.quantity = Config.LoginDaysData.data_day[index].rewards[1][2] // -- this.goods_item:setData(config) // -- this.index = index var index = this.data; var StringUtil = require("string_util"); this.title.string = Utils.TI18N("第") + StringUtil.numToChinese(index) + Utils.TI18N("天"); this.loadRes(PathTool.getUIIconPath("actionsevenlogin", "seven_login_item" + index), function (resObject) { this.icon.spriteFrame = resObject; }.bind(this)); if (index == 2 || index == 3) { if (this.effect2 == null) { var node = new cc.Node(); node.setAnchorPoint(0.5, 0.5); node.setPosition(this.main_container.getContentSize().width / 2, this.main_container.getContentSize().height / 2); this.main_container.addChild(node, 19); this.effect2 = node.addComponent(sp.Skeleton); var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(258), "action"); this.loadRes(anima_path, function (ske_data) { if (this.effect2) { this.effect2.skeletonData = ske_data; this.effect2.setAnimation(0, PlayerAction.action, true); } }.bind(this)); } if (this.effect2) { this.effect2.node.active = true; } } else { if (this.effect2) { this.effect2.node.active = false; } } }, setStatus: function setStatus(status) { this.status = status; if (!this.root_wnd) return; if (this.status == 3) { //已领取 this.get.active = true; if (this.effect2) { this.effect2.node.active = false; } if (this.effect_node) { this.effect_node.active = false; } } else { if (this.get) { this.get.active = false; } } if (this.status == 2) { //可领取 if (this.effect_node) { this.effect_node.active = true; } } else { if (this.effect_node) { this.effect_node.active = false; } } // -- if this.status == 2 then --可领取 // -- if this.effct == nil then // -- this.effect = createEffectSpine(PathTool.getEffectRes(257),cc.p(this.main_container:getContentSize().width/2, this.main_container:getContentSize().height/2),cc.p(0.5, 0.5),true,"action") // -- this.main_container:addChild(this.effect,20) // -- end // -- this.effect:setVisible(true) // -- else // -- if this.effect then // -- this.effect:setVisible(false) // -- end // -- end }, setSelect: function setSelect(status) { this.isSelect = status; if (!this.root_wnd) return; if (status) { this.select.active = true; } else { this.select.active = false; } }, addCallBack: function addCallBack(value) { this.callback = value; }, // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了 onShow: function onShow(params) {}, // 面板设置不可见的回调,这里做一些不可见的屏蔽处理 onHide: function onHide() {}, // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用 onDelete: function onDelete() { if (this.effect) { this.effect.setToSetupPose(); this.effect.clearTracks(); } if (this.effect2) { this.effect2.setToSetupPose(); this.effect2.clearTracks(); } this.effect2 = null; } }); cc._RF.pop();