106 lines
2.7 KiB
JavaScript
106 lines
2.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '79d14f+PM9OeaCuQ7AOt7tg', 'cmp.act.vipLevel.wnd');
|
|
// Scripts/mod/acts/vipLevel/cmp.act.vipLevel.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* VIP升级
|
|
*
|
|
******************************************************************/
|
|
|
|
var ActPage = require("act.page.base");
|
|
var FxSVC = require("nx.fx.sv.expand");
|
|
var RoleController = require("role_controller");
|
|
cc.Class({
|
|
"extends": ActPage,
|
|
properties: {
|
|
lstTask: {
|
|
"default": null,
|
|
type: FxSVC
|
|
},
|
|
nodVIP: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 初始化
|
|
build: function build(_data) {
|
|
this._super(_data);
|
|
|
|
// 活动监听
|
|
this.mod.vbind(this, [["VipTasks", this.freshTask.bind(this)]]);
|
|
|
|
// 角色属性监听
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
|
if (this.role_vo) {
|
|
this.handler_role = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, val) {
|
|
var _this = this;
|
|
// console.log( 'HERO ATTR: ', key, val );
|
|
if (key == 'vip_exp') {
|
|
this.scheduleOnce(function () {
|
|
_this.freshVip();
|
|
}, 0.1);
|
|
}
|
|
}, this);
|
|
}
|
|
},
|
|
onEnable: function onEnable() {
|
|
this.mod.reqBaseData();
|
|
this.freshVip();
|
|
},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 角色监听解除
|
|
if (this.handler_role && this.role_vo) {
|
|
this.role_vo.unbind(this.handler_role);
|
|
this.handler_role = null;
|
|
this.role_vo = null;
|
|
}
|
|
|
|
// 活动监听解除
|
|
if (this.mod) {
|
|
this.mod.vunbind(this);
|
|
}
|
|
this._super();
|
|
},
|
|
// VIP刷新
|
|
freshVip: function freshVip() {
|
|
if (!this.role_vo) {
|
|
return;
|
|
}
|
|
var cfg = game.configs.vip_data.data_get_reward;
|
|
var lev = this.role_vo.vip_lev;
|
|
var now = this.role_vo.vip_exp;
|
|
var total = lev + 1 < 13 ? cfg[lev + 1].gold : cfg[lev].gold;
|
|
nx.gui.setString(this.nodVIP, "vip/num", lev);
|
|
nx.gui.setString(this.nodVIP, "exp", now + "/" + total);
|
|
var cmp = nx.gui.getComponent(this.nodVIP, "prog", cc.ProgressBar);
|
|
if (cmp) {
|
|
cmp.progress = parseFloat(now / total);
|
|
}
|
|
},
|
|
// 任务刷新
|
|
freshTask: function freshTask(_task) {
|
|
// 0不可领取 1可领取 2已领取
|
|
var PR = [2, 1, 3];
|
|
this.tasks = nx.dt.objClone(_task);
|
|
this.tasks.sort(function (a, b) {
|
|
if (a.status == b.status) {
|
|
return a.id - b.id;
|
|
}
|
|
return PR[a.status] - PR[b.status];
|
|
});
|
|
var cfg = game.configs.vip_data.data_lev_gift;
|
|
for (var i in this.tasks) {
|
|
var task = this.tasks[i];
|
|
task.level = task.id;
|
|
task.rewards = cfg[task.id].reward;
|
|
task.mod = this.mod;
|
|
}
|
|
this.lstTask.rebuild(this.tasks);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |