local UIMonopolyRecords = UIViewClass() local RewardStrFormat = "%s%s " ----------------------------- 系统函数 ----------------------------- function UIMonopolyRecords:OnOpened() self:RegistSystemEvent(EventID.UI_Monopoly_RefreshRecord, self.RefreshPanel) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_Monopoly_RewardRecord"]) MDL.Monopoly.MonopolyHistoryRewardRequest(self.context.activityId) end function UIMonopolyRecords:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIMonopolyRecords:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIMonopolyRecords:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_Records then local timeData = os.date(UTL.Time.FormatDateEnum.YMDHM, data.optTime) UIUtils.SetLabel(cellTable.txt_Date, timeData) -- 统计奖励 local stepRewardStr = "" if data.stepReward then stepRewardStr = self:FormatRewardStr(data.stepReward.ItemId, data.stepReward.ItemCount) if not string.isNilOrEmpty(stepRewardStr) then stepRewardStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Monopoly_RewardRecord_Tips_1"]), stepRewardStr) .. " " end end local passRewardStr = "" if data.passReward and #data.passReward > 0 then local itemCount = 0 local itemID = data.passReward[1].ItemId for _, v in ipairs (data.passReward) do itemCount = itemCount + v.ItemCount end passRewardStr = self:FormatRewardStr(itemID, itemCount) if not string.isNilOrEmpty(passRewardStr) then passRewardStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Monopoly_RewardRecord_Tips_2"]), passRewardStr) .. " " end end local roundRewardStr = "" if data.roundReward then roundRewardStr = self:FormatRewardStr(data.roundReward.ItemId, data.roundReward.ItemCount) if not string.isNilOrEmpty(roundRewardStr) then roundRewardStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Monopoly_RewardRecord_Tips_3"]), roundRewardStr) end end UIUtils.SetLabel(cellTable.txt_Desc, string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Monopoly_RewardRecord_Tips"]), data.moveNum) .. passRewardStr .. stepRewardStr .. roundRewardStr) end end ------------------------------------------------------------------- function UIMonopolyRecords:RefreshPanel(records) UIUtils.SetActive(self.group_Empty, records == nil or #records == 0) if records and #records > 0 then for i = #records, 1, -1 do self.scroll_Records:AddData(records[i], 0) end end end function UIMonopolyRecords:FormatRewardStr(itemId, itemNum) if itemId > 0 then local itemData = DataSheetManager.ItemData:GetDataByID(itemId) if itemData then return string.format(RewardStrFormat, UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[itemData.Name]), itemData.Color), UTL.Color.FormatQualityText("x" .. itemNum, itemData.Color)) end end return "" end return UIMonopolyRecords