Files
fc/dev/project/library/imports/66/66683198-2ccc-410a-84db-742fa51cbb4f.js
T
2026-05-24 10:21:26 +08:00

200 lines
7.5 KiB
JavaScript

"use strict";
cc._RF.push(module, '66683GYLMxBCoTbdC+lHLtP', 'cmp.payment.vip.page');
// Scripts/mod/payment/cmp/cmp.payment.vip.page.js
"use strict";
/******************************************************************
*
* VIP页面
*
******************************************************************/
var MenuPage = require("cmp.com.menu.page");
var FXTog = require("nx.fx.togs");
var VipController = require("vip_controller");
var RoleController = require("role_controller");
cc.Class({
"extends": MenuPage,
properties: {
nodVipLev: {
"default": null,
type: cc.Node
},
nodTogs: {
"default": null,
type: FXTog
},
nodShow: {
"default": null,
type: cc.Node
},
nodVipLst: {
"default": null,
type: cc.Node
}
},
onLoad: function onLoad() {
this.alreadyBuy = [];
this.onTouch = 0;
this.nodTogs.posTog = this.onTouchChange.bind(this);
var cfg = game.configs.vip_data.data_get_reward;
this.cfgs = cfg;
var vip = RoleController.getInstance().getRoleVo().vip_lev;
this.vip = vip;
var count = Object.keys(cfg).length;
var cmp = nx.gui.getComponent(this.nodShow, "extItems", "cmp.common.itemlayout");
var spcmp = nx.gui.getComponent(this.nodShow, "gift/view/spgift", "cmp.common.itemlayout");
// 角色属性监听
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' || key == 'vip_lev') {
this.scheduleOnce(function () {
_this.freshVip();
}, 0.1);
}
}, this);
}
cmp.rebuild([]);
spcmp.rebuild([]);
nx.gui.gocChildren(this.nodTogs, "", count);
for (var i in cfg) {
var _vip = cfg[i];
var nod = this.nodTogs.node.children[i];
nx.gui.setStringRich(nod, "on/txt", _vip.lev != 0 ? nx.text.format("VIPTipRich", _vip.lev) : nx.text.format("VIPTipRich", ""));
nx.gui.setString(nod, "off/txt", nx.text.format("VIPTip", _vip.lev));
}
this.vbind([["VIPBuyGifts", this.onFreshBuyInfo.bind(this)], ["VIPMMSp", this.onFreshGetExt.bind(this)]]);
// this.nodTogs.rebuildTogs();
// this.togMenus.togTo( 0 );
// this.activeMenus( 1 );
// Tog监听
this.nodTogs.togTo(0);
this.onTogMenus(0);
},
freshVip: function freshVip() {
var vip = RoleController.getInstance().getRoleVo().vip_lev;
this.vip = vip;
nx.gui.setString(this.nodVipLev, "panel/level/txt", vip);
if (this.cfgs) {
var total = vip + 1 < 13 ? this.cfgs[vip + 1].gold : this.cfgs[13].gold;
var now = RoleController.getInstance().getRoleVo().vip_exp;
nx.gui.setString(this.nodVipLev, "panel/prog", now + "/" + total);
var cmp = nx.gui.getComponent(this.nodVipLev, "panel/bar", cc.ProgressBar);
if (cmp) {
cmp.progress = parseFloat(now / total);
}
nx.gui.setStringRich(this.nodVipLev, "panel/tip", nx.text.format("ChargeTip", vip + 1 <= 13 ? total - now : 0, vip + 1 <= 13 ? vip + 1 : 13));
}
},
onEnable: function onEnable() {
this.freshVip();
VipController.getInstance().sender16707();
this.nodTogs.togTo(this.vip);
this.scv = nx.gui.getComponent(this.nodTogs.node.parent.parent, "", cc.ScrollView);
this.onTogMenus(this.vip);
if (this.vip <= 13 && this.vip >= 9) {
this.scv.scrollToBottom(0.01);
} else {
if (this.scv) {
var posp = cc.v2(0, this.vip * 90);
this.scv.setContentPosition(posp); // scrollTo
}
}
},
onDisable: function onDisable() {
var cmp = nx.gui.getComponent(this.nodShow, "extItems", "cmp.common.itemlayout");
var spcmp = nx.gui.getComponent(this.nodShow, "gift/view/spgift", "cmp.common.itemlayout");
cmp.rebuild([]);
spcmp.rebuild([]);
},
onTouchChange: function onTouchChange(_index) {
var cmp = nx.gui.getComponent(this.nodShow, "extItems", "cmp.common.itemlayout");
var spcmp = nx.gui.getComponent(this.nodShow, "gift/view/spgift", "cmp.common.itemlayout");
cmp.rebuild([]);
spcmp.rebuild([]);
this.onTogMenus(_index);
},
onTogMenus: function onTogMenus(_index) {
var cmp = nx.gui.getComponent(this.nodShow, "extItems", "cmp.common.itemlayout");
var spcmp = nx.gui.getComponent(this.nodShow, "gift/view/spgift", "cmp.common.itemlayout");
// cmp.rebuild( [] );
// spcmp.rebuild( [] );
this.onTouch = _index;
var extRewards = game.configs.charge_data.data_supre_reward_data;
var vipExt = extRewards[_index];
var vfg = this.cfgs[_index];
if (cmp) {
cmp.rebuild(vipExt.reward);
}
nx.gui.setStringRich(this.nodShow, "vip_title", nx.text.format("VIPPrivilege", _index));
nx.gui.setStringRich(this.nodShow, "desc/view/content/txt", vfg.spe_desc);
nx.gui.setString(this.nodShow, "normal/cost", nx.text.getKey("act_limit_buy1") + vfg.old_price[0][1]);
nx.gui.setString(this.nodShow, "op/price", vfg.price[0][1] == 0 ? nx.text.getKey("Free") : vfg.price[0][1]);
nx.gui.setString(this.nodShow, "cannot/price", vfg.price[0][1] == 0 ? nx.text.getKey("Free") : vfg.price[0][1]);
nx.bridge.setIconS(this.nodShow, "op/icon", vfg.price[0][0]);
nx.bridge.setIconS(this.nodShow, "cannot/icon", vfg.price[0][0]);
nx.bridge.setIconS(this.nodShow, "normal/icon", vfg.price[0][0]);
if (spcmp) {
spcmp.rebuild(vfg.items);
}
nx.gui.setStringRich(this.nodShow, "desc_tip", nx.text.format("lab_vipChargePrivilege", 3, vfg.gold));
nx.gui.setActive(this.nodShow, "op", !nx.dt.arrMember(this.alreadyBuy, _index) && this.vip >= _index);
nx.gui.setActive(this.nodShow, "cannot", !nx.dt.arrMember(this.alreadyBuy, _index) && this.vip < _index);
// let cmp =
nx.gui.setActive(this.nodShow, "sold", nx.dt.arrMember(this.alreadyBuy, _index));
nx.gui.setActive(this.nodShow, "claim", this.vip == _index);
var btn = nx.gui.getComponent(this.nodShow, "claim", cc.Button);
if (btn) {
btn.interactable = this.vip == _index && this.status == 1;
nx.gui.setString(this.nodShow, "claim/price", this.status != 2 ? nx.text.getKey("Get") : nx.text.getKey("Got"));
nx.gui.setOutlineColor(this.nodShow, "claim/price", this.vip == _index && this.status == 1 ? new cc.color("#b85833") : cc.Color.BLACK);
}
// nx.gui.setActive( this.nodShow, "got", this.status == 2 );
nx.gui.find(this.nodShow, "op").zIndex = vfg.lev;
},
onFreshBuyInfo: function onFreshBuyInfo(_buyinfo) {
var _this2 = this;
this.alreadyBuy = [];
if (nx.dt.arrNEmpty(_buyinfo)) {
_buyinfo.forEach(function (_info) {
_this2.alreadyBuy.push(_info.lev);
});
}
this.onTogMenus(this.onTouch);
},
onFreshGetExt: function onFreshGetExt(_status) {
this.nodTogs.node.children.forEach(function (_nod) {
nx.gui.setActive(_nod, "off/tip", false);
});
this.status = _status;
var vip = RoleController.getInstance().getRoleVo().vip_lev;
var nod = this.nodTogs.node.children[vip];
nx.gui.setActive(nod, "off/tip", this.status == 1);
this.onTogMenus(this.onTouch);
},
onTouchGet: function onTouchGet() {
VipController.getInstance().sender16708();
// console.log( );
},
onTouchBuy: function onTouchBuy(_btn) {
var vip = RoleController.getInstance().getRoleVo().vip_lev;
if (vip < _btn.zIndex) {
nx.tbox(nx.text.format("tips_vipBuy", _btn.zIndex));
return;
}
VipController.getInstance().sender16711(_btn.zIndex);
// console.log( );
}
});
cc._RF.pop();