Files
fc/dev/project/library/imports/01/01f1b1e4-cf91-424d-a4dd-e373ce183a3f.js
2026-05-24 10:21:26 +08:00

215 lines
7.8 KiB
JavaScript

"use strict";
cc._RF.push(module, '01f1bHkz5FCTaTd43POGDo/', 'cmp.payment.gift.page');
// Scripts/mod/payment/cmp/cmp.payment.gift.page.js
"use strict";
/******************************************************************
*
* VIP页面
*
******************************************************************/
var MenuPage = require("cmp.com.menu.page");
var VipController = require("vip_controller");
var TipsController = require("tips_controller");
var Payment = require("payment.mod");
var NxSpine = require("nx.fx.spine");
cc.Class({
"extends": MenuPage,
properties: {
nodGifts: {
"default": null,
type: cc.Node
},
nodScores: {
"default": null,
type: cc.Node
},
nodOp: {
"default": null,
type: cc.Node
},
spRole: {
"default": null,
type: NxSpine
},
nodCloseAllDesc: {
"default": null,
type: cc.Node
}
},
onLoad: function onLoad() {
var _this = this;
this.cfg = game.configs.daily_charge_data;
this.spRole.load("resDB/models/H30098/show", function (_e) {
if (!_e) {
_this.spRole.action("drama1", true);
} else {
_this.spRole.stop();
}
});
// let
var count = Object.keys(this.cfg.data_gift_info).length;
var rewards = nx.gui.find(this.nodScores, "rewards").children;
var len = Object.keys(this.cfg.data_reward).length;
this.total = this.cfg.data_reward[len].num;
nx.gui.setString(this.nodScores, "point/num", 0);
nx.gui.getComponent(this.nodScores, "prog", cc.ProgressBar).progress = 0;
nx.gui.gocChildren(this.nodGifts, "", count);
// nx.gui.setString( this.nodOp, "now/cost", Payment.getInstance().fmtPrice(this.cfg.data_constant.sevenday_charge_price.val ) );
// nx.gui.setString( this.nodOp, "now/before", Payment.getInstance().fmtPrice( 147 ) );
for (var i = 0; i < rewards.length; i++) {
var nod = this.nodGifts.children[i];
var giftinfo = this.cfg.data_gift_info[i + 1];
if (giftinfo) {
var cmp = nx.gui.getComponent(nod, "items", "cmp.common.itemlayout");
if (cmp) {
cmp.rebuild(giftinfo.reward);
}
nx.gui.find(nod, "buy").zIndex = giftinfo.id;
nx.gui.setString(nod, "buy/cost", giftinfo.money == 0 ? nx.text.getKey("Free") : nx.text.format("CostDay", Payment.getInstance().fmtPrice(giftinfo.money)));
nx.gui.setActive(nod, "sold", false);
}
var reward = rewards[i];
var rewardinfo = this.cfg.data_reward[i + 1];
if (reward && rewardinfo) {
nx.gui.setString(reward, "point", rewardinfo.num); //payment.daily.free
var _cmp = nx.gui.getComponent(reward, "show/rewards", "cmp.common.itemlayout");
if (_cmp) {
_cmp.rebuild(rewardinfo.reward);
}
nx.gui.find(reward, "touch").zIndex = rewardinfo.id;
nx.gui.setActive(reward, "get", false);
nx.gui.find(reward, "get").zIndex = rewardinfo.id;
nx.gui.setActive(reward, "ico_open", false);
nx.gui.setActive(reward, "show", false);
// nx.gui.setActive( reward, "tip", giftinfo.money == 0 );
}
}
nx.gui.setActive(this.nodCloseAllDesc, "", false);
this.vbind([["DailySpGift", this.onFreshBuyInfo.bind(this)]]);
},
onEnable: function onEnable() {
VipController.getInstance().reqDailySpGift();
},
onTouchHideAllDesc: function onTouchHideAllDesc() {
var chd = nx.gui.find(this.nodScores, "rewards").children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
nx.gui.setActive(nod, "show", false);
}
nx.gui.setActive(this.nodCloseAllDesc, "", false);
},
onTouchShow: function onTouchShow(_btn) {
var index = parseInt(_btn.zIndex - 1);
var chd = nx.gui.find(this.nodScores, "rewards").children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
if (i != index) {
nx.gui.setActive(nod, "show", false);
}
}
var nodShow = nx.gui.find(chd[index], "show");
nx.gui.setActive(nodShow, "", !nodShow.active);
nx.gui.setActive(this.nodCloseAllDesc, "", nodShow.active == true);
},
/***
* [21041]:{"gift":[{"id":1,"status":2},{"id":2,"status":0},{"id":3,"status":0}],"num":0,"ids":[],"is_activate":0}
*/
onFreshBuyInfo: function onFreshBuyInfo(_buyinfo) {
var _this2 = this;
if (!_buyinfo) {
return;
}
this.gifts = _buyinfo.gift;
this.chargestatus = _buyinfo.is_activate;
if (nx.dt.arrNEmpty(this.gifts)) {
this.gifts.forEach(function (_gift) {
if (_gift) {
nx.gui.setString(_this2.nodGifts.children[_gift.id - 1], "buy/cost", _gift.status != 0 ? nx.text.getKey("Get") : nx.text.format("CostDay", Payment.getInstance().fmtPrice(_this2.cfg.data_gift_info[_gift.id].money)));
nx.gui.setActive(_this2.nodGifts.children[_gift.id - 1], "buy", _gift.status != 2);
nx.gui.setActive(_this2.nodGifts.children[_gift.id - 1], "buy/tip", _gift.status != 2 && _gift.id - 1 == 0);
nx.gui.setActive(_this2.nodGifts.children[_gift.id - 1], "sold", _gift.status == 2);
if (_gift.id == 2) {
nx.gui.setString(_this2.nodGifts.children[_gift.id - 1], "sold/txt", nx.text.format("RemainDay", _buyinfo.is_activate));
} else if (_gift.id == 3) {
nx.gui.setString(_this2.nodGifts.children[_gift.id - 1], "sold/txt", nx.text.format("RemainDay", _buyinfo.end_day));
} else {
nx.gui.setString(_this2.nodGifts.children[_gift.id - 1], "sold/txt", nx.text.getKey("Got"));
}
}
});
}
nx.gui.setString(this.nodScores, "point/num", _buyinfo.num);
// nx.gui.setActive( this.nodOp, "charged", _buyinfo.is_activate == 1 );
// nx.gui.setActive( this.nodOp, "now", _buyinfo.is_activate == 0 );
nx.gui.getComponent(this.nodScores, "prog", cc.ProgressBar).progress = _buyinfo.num / this.total;
this.freshReward(_buyinfo.ids, _buyinfo.num);
// nx.gui.setActive();
// console.log( "購買信息" + JSON.stringify( _buyinfo ) );
},
freshReward: function freshReward(_rewards, _num) {
var rewards = _rewards;
var num = _num;
var rewardinfo = this.cfg.data_reward;
var nodrewards = nx.gui.find(this.nodScores, "rewards").children;
if (nx.dt.arrEmpty(rewards)) {
for (var i in rewardinfo) {
var reward = rewardinfo[i];
if (reward) {
nx.gui.setActive(nodrewards[reward.id - 1], "get", num >= reward.num);
}
}
} else {
for (var _i in rewardinfo) {
var _reward = rewardinfo[_i];
if (_reward) {
nx.gui.setActive(nodrewards[_reward.id - 1], "get", num >= _reward.num);
}
rewards.forEach(function (_re) {
nx.gui.setActive(nodrewards[_re.id - 1], "get", false);
});
}
}
},
//[21041]:{"gift":[{"id":1,"status":0},{"id":2,"status":0},{"id":3,"status":0}],"num":0,"ids":[],"is_activate":0}
onTouchBuy: function onTouchBuy(_btn) {
var id = _btn.zIndex;
var chargeid = this.cfg.data_gift_info[id].charge_id;
if (this.gifts[id - 1].status == 0) {
if (id != 1) {
var msg = "pay " + chargeid;
Payment.getInstance().reqPayment(chargeid);
} else {
VipController.getInstance().reqGetDailySpGift(id);
}
} else {
VipController.getInstance().reqGetDailySpGift(id);
}
},
onTouchBuyOnce: function onTouchBuyOnce(_btn) {
if (this.chargestatus != 0) {
nx.tbox("Charged");
return;
}
var chargeid = this.cfg.data_constant.sevenday_charge.val;
var msg = "pay " + chargeid;
Payment.getInstance().reqPayment(chargeid);
},
onTouchGet: function onTouchGet(_btn) {
var id = _btn.zIndex;
VipController.getInstance().reqGetDailyReward(id);
},
onTouchHelp: function onTouchHelp() {
var TC = TipsController.getInstance();
var explain = this.cfg.data_desc[1];
TC.showTextPanel(explain.name, explain.desc);
}
});
cc._RF.pop();