hy-farm/muchang/home/web/game/js/main/06-gifts-and-friend-panels.js
2026-05-29 19:54:56 +08:00

1079 lines
38 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var WaitPanel = class WaitPanel extends egret.Sprite {
constructor(e = 1) {
super();
this.bg = new egret.Sprite();
this.w = 0;
this.h = 0;
this.createView();
}
createView() {
((this.w = egret.MainContext.instance.stage.stageWidth),
(this.h = egret.MainContext.instance.stage.stageHeight),
this.bg.graphics.beginFill(0, 0.2),
this.bg.graphics.drawRect(0, 0, this.w, this.h),
this.bg.graphics.endFill(),
(this.bg.width = this.w),
(this.bg.height = this.h),
this.addChild(this.bg),
(this.touchEnabled = !0),
(this.waitImg = new egret.Bitmap()),
(this.waitImg.texture = RES.getRes("loadingcircle_png")),
this.addChild(this.waitImg),
(this.waitImg.x = this.w / 2),
(this.waitImg.y = this.h / 2),
(this.waitImg.anchorOffsetX = this.waitImg.width / 2),
(this.waitImg.anchorOffsetY = this.waitImg.height / 2),
EffectUtils.rotationEffect(this.waitImg, 1e3));
}
};
__reflect(WaitPanel.prototype, "WaitPanel");
var game;
!(function (game) {
const WareHousePanel = class WareHousePanel extends game.BasePanel {
constructor() {
super();
this.isFullScreen = !0;
this.isVisibleAnimate = !0;
this.skinName = new WareHouseSkin();
}
createChildren() {
(super.createChildren(), this.initList(), this.initTab());
}
initList() {
((this.list.dataProvider = null), (this.list.itemRenderer = game.WareHouseItem));
}
initTab() {
const e = ["果实", "种子", "道具"];
((this.tab = new game.Tab(e, this.onTabItemClickCallback.bind(this))),
(this.tab.bottom = 0),
this.groupTab.addChild(this.tab));
}
flushList() {
this.onTabItemClickCallback(this.tab.selectIndex);
}
onTabItemClickCallback(t) {
let e = null;
(0 == t
? (e = Global.playerProxy.getItemByType(ItemType.FRUIT))
: 1 == t
? (e = Global.playerProxy.getItemByType(ItemType.SEED))
: 2 == t && (e = Global.playerProxy.getItemByType(ItemType.PROPS)),
this.updateTabPageByData(e));
}
updateTabPageByData(t) {
t.sort(function (t, e) {
return t.config.id - e.config.id;
});
const e = t.concat(),
i = e.length,
n = Const.WARE_CAPACITY - i;
if (n > 0) for (let a = 0; n > a; a++) e.push(null);
this.list.dataProvider = new eui.ArrayCollection(e);
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_WARE_HOUSE);
}
};
((game.WareHousePanel = WareHousePanel), __reflect(WareHousePanel.prototype, "game.WareHousePanel"));
})(game || (game = {}));
var game;
!(function (game) {
const ExGoldPanel = class ExGoldPanel extends game.BasePanel {
constructor() {
super();
this.isFullScreen = !0;
this.skinName = new ExGoldSkin();
}
createChildren() {
super.createChildren();
const t = Global.gameProxy.getTabelConfigByType("common")[17];
((this.inpDiamond.text = t.min),
(this.labelGold.text = "1"),
(this.commonConfig = t),
(this.tipsLabel.text = "金币兑换钻石比例: " + t.min + ": 1"),
this.inpDiamond.addEventListener(egret.Event.FOCUS_OUT, this.onInpChange, this));
}
onInpChange() {
let t = int(this.inpDiamond.text);
((!this.inpDiamond.text || int(this.inpDiamond.text) < this.commonConfig.min) && (t = this.commonConfig.min),
(this.inpDiamond.text = t + ""),
(this.labelGold.text = t / this.commonConfig.min + ""));
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_EXGOLD);
}
onTouchTap(t) {
switch ((super.onTouchTap(t), t.target)) {
case this.btnEx:
this.exGold();
}
}
exGold() {
const e = this,
i = int(this.inpDiamond.text);
if (i < this.commonConfig.min) return void PopUpManager.popTip("最少兑换的金币:" + this.commonConfig.min);
if (i > Global.playerProxy.playerData.gold) return void PopUpManager.popTip("金币不足");
const n = "是否花费" + i + "金币兑换" + i / this.commonConfig.min + "钻石";
Global.alertMediator.addAlert(n, function () {
const n = GameConfig.SERVER_PATH + "user/gold-exchange-gem";
Global.netProxy.sendRequest(
n,
{
gold: i
},
function (n) {
0 == n.status
? (PopUpManager.popTip("兑换成功!"),
(Global.playerProxy.playerData.gold -= i),
(Global.playerProxy.playerData.gem += i / e.commonConfig.min),
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE))
: TipsUtils.showErrorCodeTips(n.status);
}
);
});
}
};
((game.ExGoldPanel = ExGoldPanel), __reflect(ExGoldPanel.prototype, "game.ExGoldPanel"));
})(game || (game = {}));
var game;
!(function (game) {
const FriendAddPanel = class FriendAddPanel extends game.BasePanel {
constructor() {
super();
this.isFullScreen = !0;
this.isVisibleAnimate = !0;
this.skinName = new FriendAddSkin();
}
createChildren() {
(super.createChildren(),
(this.labelName.text = ""),
(this.labelLv.text = ""),
(this.labelMoney.text = ""),
(this.btnHome.visible = !1));
}
onTouchTap(t) {
super.onTouchTap(t);
const i = t.target;
switch (i) {
case this.btnSearch:
this.searchUser();
break;
case this.btnAdd:
this.goOtherFarm();
}
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND_ADD);
}
goOtherFarm() {
const t = Global.playerProxy.playerData;
this.friendData
? this.friendData.uid == t.id
? PopUpManager.popTip("不能自己添加自己")
: this.mediator.addFriend(this.friendData.uid)
: PopUpManager.popTip("请确认目标存在");
}
searchUser() {
const e = this,
i = parseInt(this.inpID.text);
if (!i) return void PopUpManager.popTip("请输入正确的ID");
this.friendData = null;
const n = GameConfig.SERVER_PATH + "friend/find";
Global.netProxy.sendRequest(
n,
{
find_user_id: i
},
function (i) {
0 == i.status
? ((e.friendData = new game.FriendData(i.data)),
(e.labelName.text = e.friendData.name),
(e.labelLv.text = e.friendData.lv + ""),
(e.labelMoney.text = e.friendData.gold + ""),
(e.btnHome.visible = !0))
: ((e.labelName.text = ""),
(e.labelLv.text = ""),
(e.labelMoney.text = ""),
(e.btnHome.visible = !1),
PopUpManager.popTip("查无此人"));
}
);
}
};
((game.FriendAddPanel = FriendAddPanel), __reflect(FriendAddPanel.prototype, "game.FriendAddPanel"));
})(game || (game = {}));
var game;
!(function (game) {
const FriendAddReqPanel = class FriendAddReqPanel extends game.BasePanel {
constructor() {
super();
this.reqArr = [];
this.pageIndex = 1;
this.pageMax = 1;
this.pageEveNum = 6;
this.isFullScreen = !0;
this.isVisibleAnimate = !0;
this.skinName = new FriendReqSkin();
}
onAdded() {
(super.onAdded(), game.EventManager.instance.addEvent(SysNotify.FRIEND_DEAL_OVER, this.dealApplyOver, this));
}
onRemoved() {
(super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.FRIEND_DEAL_OVER, this.dealApplyOver, this));
}
createChildren() {
(super.createChildren(), this.initList());
}
initList() {
((this.list.dataProvider = null), (this.list.itemRenderer = game.FriendReqItemRender), this.updateListPage(1));
}
onTouchTap(t) {
super.onTouchTap(t);
const i = t.target;
switch (i) {
case this.btnOneKeyOk:
this.pass();
break;
case this.btnOneKeyNo:
this.reject();
break;
case this.btnPrev:
this.changePage(-1);
break;
case this.btnNext:
this.changePage(1);
}
}
pass() {
if (this.reqArr.length > 0) {
this.reqArr.shift();
this.mediator.applyAllReq(1, this.pass.bind(this));
}
}
reject() {
if (this.reqArr.length > 0) {
this.reqArr.shift();
this.mediator.applyAllReq(2, this.reject.bind(this));
}
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND_ADD_REQ);
}
changePage(t, e) {
if ((void 0 === e && (e = !1), e)) this.pageIndex = t;
else {
if (this.pageIndex <= 1 && 0 > t) return;
if (this.pageIndex >= this.pageMax && t > 0) return;
this.pageIndex += t;
}
((this.labelPage.text = this.pageIndex + "/" + this.pageMax), this.updateListPage(this.pageIndex));
}
updateListPage(t) {
const e = (t - 1) * this.pageEveNum;
this.mediator.applyList(e, this.pageEveNum, this.onListData.bind(this));
}
onListData(e) {
((this.pageMax = Math.ceil(e.total_count / this.pageEveNum) || 1), (this.reqArr = []));
for (let i = e.list || [], n = 0; n < i.length; n++) this.reqArr.push(new game.FriendData(i[n]));
((this.labelPage.text = this.pageIndex + "/" + this.pageMax),
(this.list.dataProvider = new eui.ArrayCollection(this.reqArr)));
}
dealApplyOver(t) {
const e = t.data,
i = this.reqArr.indexOf(e);
i > -1 &&
(this.reqArr.splice(i, 1),
0 != this.reqArr.length
? (this.list.dataProvider = new eui.ArrayCollection(this.reqArr))
: this.updateListPage(this.pageIndex));
}
};
((game.FriendAddReqPanel = FriendAddReqPanel), __reflect(FriendAddReqPanel.prototype, "game.FriendAddReqPanel"));
})(game || (game = {}));
var game;
!(function (game) {
const FriendGiveListPanel = class FriendGiveListPanel extends game.BasePanel {
constructor(t) {
super();
this.listData = t;
this.isFullScreen = !0;
this.isVisibleAnimate = !0;
this.skinName = new FriendGiveListSkin();
}
createChildren() {
(super.createChildren(),
(this.list.dataProvider = null),
(this.list.itemRenderer = game.FriendGiveListItemRender));
const i =
"编号:" +
this.listData.deal_id +
" " +
this.listData.from_user_nickname +
" 给 " +
this.listData.be_user_nickname +
" 的转赠";
((this.labelName.text = i), this.initList());
}
initList() {
let t = [];
if (0 === this.listData.type) {
const e = {
num: this.listData.data.gold,
item_id: -3
};
t.push(e);
} else t = this.listData.data.item_list;
this.list.dataProvider = new eui.ArrayCollection(t);
}
onTouchTap(t) {
switch ((t.stopPropagation(), t.target)) {
case this.enterBtn:
this.enterBtnTouch();
}
}
enterBtnTouch() {
const e = GameConfig.SERVER_PATH + "deal/deal-confirm",
i = {
deal_id: this.listData.deal_id
};
game.SurePasswordPanel.instance.show(e, i, function (e) {
0 == e.status
? (this.btnCloseTouchEnded(),
game.EventManager.instance.dispatch(SysNotify.FLUSH_GROUP3),
PopUpManager.popTip("已确认,等待对方确定"),
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND_GIVE_LIST))
: TipsUtils.showErrorCodeTips(e.status);
});
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND_GIVE_LIST);
}
};
((game.FriendGiveListPanel = FriendGiveListPanel),
__reflect(FriendGiveListPanel.prototype, "game.FriendGiveListPanel"));
})(game || (game = {}));
var game;
!(function (game) {
const FriendGivePanel = class FriendGivePanel extends game.BasePanel {
constructor() {
super();
this.type = 0;
this.pageIndex = 1;
this.pageMax = 1;
this.pageEveNum = 10;
this.isFullScreen = !0;
this.isVisibleAnimate = !0;
this.skinName = new FriendGiveSkin();
}
createChildren() {
(super.createChildren(),
this.commonPanel.setPanelWidth(620),
this.commonPanel.setPanelHeight(810),
this.commonPanel.setTitleIcon("give_icon_png"),
this.commonPanel.setTitle("give_title_png"),
(this.commonPanel.groupHelp.visible = !1),
(this.commonPanel.btnClose.label = "转赠"),
(this.commonPanel.closeBtn.visible = !0),
(this.list.itemRenderer = game.FriendGiveItemRender),
(this.list.dataProvider = null),
(this.noList.itemRenderer = game.FriendGiveNoComRender),
(this.noList.dataProvider = null),
this.initTab());
}
onAdded() {
(super.onAdded(), game.EventManager.instance.addEvent(SysNotify.FLUSH_GROUP3, this.updateGroup3, this));
}
onRemoved() {
(super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.FLUSH_GROUP3, this.updateGroup3, this));
}
closeBtnTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND_GIVE);
}
btnCloseTouchEnded() {
0 === this.type ? this.sendGold() : 1 === this.type ? this.sendFriut() : this.closeBtnTouchEnded();
}
sendFriut() {
if (RegUtils.isNull(this.fruitIdEt.text)) return void PopUpManager.popTip("请输入交易人ID");
for (var e = [], i = 0; i < this.list.numChildren; i++) {
const n = this.list.$children[i];
if (n.exNum > 0) {
const a = {
num: 100 * n.exNum,
item_id: n.data.config.id
};
e.push(a);
}
}
if (e.length < 1) return void PopUpManager.popTip("没有转增的果实");
const o = {
be_user_id: this.fruitIdEt.text,
type: 1,
gold: 0,
item_list: e
},
r = GameConfig.SERVER_PATH + "deal/deal";
game.SurePasswordPanel.instance.show(r, o, function (i) {
0 !== i.status
? TipsUtils.showErrorCodeTips(i.status)
: (PopUpManager.popTip("已发起交易"),
e.forEach(function (t) {
Global.playerProxy.sellWareHouseItem(
{
id: t.item_id
},
t.num
);
}),
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE),
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND_GIVE));
});
}
onTouchTap(t) {
super.onTouchTap(t);
const i = t.target;
switch (i) {
case this.btnPrev:
this.changePage(-1);
break;
case this.btnNext:
this.changePage(1);
break;
case this.sendBtn:
this.searchPlayer();
}
}
searchPlayer() {
const t = this,
e = this.goldIdEt.text.trim();
if (RegUtils.isNull(e)) return void PopUpManager.popTip("请输入交易人ID,后查询");
const i = GameConfig.SERVER_PATH + "user/get-wx-name";
Global.netProxy.sendRequest(
i,
{
be_user_id: e
},
function (e) {
0 == e.status
? (t.nameLabel.text = e.data.wx_name)
: ((t.nameLabel.text = ""), PopUpManager.popTip("查无此人"));
}
);
}
sendGold() {
if (RegUtils.isNull(this.goldIdEt.text)) return void PopUpManager.popTip("请输入交易人ID");
if (int(this.goldEt.text) <= 0) return void PopUpManager.popTip("金额不能小于0");
const e = GameConfig.SERVER_PATH + "deal/deal",
i = {
be_user_id: this.goldIdEt.text,
type: 0,
gold: int(this.goldEt.text),
item_list: []
};
game.SurePasswordPanel.instance.show(e, i, function (e) {
0 !== e.status
? TipsUtils.showErrorCodeTips(e.status)
: (PopUpManager.popTip("已发起交易"),
(Global.playerProxy.playerData.gold -= i.gold),
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE));
});
}
initTab() {
const e = ["金币转赠", "果实转赠", "未完成的转赠"];
((this.tab = new game.Tab(e, this.onTabItemClickCallback.bind(this))),
(this.tab.bottom = 0),
this.groupTab.addChild(this.tab));
}
updateGroup3() {
2 == this.type && this.onTabItemClickCallback(2);
}
onTabItemClickCallback(t) {
if (((this.btnClose.visible = !0), 0 == t))
return (
(this.type = 0),
(this.goldGroup.visible = !0),
(this.fruitGroup.visible = !1),
void (this.noComGroup.visible = !1)
);
if (1 == t) {
((this.type = 1),
(this.noComGroup.visible = !1),
(this.goldGroup.visible = !1),
(this.fruitGroup.visible = !0));
const e = Global.playerProxy.getItemByType(ItemType.FRUIT);
this.list.dataProvider = new eui.ArrayCollection(e);
} else
((this.type = 2),
(this.noComGroup.visible = !0),
(this.goldGroup.visible = !1),
(this.fruitGroup.visible = !1),
this.changePage(this.pageIndex, !0),
(this.btnClose.visible = !1));
}
changePage(t, e) {
if ((void 0 === e && (e = !1), e)) this.pageIndex = t;
else {
if (this.pageIndex <= 1 && 0 > t) return;
if (this.pageIndex >= this.pageMax && t > 0) return;
this.pageIndex += t;
}
((this.labelPage.text = this.pageIndex + "/" + this.pageMax), this.updateListPage(this.pageIndex));
}
updateListPage(t) {
const e = GameConfig.SERVER_PATH + "deal/get-list",
i = {
offset: (this.pageIndex - 1) * this.pageEveNum,
count: this.pageEveNum
};
Global.netProxy.sendRequest(e, i, this.onListData.bind(this));
}
onListData(e) {
const i = e.data;
((this.pageMax = game.Utils.limit(Math.ceil(i.total_count / 10), 1, 10)),
(this.labelPage.text = this.pageIndex + "/" + this.pageMax),
(this.noList.dataProvider = new eui.ArrayCollection(i.list)));
}
};
((game.FriendGivePanel = FriendGivePanel), __reflect(FriendGivePanel.prototype, "game.FriendGivePanel"));
})(game || (game = {}));
var game;
!(function (game) {
const FriendPanel = class FriendPanel extends game.BasePanel {
constructor(t = 0) {
super();
this.pageIndex = 1;
this.pageMax = 1;
this.pageEveNum = 7;
this.showType = 1;
this.rankType = 0;
this.startIndex = 0;
this.startIndex = t;
this.isFullScreen = !0;
this.isVisibleAnimate = !0;
this.skinName = new FriendSkin();
}
onScrollerTouchBegan(t) {
((this.scrollerTouchStart = t.stageX),
this.stage.once(egret.TouchEvent.TOUCH_END, this.onScrollerTouchEnded, this, !0, Number.MAX_VALUE));
}
onScrollerTouchEnded(t) {
const e = t.stageX - this.scrollerTouchStart;
e > 150 ? this.changePage(-1) : -150 > e && this.changePage(1);
}
createChildren() {
(super.createChildren(),
this.commonPanel.setPanelWidth(594),
this.commonPanel.setPanelHeight(862),
this.commonPanel.setTitleIcon("panel_icon_friend_png"),
this.commonPanel.setTitle("panel_title_friend_png"),
(this.btnLv.visible = !0),
(this.btnGold.visible = !1),
this.initList(),
this.initTab(),
this.changeType(1),
game.EventManager.instance.addEvent(SysNotify.FRIEND_REFRESH, this.onFriendNeedRefresh, this));
}
onFriendNeedRefresh() {
this.changePage(this.pageIndex, !0);
}
initList() {
((this.list.dataProvider = null),
(this.list.itemRenderer = game.FriendItemRender),
this.scroller.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onScrollerTouchBegan, this));
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_FRIEND);
}
onTouchTap(i) {
super.onTouchTap(i);
const n = i.target;
switch (n) {
case this.btnPrev:
this.changePage(-1);
break;
case this.btnNext:
this.changePage(1);
break;
case this.btnAdd:
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FRIEND_ADD);
break;
case this.btnReq:
game.AppFacade.getInstance().sendNotification(PanelNotify.OPEN_FRIEND_ADD_REQ);
break;
case this.btnLv:
this.changeType(0);
break;
case this.btnGold:
this.changeType(1);
}
}
initTab() {
let e = ["全国排名", "好友排名"];
(1 == this.startIndex && (e = ["好友排名", "全国排名"]),
(this.tab = new game.Tab(e, this.onTabItemClickCallback.bind(this))),
this.tab.setItemBaseHeight(50),
(this.tab.bottom = 0),
this.groupTab.addChild(this.tab));
}
onTabItemClickCallback(t) {
(1 == this.startIndex ? (0 == t ? (this.rankType = 1) : (this.rankType = 0)) : (this.rankType = t),
this.changePage(1, !0));
}
changePage(t, e) {
if ((void 0 === e && (e = !1), e)) this.pageIndex = t;
else {
if (this.pageIndex <= 1 && 0 > t) return;
if (this.pageIndex >= this.pageMax && t > 0) return;
this.pageIndex += t;
}
((this.labelPage.text = this.pageIndex + "/" + this.pageMax), this.updateListPage(this.pageIndex));
}
updateListPage(t) {
0 == this.rankType
? this.mediator.getRankList(this.showType, t - 1, this.pageEveNum, this.onListData.bind(this))
: this.mediator.getFriendList(this.showType, t - 1, this.pageEveNum, this.onListData.bind(this));
}
onListData(e) {
((this.pageMax = Math.ceil(e.total_count / this.pageEveNum) || 1), (this.reqArr = []));
for (let i = e.list || [], n = 0; n < i.length; n++) {
const a = new game.FriendData(i[n]);
((a.rank = (this.pageIndex - 1) * this.pageEveNum + n + 1), this.reqArr.push(a));
}
((this.labelPage.text = this.pageIndex + "/" + this.pageMax),
(this.list.dataProvider = new eui.ArrayCollection(this.reqArr)));
}
changeType(t) {
((this.showType = t),
(this.btnLv.visible = 1 == t),
(this.btnGold.visible = 0 == t),
(this.labelTitleLv.text = 1 == t ? "等级" : "财富"),
(Const.RANK_SHOW_TYPE = t));
}
};
((game.FriendPanel = FriendPanel), __reflect(FriendPanel.prototype, "game.FriendPanel"));
})(game || (game = {}));
var GiftItemRender = class GiftItemRender extends eui.ItemRenderer {
constructor() {
super();
this.unitArr = [];
this.skinName = OnLineGiftItemRenderSkin;
}
partAdded(e, i) {
super.partAdded(e, i);
}
childrenCreated() {
(super.childrenCreated(),
(this.unitArr.length = 0),
this.unitArr.push(this.unit0),
this.unitArr.push(this.unit1),
this.unitArr.push(this.unit2),
this.unitArr.push(this.unit3),
game.UIUtils.addShortTouch(this.getButton, this.onSendGetReward.bind(this), null));
}
onSendGetReward() {
EffectUtils.playEffect(this.getButton, 1);
if (!this.data) return;
const onlineGiftData = GiftManager.getInstance().getDataForID(this.data.id);
if (this.data.receive_time >= 0) {
0 == onlineGiftData.receive_time
? ((GiftManager.getInstance().curid = this.data.id), GiftManager.getInstance().getNetOnLineGift())
: TipsUtils.showTipsDownToUp("时间未到");
} else if (this.data.player_level) {
((LevelGiftManager.getInstance().curid = this.data.id), LevelGiftManager.getInstance().sendNetLevelGift());
}
}
onTimer() {
if (this.data && this.data.receive_time >= 0) {
const t = GiftManager.getInstance().getDataForID(this.data.id),
e = t.receive_time;
((this.timeLabel.text = game.Utils.showTimeFormat(1e3 * e)),
(this.getButton.visible = !1),
(this.getButtonD.visible = !1),
0 == t.isGet
? ((this.getButton.visible = !0), (this.getButton.enabled = !1))
: 1 == t.isGet
? ((this.getButton.visible = !0), (this.getButton.enabled = !0))
: ((this.getButton.visible = !1), (this.getButtonD.visible = !0)));
}
}
dataChanged() {
if ((super.dataChanged(), this.clearItem(), this.data.receive_time >= 0)) {
((this.onLineGroup.visible = !0), (this.levelGroup.visible = !1));
const e =
(Global.playerProxy.playerData.online_gift_get_count % 7, GiftManager.getInstance().getDataForID(this.data.id));
((this.getButton.visible = !1),
(this.getButtonD.visible = !1),
0 == e.isGet
? ((this.getButton.visible = !0), (this.getButton.enabled = !1))
: 1 == e.isGet
? ((this.getButton.visible = !0), (this.getButton.enabled = !0))
: ((this.getButton.visible = !1), (this.getButtonD.visible = !0)),
(this.timeLabel.text = game.Utils.showTimeFormat(1e3 * e.receive_time)));
let i = 1;
for (const n in this.data)
if (("fruit_id1" == n || "fruit_id2" == n || "fruit_id3" == n || "fruit_id4" == n) && this.data[n]) {
const a = this.data[n];
let o = a.split(":");
1 == o.length && ((o.length = 0), (o = a.split("")));
const r = Global.gameProxy.getItemImageId(o[0]);
(this.unitArr[i - 1].setIcon(r + "_png"), this.unitArr[i - 1].setNum(int(o[1])));
const s = new SimpleItemData(Global.gameProxy.getItemConfig(o[0]));
((this.unitArr[i - 1].itemData = s), i++);
}
} else if (this.data.player_level) {
(this.onLineGroup.visible = !1), (this.levelGroup.visible = !0), this.renderRewardItems(this.data);
((this.levelLabel.text = this.data.player_level),
(this.getButton.visible = !1),
(this.getButtonD.visible = !1),
0 == this.data.isget
? ((this.getButton.visible = !0), (this.getButton.enabled = !1))
: 1 == this.data.isget
? ((this.getButton.visible = !0), (this.getButton.enabled = !0), (this.levelLabel.textColor = 16777215))
: (this.getButtonD.visible = !0));
}
}
renderRewardItems(data) {
let unitIndex = 0;
for (const fieldName of ["fruit_id1", "fruit_id2", "fruit_id3", "fruit_id4"]) {
const rewardString = data[fieldName];
if (!rewardString || unitIndex >= this.unitArr.length) continue;
let rewardParts = String(rewardString).split(":");
1 == rewardParts.length && (rewardParts = String(rewardString).split(""));
const itemId = rewardParts[0],
count = int(rewardParts[1]),
imageId = Global.gameProxy.getItemImageId(itemId),
itemConfig = Global.gameProxy.getItemConfig(itemId);
(this.unitArr[unitIndex].setIcon(imageId + "_png"),
this.unitArr[unitIndex].setNum(count),
(this.unitArr[unitIndex].itemData = new SimpleItemData(itemConfig)),
unitIndex++);
}
}
clearItem() {
for (let t = 0; t < this.unitArr.length; t++) (this.unitArr[t].setIcon(""), this.unitArr[t].setNum(0));
}
};
__reflect(GiftItemRender.prototype, "GiftItemRender");
var GiftManager = class GiftManager extends egret.EventDispatcher {
constructor() {
super();
this.onLineDataArr = [];
}
static getInstance() {
return (this._insatance || (this._insatance = new GiftManager()), this._insatance);
}
initData() {
this.onLineDataArr.length = 0;
const t = Global.gameProxy.getOnlineGiftConfig();
for (const e in t) {
const i = {};
((i.receive_time = t[e].receive_time),
(i.fruit_id4 = t[e].fruit_id4),
(i.fruit_id3 = t[e].fruit_id3),
(i.fruit_id2 = t[e].fruit_id2),
(i.fruit_id1 = t[e].fruit_id1),
(i.id = t[e].id));
let n = Global.playerProxy.playerData.online_gift_get_count % 7;
(n >= i.id ? ((i.isGet = 0), (i.receive_time = 0)) : (n = i.id - 1) ? (i.isGet = 1) : (i.isGet = 2),
this.onLineDataArr.push(i));
}
this.addTimer();
}
getDataForID(t) {
for (let e = 0; e < this.onLineDataArr.length; e++) if (this.onLineDataArr[e].id == t) return this.onLineDataArr[e];
return null;
}
addTimer() {
core.TimerManager.instance.addTick(1e3, 0, this.onTimer, this);
}
onTimer() {
for (let t = Global.playerProxy.playerData.online_gift_get_count % 7, e = 0; e < this.onLineDataArr.length; e++)
(this.onLineDataArr[e].receive_time >= 1 &&
t == this.onLineDataArr[e].id - 1 &&
(this.onLineDataArr[e].receive_time -= 1),
t >= this.onLineDataArr[e].id
? (this.onLineDataArr[e].isGet = 0)
: t == this.onLineDataArr[e].id - 1 && 0 == this.onLineDataArr[e].receive_time
? (this.onLineDataArr[e].isGet = 1)
: (this.onLineDataArr[e].isGet = 2));
}
getNetOnLineGift() {
Global.netProxy.sendRequest(
GameConfig.SERVER_PATH + "user/get-online-gift",
{},
this.onGetNetOnLineGift.bind(this)
);
}
onGetNetOnLineGift(t) {
if (0 == t.status) {
Global.playerProxy.playerData.online_gift_get_count += 1;
const e = this.getDataForID(this.curid);
((e.receive_time = 0), (e.isGet = 0));
const i = [];
for (const n in e) {
var a = 1;
if (("fruit_id1" == n || "fruit_id2" == n || "fruit_id3" == n || "fruit_id4" == n) && e[n]) {
const o = e[n],
r = o.split(":"),
s = r[0],
l = int(r[1]);
Global.playerProxy.updateWareHouseItem(
{
item_id: s
},
l
);
const h = Global.gameProxy.getItemConfig(s).name;
i.push("获得[" + h + "]X" + l);
}
}
var a = 0;
(core.TimerManager.instance.addTick(
200,
i.length,
function () {
(TipsUtils.showTipsDownToUp(i[a]), a++);
},
this
),
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE),
game.EventManager.instance.dispatch(SysNotify.GETREWARD_UPDATA));
} else TipsUtils.showTipsDownToUp(GameConfig.ServerCode[t.status]);
}
};
__reflect(GiftManager.prototype, "GiftManager");
var LevelGiftData = class LevelGiftData {
constructor(config) {
this.isget = 2;
this.id = config.id;
this.fruit_id1 = config.fruit_id1;
this.fruit_id2 = config.fruit_id2;
this.fruit_id3 = config.fruit_id3;
this.fruit_id4 = config.fruit_id4;
this.player_level = int(config.player_level);
this.sortkey = int(config.id);
}
};
__reflect(LevelGiftData.prototype, "LevelGiftData");
var LevelGiftManager = class LevelGiftManager extends egret.EventDispatcher {
constructor() {
super();
this.levelGiftArr = [];
}
static getInstance() {
return (this._insatance || (this._insatance = new LevelGiftManager()), this._insatance);
}
updataData(receivedList) {
const received = receivedList || [],
configList = Global.gameProxy.getLevelGiftConfig() || {};
this.levelGiftArr.length = 0;
for (const configId in configList) {
const giftData = new LevelGiftData(configList[configId]);
this.levelGiftArr.push(giftData);
for (let index = 0; index < received.length; index++)
received[index].gift_id == giftData.id && ((giftData.isget = 0), (giftData.sortkey += 20));
giftData.player_level <= int(Global.playerProxy.playerData.level) &&
2 == giftData.isget &&
((giftData.isget = 1), (giftData.sortkey -= 20));
}
this.levelGiftArr.sort(this.sort);
}
sort(left, right) {
return left.sortkey > right.sortkey ? 1 : -1;
}
getGiftDataForID(id) {
for (let index = 0; index < this.levelGiftArr.length; index++)
if (this.levelGiftArr[index].id == id) return this.levelGiftArr[index];
return null;
}
sendNetGetList() {
Global.netProxy.sendRequest(
GameConfig.SERVER_PATH + "user/get-player-level-gift-list",
{},
this.onSendNetGetList.bind(this)
);
}
onSendNetGetList(response) {
0 == response.status
? (this.updataData((response.data && response.data.list) || []),
game.EventManager.instance.dispatch(SysNotify.GETREWARD_UPDATA))
: TipsUtils.showTipsDownToUp(GameConfig.ServerCode[response.status] || "获取等级礼包失败");
}
sendNetLevelGift() {
Global.netProxy.sendRequest(
GameConfig.SERVER_PATH + "user/get-player-level-gift",
{
gift_id: this.curid
},
this.onSendNetLevelGift.bind(this)
);
}
onSendNetLevelGift(response) {
if (0 == response.status) {
const giftData = this.getGiftDataForID(this.curid),
rewards = [];
for (const fieldName of ["fruit_id1", "fruit_id2", "fruit_id3", "fruit_id4"])
giftData && giftData[fieldName] && rewards.push(giftData[fieldName]);
(rewards.length > 0 && Global.playerProxy.addItem1(rewards.join(",")),
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE),
this.sendNetGetList());
} else TipsUtils.showTipsDownToUp(GameConfig.ServerCode[response.status] || "领取等级礼包失败");
}
};
__reflect(LevelGiftManager.prototype, "LevelGiftManager");
var LevelGiftMediter = class LevelGiftMediter extends BaseMediator {
constructor() {
super("LevelGiftMediter");
}
listNotificationInterests() {
return [PanelNotify.OPEN_LEVELGIFT, PanelNotify.CLOSE_LEVELGIFT];
}
onRegister() {
super.onRegister();
}
showViewComponent(t = 7) {
((this.viewComponent = new LevelGiftPanel()), this.showUI(this.viewComponent, !0, 0, 0, t));
}
handleNotification(t) {
t.getBody();
switch (t.getName()) {
case PanelNotify.OPEN_LEVELGIFT:
Global.netProxy.sendRequest(
GameConfig.SERVER_PATH + "user/get-player-level-gift-list",
{},
this.onGetPlayerLevelGift.bind(this)
);
break;
case PanelNotify.CLOSE_LEVELGIFT:
this.closeViewComponent(10);
}
}
onGetPlayerLevelGift(response) {
0 == response.status
? (LevelGiftManager.getInstance().updataData((response.data && response.data.list) || []), this.showViewComponent(10))
: TipsUtils.showTipsDownToUp(GameConfig.ServerCode[response.status] || "获取等级礼包失败");
}
static NAME = "LevelGiftMediter";
};
__reflect(LevelGiftMediter.prototype, "LevelGiftMediter");
var LevelGiftPanel = class LevelGiftPanel extends game.BasePanel {
constructor() {
super();
this.skinName = LevelGiftPanelSkin;
}
partAdded(e, i) {
super.partAdded(e, i);
}
onAdded() {
(super.onAdded(), game.EventManager.instance.addEvent(SysNotify.GETREWARD_UPDATA, this.OnUPdata, this));
}
onRemoved() {
(super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.GETREWARD_UPDATA, this.OnUPdata, this));
}
OnUPdata() {
const viewport = this.scrolls && this.scrolls.viewport,
scrollV = viewport ? viewport.scrollV : 0;
(this.initData(),
egret.callLater(function () {
this.scrolls && this.scrolls.validateNow();
viewport && (viewport.scrollV = scrollV);
}, this));
}
initData() {
this.list.dataProvider = new eui.ArrayCollection(LevelGiftManager.getInstance().levelGiftArr);
}
childrenCreated() {
(super.childrenCreated(),
(this.scrolls.viewport = this.list),
(this.list.itemRenderer = GiftItemRender),
this.initData());
}
createChildren() {
(super.createChildren(),
(this.isFullScreen = !0),
(this.isVisibleAnimate = !0),
this.commonPanel.setPanelWidth(640),
this.commonPanel.setPanelHeight(800),
this.commonPanel.setTitle("onLineGift_json.onLineGift_Title1_png"));
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_LEVELGIFT);
}
};
__reflect(LevelGiftPanel.prototype, "LevelGiftPanel");
var OnlineGiftMediter = class OnlineGiftMediter extends BaseMediator {
constructor() {
super("OnlineGiftMediter");
}
listNotificationInterests() {
return [PanelNotify.OPEN_ONLINEGIFT, PanelNotify.CLOSE_ONLINEGIFT];
}
onRegister() {
super.onRegister();
}
showViewComponent(t = 7) {
((this.viewComponent = new OnlineGiftPanel()), this.showUI(this.viewComponent, !0, 0, 0, t));
}
handleNotification(t) {
t.getBody();
switch (t.getName()) {
case PanelNotify.OPEN_ONLINEGIFT:
this.showViewComponent(10);
break;
case PanelNotify.CLOSE_ONLINEGIFT:
this.closeViewComponent(10);
}
}
static NAME = "OnlineGiftMediter";
};
__reflect(OnlineGiftMediter.prototype, "OnlineGiftMediter");
var OnlineGiftPanel = class OnlineGiftPanel extends game.BasePanel {
constructor() {
super();
this.skinName = OnLineGiftPanelSkin;
}
partAdded(e, i) {
super.partAdded(e, i);
}
onAdded() {
(super.onAdded(),
core.TimerManager.instance.addTick(1e3, 0, this.onTimer, this),
game.EventManager.instance.addEvent(SysNotify.GETREWARD_UPDATA, this.OnUPdata, this));
}
onRemoved() {
(super.onRemoved(), game.EventManager.instance.removeEvent(SysNotify.GETREWARD_UPDATA, this.OnUPdata, this));
}
OnUPdata() {
this.scrolls.viewport.scrollEnabled = !0;
const t = this.scrolls.viewport.scrollV;
(this.initData(), (this.scrolls.viewport.scrollV = t), this.scrolls.viewport.validateNow());
}
onTimer() {
for (let t = 0; t < this.list.numChildren; t++) {
const e = this.list.getChildAt(t);
e.onTimer();
}
}
childrenCreated() {
(super.childrenCreated(),
(this.scrolls.viewport = this.list),
(this.list.itemRenderer = GiftItemRender),
this.initData());
}
createChildren() {
(super.createChildren(),
(this.isFullScreen = !0),
(this.isVisibleAnimate = !0),
this.commonPanel.setPanelWidth(640),
this.commonPanel.setPanelHeight(700),
this.commonPanel.setTitle("onLineGift_json.onLineGift_Title2_png"));
}
initData() {
const t = GiftManager.getInstance().onLineDataArr;
this.list.dataProvider = new eui.ArrayCollection(t);
}
btnCloseTouchEnded() {
game.AppFacade.getInstance().sendNotification(PanelNotify.CLOSE_ONLINEGIFT);
}
};
__reflect(OnlineGiftPanel.prototype, "OnlineGiftPanel");