local UIGuildAuctionRecord = UIViewClass() local auction_base = require 'Proto.auction_base_pb' local TimeFormationStr = "%d:%d" local TimeFormationStrLessTen = "%d:0%d" -------------------------------- 系统函数 ------------------------------- function UIGuildAuctionRecord:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildAuctionRecord_RefreshPanel, self.RefreshPanel) MDL.GuildAuction.RequestAuctionRecord(context and context.recordReqTyp) end function UIGuildAuctionRecord:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildAuctionRecord:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView(true) end end function UIGuildAuctionRecord:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_Record then local auctionData = DataSheetManager.GuildAuction:GetDataByID(data.cfgId) if not auctionData then return end local itemData = DataSheetManager.ItemData:GetDataByID(auctionData.ItemID) if not itemData then return end local consumeItemData = DataSheetManager.ItemData:GetDataByID(auctionData.AuctionCoin) UTL.Item.SetAtlasSprite(cellTable.icon_Currency, "UI_Common", consumeItemData.Icon) UTL.Item.SetItemCell(cellTable.Item, itemData.ID, auctionData.ItemNum) local dataSplice = UTL.Item.GetItemDataSpliceByType(itemData.ID) UIUtils.SetLabel(cellTable.txt_ItemName, UTL.Color.FormatQualityText(dataSplice.Name, itemData.Color)) UIUtils.SetActive(cellTable.group_Success, data.isSuccess) UIUtils.SetActive(cellTable.group_Fail, not data.isSuccess) if GameAppInfo.IsVietnamPackage() then UIUtils.SetLabel(cellTable.txt_Date, os.date(UTL.Time.FormatDateEnum.HM, data.tradingTime)) UIUtils.SetLabel(cellTable.txt_Time, os.date(UTL.Time.FormatDateEnum.MD, data.tradingTime)) else local curDate = UTL.Time.OsDateOriginal("*t", data.tradingTime) UIUtils.SetLabel(cellTable.txt_Date, string.FormatByIdsKey("IDS_Time_MonthDay", curDate.month, curDate.day)) if curDate.min < 10 then UIUtils.SetLabel(cellTable.txt_Time, string.format(TimeFormationStrLessTen, curDate.hour, curDate.min)) else UIUtils.SetLabel(cellTable.txt_Time, string.format(TimeFormationStr, curDate.hour, curDate.min)) end end UIUtils.SetLabel(cellTable.txt_Number, data.cost) if not data.isSuccess then UIUtils.SetLabelText(cellTable.lab_Remark, Const_IDS["IDS_Auction_BiddingCostRefund"]) else UIUtils.SetLabelText(cellTable.lab_Remark, data.typ == auction_base.AuctionPrice and Const_IDS["IDS_Auction_BiddingPrice"] or Const_IDS["IDS_Auction_BuyOutPrice"]) end -- 显示折扣 local specialOfferInfo = MDL.GuildAuction.CalculationSpecialOfferInfo(auctionData.HighestPrice, auctionData.SpecialOfferInfo, data.cost) if specialOfferInfo > 0 then UIUtils.SetActive(cellTable.group_Off, true) UIUtils.SetLabel(cellTable.txt_Off, string.format("-%d%%", specialOfferInfo * 100)) else UIUtils.SetActive(cellTable.group_Off, false) end end end function UIGuildAuctionRecord:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.LoopScroll_Record then local auctionData = DataSheetManager.GuildAuction:GetDataByID(data.cfgId) if not auctionData then return end if target == cellTable.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(auctionData.ItemID) end end end -------------------------------------------------------------------------- function UIGuildAuctionRecord:RefreshPanel(recordItems) self.LoopScroll_Record:ClearCells() if recordItems and #recordItems > 0 then UIUtils.SetActive(self.group_Empty, false) for i = #recordItems, 1, -1 do self.LoopScroll_Record:AddData(recordItems[i], 0) end else UIUtils.SetActive(self.group_Empty, true) end end return UIGuildAuctionRecord