function showWelfareStatusTips(status) { if (0 === status) return; if (TipsUtils.showErrorCodeTips) TipsUtils.showErrorCodeTips(status); else TipsUtils.showTipsDownToUp(GameConfig.ServerCode[status] || "操作失败"); } function appendWelfareReward(rewards, rewardString) { game.CostUtils.parseCostString(rewardString).forEach(function (reward) { reward.count > 0 && rewards.push(reward.itemId + ":" + reward.count); }); } function getWelfareItemIcon(itemId) { return game.URLConfig.getIcon(Global.gameProxy.getItemImageId(itemId)); } function isSameWelfareDay(leftTime, rightTime) { if (!leftTime || !rightTime) return !1; return new Date(1e3 * leftTime).toDateString() === new Date(1e3 * rightTime).toDateString(); } var FuliItem1 = class FuliItem1 extends eui.Component { childrenCreated() { super.childrenCreated(); } }; __reflect(FuliItem1.prototype, "FuliItem1"); var FuliProssbAR = class FuliProssbAR extends eui.Component { childrenCreated() { (super.childrenCreated(), this.group && this.imgmask && (this.group.mask = this.imgmask)); } setPross(value, maxValue) { const max = Math.max(1, int(maxValue)), current = Math.max(0, int(value)); let percent = current / max; percent > 1 && (percent = 1); (this.imgProssBar && (this.imgProssBar.x = this.imgProssBar.width * percent - this.imgProssBar.width), this.prosslabel && (this.prosslabel.text = current + "/" + max)); } }; __reflect(FuliProssbAR.prototype, "FuliProssbAR"); var FuliTextFieldItem = class FuliTextFieldItem extends eui.Component { constructor() { super(); this.skinName = TextFiledItemSkin; } childrenCreated() { super.childrenCreated(); } }; __reflect(FuliTextFieldItem.prototype, "FuliTextFieldItem"); var FuliItem2 = class FuliItem2 extends eui.Component { constructor() { super(); this.pageIndex = 0; this.pageNum = 14; this.privilegeFields = ["arena", "playground_frequency", "turntable_frequency"]; this.privilegeLabels = ["每天可挑战玩家次数增加", "游乐场免费进入次数", "大转盘免费抽取次数"]; this.privilegeCountByVip = [0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]; } childrenCreated() { (super.childrenCreated(), this.scrolls && (this.scrolls.viewport = this.g1), this.payButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onPay, this), this.buyButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGiftClick, this), this.leftButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onLeft, this), this.rightButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRight, this)); const vipLevel = FuliMannager.getInstance().getVipLevel(); this.pageIndex = Math.max(0, vipLevel - 1); this.pageNum = Math.max(0, Object.keys(Global.gameProxy.getVipConfig()).length - 1); this.updata(); } onPay() { (game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_PAY), game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FULI)); } onGiftClick() { FuliMannager.getInstance().hasVipGiftToGet() ? (game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FULI_GET), game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FULI)) : TipsUtils.showTipsDownToUp("您已领取礼包"); } onLeft() { (this.pageIndex > 0 && this.pageIndex--, this.updataTextfiledGroup(this.pageIndex + 1)); } onRight() { (this.pageIndex < this.pageNum && this.pageIndex++, this.updataTextfiledGroup(this.pageIndex + 1)); } updata() { const vipLevel = FuliMannager.getInstance().getVipLevel(), nextVipLevel = Math.min(vipLevel + 1, Math.max(1, Object.keys(Global.gameProxy.getVipConfig()).length)), nextVipConfig = Global.gameProxy.getVipConfigForID(nextVipLevel) || {}, vipData = FuliMannager.getInstance().fuliData || {}, needExp = int(nextVipConfig.recharge_amount), currentExp = int(vipData.exp), remainingExp = Math.max(0, needExp - currentExp); ((this.vipLabel.text = "VIP " + vipLevel), this.gs && (this.gs.visible = vipLevel > 0), this.imgNoVip && (this.imgNoVip.visible = 0 == vipLevel), (this.payGemLabel1.text = vipLevel > 0 ? vipLevel + "" : "1"), (this.buyButton.enabled = vipLevel > 0 && FuliMannager.getInstance().hasVipGiftToGet()), (this.buyButton.label = this.buyButton.enabled ? "领取" : "已领取"), 0 == vipLevel && ((this.buyButton.enabled = !1), (this.buyButton.label = "领取")), this.prossBar.setPross(currentExp, needExp), (this.gemLabel.text = remainingExp + ""), (this.vipLabel3.text = nextVipLevel + ""), this.updataTextfiledGroup(this.pageIndex + 1)); } updataTextfiledGroup(vipLevel) { const config = Global.gameProxy.getVipConfigForID(vipLevel) || {}; ((this.vipLabel1.text = (config.id || vipLevel) + ""), (this.vipLabel2.text = (config.id || vipLevel) + ""), (this.payGemLabel.text = int(config.recharge_amount) + ""), this.gt.removeChildren()); const privilegeCount = this.privilegeCountByVip[Math.max(0, vipLevel - 1)] || 0; for (let index = 0; index < privilegeCount; index++) { const item = new FuliTextFieldItem(), field = this.privilegeFields[index], value = null == config[field] ? 0 : config[field]; (this.gt.addChild(item), (item.y = 21 * index), (item.strLabel.text = this.privilegeLabels[index] + " " + value)); } } }; __reflect(FuliItem2.prototype, "FuliItem2"); var FulilibaoItem = class FulilibaoItem extends eui.Component { childrenCreated() { super.childrenCreated(); } }; __reflect(FulilibaoItem.prototype, "FulilibaoItem"); var FuliLibaoTips = class FuliLibaoTips extends eui.Component { constructor() { super(); this.itemARR = []; this.skinName = FuliLibaoPanelSkin; } static getInstance() { return (this._instance || (this._instance = new FuliLibaoTips()), this._instance); } childrenCreated() { (this.itemARR.push(this.item0), this.itemARR.push(this.item1), this.itemARR.push(this.item2), this.LingquButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onLingqu, this), this.btnClose.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnClose, this), game.EventManager.instance.addEvent(SysNotify.GETVIPREWARD_UPDATA, this.updata, this), this.updata(), game.UIUtils.addButtonScaleEffects(this)); } onRemoved() { (super.onRemoved && super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.GETVIPREWARD_UPDATA, this.updata, this)); } onLingqu() { FuliMannager.getInstance().sendNetGetAward(); } onBtnClose() { game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FULI_GET); } clearItemViews() { ((this.icons.source = ""), (this.numLabel.text = "")); for (let index = 0; index < this.itemARR.length; index++) ((this.itemARR[index].imgicon.source = ""), (this.itemARR[index].numLabel.text = ""), (this.itemARR[index].nameLabel.text = "")); } updata() { this.clearItemViews(); const vipLevel = FuliMannager.getInstance().getVipLevel(), config = Global.gameProxy.getVipConfigForID(vipLevel); ((this.vipLabel.text = "VIP" + vipLevel), (this.LingquButton.enabled = vipLevel > 0 && FuliMannager.getInstance().hasVipGiftToGet())); if (!config) return; const fixedReward = game.CostUtils.parseCostString(config.fixed_reward_id)[0]; fixedReward && ((this.icons.source = getWelfareItemIcon(fixedReward.itemId)), (this.numLabel.text = fixedReward.count + "")); let itemIndex = 0; for (let index = 1; index <= 3; index++) { const reward = game.CostUtils.parseCostString(config["cycle_bonus_id" + index])[0]; if (!reward || reward.count <= 0 || !this.itemARR[itemIndex]) continue; const itemConfig = Global.gameProxy.getItemConfig(reward.itemId); ((this.itemARR[itemIndex].imgicon.source = getWelfareItemIcon(reward.itemId)), (this.itemARR[itemIndex].numLabel.text = reward.count + ""), (this.itemARR[itemIndex].nameLabel.text = itemConfig.name), itemIndex++); } } }; __reflect(FuliLibaoTips.prototype, "FuliLibaoTips"); var FuliMannager = class FuliMannager extends egret.EventDispatcher { constructor() { super(); this.zyData = []; this.fuliData = { level: 0, exp: 0, is_get_fix_gift: 1, is_get_week_gift: 1, last_get_week_gift_time: 0 }; } static getInstance() { return (this._instance || (this._instance = new FuliMannager()), this._instance); } setVipData(data) { this.fuliData = Object.assign({}, this.fuliData, data || {}); } setCardData(list) { this.zyData = Array.isArray(list) ? list : []; } getVipLevel() { return int(this.fuliData && this.fuliData.level); } hasVipGiftToGet() { return this.getVipLevel() > 0 && (0 == int(this.fuliData.is_get_fix_gift) || 0 == int(this.fuliData.is_get_week_gift)); } getisZY(itemId) { for (let index = 0; index < this.zyData.length; index++) if (this.zyData[index].item_id == itemId) return this.zyData[index]; return null; } getCardRemainingCount(itemId) { const card = this.getisZY(itemId); return card ? Math.max(0, int(card.count)) : 0; } canGetCardGift(itemId) { const card = this.getisZY(itemId); return !!card && int(card.count) > 0 && !isSameWelfareDay(int(card.last_get_gift_time), DateTimer.instance.now); } sendNetGetAward() { Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/get-vip-gift", {}, this.onSendNetVipGift.bind(this)); } onSendNetVipGift(response) { if (0 !== response.status) return void showWelfareStatusTips(response.status); const vipLevel = this.getVipLevel(), config = Global.gameProxy.getVipConfigForID(vipLevel), rewards = []; if (!config) return void TipsUtils.showTipsDownToUp("VIP配置不存在"); 0 == int(this.fuliData.is_get_fix_gift) && appendWelfareReward(rewards, config.fixed_reward_id); if (0 == int(this.fuliData.is_get_week_gift)) for (let index = 1; index <= 3; index++) appendWelfareReward(rewards, config["cycle_bonus_id" + index]); rewards.length > 0 ? Global.playerProxy.addItem1(rewards.join(",")) : TipsUtils.showTipsDownToUp("您已领取礼包"); ((this.fuliData.is_get_fix_gift = 1), (this.fuliData.is_get_week_gift = 1), (this.fuliData.last_get_week_gift_time = DateTimer.instance.now), game.EventManager.instance.dispatch(SysNotify.GETVIPREWARD_UPDATA), game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE), game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FULI_GET)); } sendNetzyGetAward(itemId) { this.curid = itemId; Global.netProxy.sendRequest( GameConfig.SERVER_PATH + "comm/get-card-gift", { item_id: itemId }, this.onSendNetCardGift.bind(this) ); } onSendNetCardGift(response) { if (0 !== response.status) return void showWelfareStatusTips(response.status); const config = Global.gameProxy.getzyConfigForID(this.curid), card = this.getisZY(this.curid); if (config) Global.playerProxy.addItem1(config.diamonds_day_id); card && ((card.count = Math.max(0, int(card.count) - 1)), (card.last_get_gift_time = DateTimer.instance.now)); (game.EventManager.instance.dispatch(SysNotify.GETVIPREWARD_UPDATA), game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE)); } }; __reflect(FuliMannager.prototype, "FuliMannager"); var FuliMediter = class FuliMediter extends BaseMediator { constructor() { super("FuliMediter"); } listNotificationInterests() { return [PanelNotify.OPEN_FULI, PanelNotify.CLOSE_FULI]; } onRegister() { super.onRegister(); } showViewComponent(layer = 7) { ((this.viewComponent = new FuliPanel()), this.showUI(this.viewComponent, !0, 0, 0, layer)); } handleNotification(notification) { switch (notification.getName()) { case PanelNotify.OPEN_FULI: Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/get-vip", {}, this.onGetVip.bind(this)); break; case PanelNotify.CLOSE_FULI: this.closeViewComponent(10); } } onGetVip(response) { if (0 !== response.status) return void showWelfareStatusTips(response.status); (FuliMannager.getInstance().setVipData(response.data || {}), (Global.playerProxy.playerData.vip = FuliMannager.getInstance().getVipLevel()), game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE), Global.netProxy.sendRequest(GameConfig.SERVER_PATH + "comm/get-card", {}, this.onGetCard.bind(this))); } onGetCard(response) { 0 === response.status ? FuliMannager.getInstance().setCardData(response.data || []) : FuliMannager.getInstance().setCardData([]); this.showViewComponent(10); FuliMannager.getInstance().hasVipGiftToGet() && game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FULI_GET); } static NAME = "FuliMediter"; }; __reflect(FuliMediter.prototype, "FuliMediter"); var FulibaoTipsMediter = class FulibaoTipsMediter extends BaseMediator { constructor() { super("FulibaoTipsMediter"); } listNotificationInterests() { return [PanelNotify.OPEN_FULI_GET, PanelNotify.CLOSE_FULI_GET]; } onRegister() { super.onRegister(); } showViewComponent(layer = 7) { ((this.viewComponent = new FuliLibaoTips()), this.showUI(this.viewComponent, !0, 0, 0, layer)); } handleNotification(notification) { switch (notification.getName()) { case PanelNotify.OPEN_FULI_GET: this.showViewComponent(6); break; case PanelNotify.CLOSE_FULI_GET: this.closeViewComponent(6); } } static NAME = "FulibaoTipsMediter"; }; __reflect(FulibaoTipsMediter.prototype, "FulibaoTipsMediter"); var FuliPanel = class FuliPanel extends game.BasePanel { constructor() { super(); this.isFullScreen = !0; this.isVisibleAnimate = !0; this.skinName = FuliPanelSkin; } createChildren() { (super.createChildren(), this.commonPanel.setPanelWidth(620), this.commonPanel.setPanelHeight(710), this.commonPanel.setTitle("fuli_json.fuli_title_png")); } childrenCreated() { (super.childrenCreated(), this.updataAll()); } onAdded() { (super.onAdded(), this.item0.buyButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBuyWeekCard, this), this.item0.getButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGetWeekCard, this), this.item1.buyButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBuyMonthCard, this), this.item1.getButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGetMonthCard, this), game.EventManager.instance.addEvent(SysNotify.GETVIPREWARD_UPDATA, this.updataAll, this)); } onRemoved() { (super.onRemoved(), this.item0.buyButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onBuyWeekCard, this), this.item0.getButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onGetWeekCard, this), this.item1.buyButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onBuyMonthCard, this), this.item1.getButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onGetMonthCard, this), game.EventManager.instance.removeEvent(SysNotify.GETVIPREWARD_UPDATA, this.updataAll, this)); } onBuyWeekCard() { this.openPayPanel(); } onBuyMonthCard() { this.openPayPanel(); } openPayPanel() { (game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_PAY), game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FULI)); } onGetWeekCard() { FuliMannager.getInstance().canGetCardGift(601000) ? FuliMannager.getInstance().sendNetzyGetAward(601000) : TipsUtils.showTipsDownToUp("今日已领取"); } onGetMonthCard() { FuliMannager.getInstance().canGetCardGift(601001) ? FuliMannager.getInstance().sendNetzyGetAward(601001) : TipsUtils.showTipsDownToUp("今日已领取"); } btnCloseTouchEnded() { game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FULI); } updataAll() { (this.itemall && this.itemall.updata(), this.updataCardItem(this.item0, 601000, "fuli_zhouka_png")); this.updataCardItem(this.item1, 601001, "fuli_yueka_png"); } updataCardItem(target, itemId, iconSource) { const config = Global.gameProxy.getzyConfigForID(itemId) || {}, fixedReward = game.CostUtils.parseCostString(config.fixed_reward_id)[0], dayReward = game.CostUtils.parseCostString(config.diamonds_day_id)[0], card = FuliMannager.getInstance().getisZY(itemId), remainingCount = FuliMannager.getInstance().getCardRemainingCount(itemId), canGet = FuliMannager.getInstance().canGetCardGift(itemId); ((target.gemLabel0.text = int(config.rmb) + ""), (target.gemLabel1.text = fixedReward ? fixedReward.count + "" : "0"), (target.gemLabel2.text = dayReward ? dayReward.count + "" : "0"), (target.nameLabel.text = config.name || ""), (target.imgicon.source = iconSource), (target.gemLabel3.text = remainingCount + ""), (target.buyButton.visible = !card || remainingCount <= 0), (target.getButton.visible = !!card && remainingCount > 0), (target.getButton.enabled = canGet), target.getButton.label && (target.getButton.label = canGet ? "领取" : "已领取")); } }; __reflect(FuliPanel.prototype, "FuliPanel");