"use strict";
|
cc._RF.push(module, '2c262hkZLNJCrnRv7647SpK', 'action_limit_change_panel');
|
// Scripts/mod/action/view/action_limit_change_panel.js
|
|
"use strict";
|
|
var _color_data, _color_has_title;
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
// --------------------------------------------------------------------
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
// @description:
|
// 这里是描述这个窗体的作用的
|
// <br/>Create: 2019-04-19 13:56:56
|
// --------------------------------------------------------------------
|
var PathTool = require("pathtool");
|
|
var ActionController = require("action_controller");
|
|
var ActionConst = require("action_const");
|
|
var ActionEvent = require("action_event");
|
|
var RoleController = require("role_controller");
|
|
var TimeTool = require("timetool");
|
|
var MallController = require("mall_controller");
|
|
var RoleEvent = require("role_event");
|
|
var color_data = (_color_data = {}, _defineProperty(_color_data, 1, [0xe7, 0xd4, 0x99, 0xff]), _defineProperty(_color_data, 2, [0xdc, 0xfc, 0xff, 0xff]), _defineProperty(_color_data, 3, [0xf6, 0xe4, 0xad, 0xff]), _defineProperty(_color_data, 4, [0xff, 0xcf, 0x90, 0xff]), _defineProperty(_color_data, 5, [0x64, 0x32, 0x23, 0xff]), _color_data);
|
var color_has_title = (_color_has_title = {}, _defineProperty(_color_has_title, 1, [0xb5, 0xaa, 0xd4, 0xff]), _defineProperty(_color_has_title, 2, [0xaf, 0xf8, 0xff, 0xff]), _defineProperty(_color_has_title, 3, [0xff, 0xff, 0xff, 0xff]), _defineProperty(_color_has_title, 4, [0xff, 0xcf, 0x90, 0xff]), _defineProperty(_color_has_title, 5, [0x64, 0x32, 0x23, 0xff]), _color_has_title);
|
var ActionLimitChangePanel = cc.Class({
|
"extends": BasePanel,
|
ctor: function ctor() {
|
this.prefabPath = PathTool.getPrefabPath("action", "action_limit_change_panel");
|
this.ctrl = ActionController.getInstance();
|
this.role_vo = RoleController.getInstance().getRoleVo(); // --此活动的兑换id 后端会传过来 先默认 80101
|
|
this.action_item_id = 80101;
|
this.rewardList = null;
|
this.holiday_bid = arguments[0];
|
},
|
// 可以初始化声明一些变量的
|
initConfig: function initConfig() {},
|
// 初始化一些配置数据,可以用于声明一些变量之类的
|
initPanel: function initPanel() {
|
var self = this;
|
var x = this.getPositionX();
|
this.setPosition(x, -20);
|
this.viewContent = this.seekChild("content");
|
self.main_container = self.root_wnd.getChildByName("main_container");
|
self.title_img = self.main_container.getChildByName("title_img");
|
var limit_change_const = Config.function_data.data_limit_change_const;
|
var config_data = limit_change_const[this.holiday_bid];
|
var str = "txt_cn_action_limit_change_panel";
|
|
if (config_data) {
|
str = config_data.bg_name;
|
}
|
|
var path = PathTool.getUIIconPath("bigbg/action", str);
|
this.loadRes(path, function (res) {
|
self.title_img.getComponent("cc.Sprite").spriteFrame = res;
|
}.bind(this));
|
self.dec_title = self.main_container.getChildByName("dec_title");
|
self.item_scrollview = self.main_container.getChildByName("item_scrollview");
|
this.dec_val = self.main_container.getChildByName("dec_val");
|
var item_dec_label = self.main_container.getChildByName("item_dec_label");
|
var rule_color_1 = "ffcf90";
|
|
if (config_data) {
|
rule_color_1 = config_data.title_color;
|
}
|
|
var color = new cc.Color().fromHEX(rule_color_1);
|
self.dec_val.color = color;
|
self.dec_title.color = color;
|
var has_color = "ffcf90";
|
|
if (config_data) {
|
has_color = config_data.has_prop_color;
|
}
|
|
item_dec_label.color = new cc.Color().fromHEX(has_color); // --道具
|
|
self.item_icon = self.main_container.getChildByName("item_icon");
|
self.item_count = self.main_container.getChildByName("item_count");
|
var time_color;
|
|
if (config_data) {
|
time_color = config_data.time_color1;
|
}
|
|
self.time_val_rt = self.main_container.getChildByName("time_val").getComponent(cc.RichText);
|
self.time_val_rt.node.color = new cc.Color().fromHEX(time_color);
|
self.comfirm_btn = self.main_container.getChildByName("comfirm_btn");
|
},
|
// 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
|
registerEvent: function registerEvent() {
|
this.addGlobalEvent(ActionEvent.UPDATE_HOLIDAY_SIGNLE, function (data) {
|
if (data && data.bid == this.holiday_bid) {
|
this.setData(data);
|
this.setLessTime(data.remain_sec - 2 * 24 * 60 * 60);
|
}
|
}.bind(this));
|
this.comfirm_btn.on('click', this.onComfirmBtn, this);
|
|
if (!this.role_lev_event && this.role_vo) {
|
this.role_lev_event = this.role_vo.bind(RoleEvent.UPDATE_ROLE_ACTION_ASSETS, function (id, value) {
|
if (id && id == this.action_item_id && this.role_vo) {
|
var count = this.role_vo.getActionAssetsNumByBid(this.action_item_id);
|
this.item_count.getComponent(cc.Label).string = count;
|
}
|
}.bind(this));
|
}
|
|
this.ctrl.cs16603(this.holiday_bid);
|
},
|
// --前往兑换
|
onComfirmBtn: function onComfirmBtn() {
|
Utils.playButtonSound(1);
|
MallController.getInstance().openMallActionWindow(true, this.holiday_bid);
|
},
|
// 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
|
onShow: function onShow(params) {},
|
// 面板设置不可见的回调,这里做一些不可见的屏蔽处理
|
onHide: function onHide() {},
|
setVisibleStatus: function setVisibleStatus(bool) {
|
bool = bool || false;
|
this.setVisible(bool);
|
},
|
setLessTime: function setLessTime(less_time) {
|
var self = this;
|
if (!self.time_val_rt) return;
|
|
if (less_time > 0) {
|
this.setTimeFormatString(less_time);
|
|
if (this.time_tichet == null) {
|
this.time_tichet = gcore.Timer.set(function () {
|
less_time--;
|
this.setTimeFormatString(less_time);
|
|
if (less_time < 0) {
|
gcore.Timer.del(this.time_tichet);
|
this.time_tichet = null;
|
this.setTimeFormatString(less_time);
|
}
|
}.bind(this), 1000, -1);
|
}
|
} else {
|
this.setTimeFormatString(less_time);
|
}
|
},
|
setTimeFormatString: function setTimeFormatString(time) {
|
if (time > 0) {
|
var str = "结束时间:<color=#00ff0c>" + TimeTool.getTimeFormatDayIIIIII(time) + "</color>";
|
|
if (this.holiday_bid == ActionConst.ActionChangeCommonType.limit_yuanzhen || this.holiday_bid == ActionConst.ActionChangeCommonType.limit_yuanzhen1) {
|
str = "结束时间:<color=#249003>" + TimeTool.getTimeFormatDayIIIIII(time) + "</color>";
|
}
|
|
this.time_val_rt.string = str;
|
} else {
|
var _str = "结束时间:<color=#00ff0c>活动已结束</color>";
|
|
if (this.holiday_bid == ActionConst.ActionChangeCommonType.limit_yuanzhen || this.holiday_bid == ActionConst.ActionChangeCommonType.limit_yuanzhen1) {
|
_str = "结束时间:<color=#249003>活动已结束</color>";
|
}
|
|
this.time_val_rt.string = _str;
|
}
|
},
|
setData: function setData(data) {
|
var self = this;
|
var text = data.client_reward;
|
text = text.replace("(", "(");
|
text = text.replace(")", ")");
|
self.dec_val.getComponent(cc.Label).string = text; // --物品id
|
|
var item_id;
|
var item_list = Utils.keyfind('aim_args_key', 4, data.aim_list[0].aim_args) || null;
|
|
if (item_list) {
|
item_id = item_list.aim_args_val;
|
}
|
|
if (item_id) {
|
self.action_item_id = item_id;
|
var config = Utils.getItemConfig(item_id);
|
|
if (config && self.item_icon) {
|
var head_icon = PathTool.getItemRes(config.icon);
|
self.item_icon.setScale(0.4);
|
this.loadRes(head_icon, function (res) {
|
self.item_icon.getComponent(cc.Sprite).spriteFrame = res;
|
}.bind(this));
|
}
|
|
var count = self.role_vo.getActionAssetsNumByBid(item_id);
|
self.item_count.getComponent(cc.Label).string = count;
|
}
|
|
if (self.rewardList) return;
|
self.rewardList = []; // --道具列表
|
|
var scale = 0.9;
|
var meter = 120;
|
|
for (var i = 0; i < data.item_effect_list.length; ++i) {
|
var v = data.item_effect_list[i];
|
var node = new cc.Node();
|
node.width = meter * scale;
|
node.height = meter * scale;
|
var item_node = ItemsPool.getInstance().getItem("backpack_item");
|
item_node.setDefaultTip();
|
item_node.setParent(node);
|
item_node.initConfig(false, scale, false, true);
|
item_node.show();
|
item_node.setData({
|
bid: v.bid,
|
num: 1
|
});
|
|
if (v.effect_1 > 0) {
|
var itemConfig = Utils.getItemConfig(v.bid);
|
|
if (itemConfig && itemConfig.quality >= 4) {
|
item_node.showItemEffect(true, 263, PlayerAction.action_1, true, 1.1);
|
} else {
|
item_node.showItemEffect(true, 263, PlayerAction.action_2, true, 1.1);
|
}
|
}
|
|
this.rewardList.push(item_node);
|
this.viewContent.addChild(node);
|
}
|
},
|
// 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
|
onDelete: function onDelete() {
|
this.action_item_id = null;
|
this.rewardList = null;
|
this.holiday_bid = null;
|
|
if (this.time_tichet) {
|
gcore.Timer.del(this.time_tichet);
|
this.time_tichet = null;
|
}
|
|
if (this.rewardList) {
|
for (var i = 0; i < this.rewardList.length; ++i) {
|
if (this.rewardList[i].deleteMe) {
|
this.rewardList[i].deleteMe();
|
}
|
}
|
}
|
|
if (this.role_lev_event) {
|
this.role_vo.unbind(this.role_lev_event);
|
this.role_lev_event = null;
|
}
|
}
|
});
|
|
cc._RF.pop();
|