local UIFriendRechargePurchaseLv = UIViewClass() function UIFriendRechargePurchaseLv:OnOpened(context) self.activityType = context.activityType self.activityId = context.activityId UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_FriendRecharge_Reward_Hint1) self.maxLevel = MDL.OperationActivity.FriendRechargeReward:GetDataLengthByActivityID(self.activityId) self.rechargeBaseInfo = MDL.FriendRecharge.GetRechargeBaseInfo() self.curLevel = self.rechargeBaseInfo.friendRechargeLv self.curExp = self.rechargeBaseInfo.friendRechargeExp self.curRechargeType = MDL.FriendRecharge.GetRechargeType() self.rechargeModelCfg = MDL.OperationActivity.FriendRechargeBackGround2:GetDataByActivityID_ModeType(self.activityId, self.curRechargeType) local titleStr = UIUtils.GetLocalizedTxt(Const_IDS[self.rechargeModelCfg.TitleIDS]) UIUtils.SetLabel(self.txt_LvBefore, titleStr.." "..string.FormatByIdsId(Const_IDS.IDS_Handbook_Hero_LevelNum, self.curLevel)) UIUtils.SetLabel(self.txt_LvAfter, titleStr.." "..string.FormatByIdsId(Const_IDS.IDS_Handbook_Hero_LevelNum, self.curLevel + 1)) local rechargeConstData = MDL.OperationActivity.ActivityBaseData[self.activityType]:GetDataByActivityID(self.activityId) local curLevelData = MDL.OperationActivity.FriendRechargeReward:GetDataByActivityID_Level(self.activityId, self.curLevel) local expDifferenceValue = curLevelData.Exp - self.curExp self.isBuy = MDL.Currency.GetSoftTokenCountById(rechargeConstData.ExpBuyCurrency) >= (expDifferenceValue * rechargeConstData.ExpBuyNum) UIUtils.SetLabel(self.lab_CostInfo, string.FormatByIdsId(Const_IDS.IDS_FriendRecharge_Reward_Hint4, expDifferenceValue * rechargeConstData.ExpBuyNum, UTL.Item.GetItemName(rechargeConstData.ExpBuyCurrency), expDifferenceValue)) UIUtils.SetLabel(self.txt_CostNum, expDifferenceValue * rechargeConstData.ExpBuyNum) local nextLevelData = MDL.OperationActivity.FriendRechargeReward:GetDataByActivityID_Level(self.activityId, self.curLevel + 1) self.loop_Reward:ReloadAll(nextLevelData.Reward_Table) end function UIFriendRechargePurchaseLv:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIFriendRechargePurchaseLv:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Buy then if self.curLevel < self.maxLevel then if self.isBuy then MDL.FriendRecharge.SubOrderBuyLvRequest(self.activityId, 1) self:CloseView() else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Store_CoinExchange_NotEnough) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_FriendRecharge_Reward_Hint2) end end end function UIFriendRechargePurchaseLv:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.RewardItem, data.RewardNum) end function UIFriendRechargePurchaseLv:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data.RewardItem) end return UIFriendRechargePurchaseLv