local UIGuildAuctionMy = UIViewClass() local auction_base = require 'Proto.auction_base_pb' local DefaultTimeShow = "00:00:00" local fixedPriceDuration = DataSheetManager.ConstData:GetDataByID("AuctionBoughtBiddingCountdown").IntValue --------------------------- 系统函数 ----------------------------- function UIGuildAuctionMy:OnOpened(context) self.curClickAuctionItem = nil self.cacheItems = {} self.auctionHouseType = context and context.auctionHouseType self:StartRepeatFunc(self.OnUpdateFun, 1) self:RegistSystemEvent(EventID.UI_GuildAuctionMy_RefreshPanel, self.RefreshPanel) MDL.GuildAuction.RequestGuildAuctionItems(auction_base.Collect) end function UIGuildAuctionMy:OnUpdateFun() MDL.GuildAuction.RequestGuildAuctionItems() end function UIGuildAuctionMy:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildAuctionMy:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView(true) elseif comp == self.info_btn_Close then self.clickedInfoIndex = nil UIUtils.SetActive(self.group_FrameInfo, false) end end function UIGuildAuctionMy:OnCellInit(scrollRect, index, cellTable, auctionItem) if scrollRect == self.LoopScroll_My then local auctionData = auctionItem.auctionData local itemData = auctionItem.itemData local startPrice, highestPrice, pacePrice, specialOfferInfo = MDL.GuildAuction.GetItemPrices(auctionItem) --region -----------------一口价相关处理------------------------------------------------- if self.clickedInfoIndex then UIUtils.SetActive(self.group_FrameInfo, true) end local isFixedPrice = auctionItem.isFixedPrice local involvedHeadCount = #auctionItem.fixedPriceAcids local fixedPriceRemainTime = isFixedPrice and auctionItem.fixedPriceTime + fixedPriceDuration - UTL.Time.GetServerTimestamp() or nil local isSelfInvolvedHead = CTL.GuildAuction.IsItemFixedPriceSelfInvolved(auctionItem.fixedPriceAcids) if startPrice < 0 then UIUtils.SetActive(cellTable.group_PresentPrice, false) -- 起拍价小于0表示只有一口价 else UIUtils.SetActive(cellTable.group_PresentPrice, not isFixedPrice) end UIUtils.SetActive(cellTable.group_Time, not isFixedPrice) UIUtils.SetActive(cellTable.group_TimeCrossServer, isFixedPrice) UIUtils.SetLabel(cellTable.txt_fixPriceInfo, string.FormatByIdsId(Const_IDS["IDS_Auction_BiddingDesc1"], fixedPriceRemainTime and UTL.Time.FormatTimeSeconds(fixedPriceRemainTime))) UIUtils.SetLabel(cellTable.txt_headCount, string.FormatByIdsId(Const_IDS["IDS_Auction_BiddingDesc2"], involvedHeadCount)) UIUtils.SetActive(cellTable.btn_ItemServerList, auctionItem.zoneType and auctionItem.zoneType > 0) -- 显示折扣 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 --endregion local consumeItemData = DataSheetManager.ItemData:GetDataByID(auctionData.AuctionCoin) UTL.Item.SetAtlasSprite(cellTable.icon_Currency_Start, "UI_Common", consumeItemData.Icon) UTL.Item.SetAtlasSprite(cellTable.icon_Currency_Fixed, "UI_Common", consumeItemData.Icon) self:SetCacheItem(cellTable.Item, itemData.ID, auctionData.ItemNum) UIUtils.SetLabel(cellTable.txt_ItemName, auctionItem.itemName) UIUtils.SetActive(cellTable.group_Auction, false) UIUtils.SetActive(cellTable.group_Lead, false) if auctionItem.isOnSale and auctionItem.curPrice > 0 then UIUtils.SetActive(cellTable.group_Auction, auctionItem.ownerAcid ~= BattleDataGetter.GetAcID() or isFixedPrice) UIUtils.SetActive(cellTable.group_Lead, auctionItem.ownerAcid == BattleDataGetter.GetAcID() and not isFixedPrice) end local remainSeconds = auctionItem.endTime - UTL.Time.GetServerTimestamp() local timeStr = remainSeconds > 0 and UTL.Time.FormatTimeClockBySeconds(remainSeconds) or DefaultTimeShow UIUtils.SetLabel(cellTable.txt_Date, timeStr) UIUtils.SetLabelText(cellTable.txt_Time, auctionItem.isOnSale and Const_IDS["IDS_Auction_BiddingEndTime"] or Const_IDS["IDS_Auction_BiddingStartTime"]) UIUtils.SetLabel(cellTable.txt_CurPrice, auctionItem.curPrice > 0 and auctionItem.curPrice + pacePrice or startPrice) UIUtils.SetLabel(cellTable.txt_FixedPrice, highestPrice) UIUtils.SetActive(cellTable.icon_Heart, auctionItem.isCollect == true) UIUtils.SetActive(cellTable.icon_HeartEmpty, auctionItem.isCollect == false) cellTable.btn_Auction:SetGray(not auctionItem.isOnSale or auctionItem.ownerAcid == BattleDataGetter.GetAcID(), true) cellTable.btn_FixedPrice:SetGray(not auctionItem.isOnSale or isSelfInvolvedHead, true) end end function UIGuildAuctionMy:OnCellClicked(scrollRect, index, cellTable, target, auctionItem) if scrollRect == self.LoopScroll_My then local isForbid, isJoin = MDL.GuildAuction.GetAuctionLimit() if target == cellTable.icon_Heart then if auctionItem.ownerAcid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_FavouriteListCannotCancel"]) CTL.Sound.PlayGameSound("UI_invalid") return end CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_RemoveFromFavouriteListSucceed"], auctionItem.itemName) MDL.GuildAuction.RequestCancelCollect(auctionItem.auctionId) elseif target == cellTable.btn_Auction then if isForbid then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_CannotBiddingIntro"]) CTL.Sound.PlayGameSound("UI_invalid") return end if not auctionItem.isOnSale then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_BidNotOpen"]) CTL.Sound.PlayGameSound("UI_invalid") return end if auctionItem.ownerAcid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_WinnerCanNotBid"]) CTL.Sound.PlayGameSound("UI_invalid") return end CTL.GuildAuction.RequestAunctionItem(auctionItem) elseif target == cellTable.btn_FixedPrice then if isForbid then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_CannotBiddingIntro"]) CTL.Sound.PlayGameSound("UI_invalid") return end if not auctionItem.isOnSale then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_BidNotOpen"]) CTL.Sound.PlayGameSound("UI_invalid") return end local isSelfInvolvedHead = CTL.GuildAuction.IsItemFixedPriceSelfInvolved(auctionItem.fixedPriceAcids) if isSelfInvolvedHead then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Auction_BoughtByOthers"], auctionItem.itemName)) CTL.Sound.PlayGameSound("UI_invalid") return end CTL.GuildAuction.RequestBuyImmediately(auctionItem) elseif target == cellTable.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(auctionItem.itemData.ID) elseif target == cellTable.btn_Info then self.clickedInfoIndex = index UIUtils.SetActive(self.group_FrameInfo, true) self.group_FrameInfo.gameObject.transform:SetPosition(cellTable.group_Time.transform.position.x + 0.2, target.transform.position.y - 0.2, 0) elseif target == cellTable.btn_ItemServerList then if auctionItem.zoneType then local context = { serverList = MDL.GuildAuction.GetServerListByAuctionZoneType(auctionItem.zoneType), pos = cellTable.group_Left.transform.position, index = index } self.serverListTip_Canvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildAuctionServerListTips), context) end end end end ------------------------------------------------------------------- function UIGuildAuctionMy:RefreshPanel() local auctionItems if self.auctionHouseType and self.auctionHouseType == MDL.GuildAuction.AllAuctionType.SlgGvE then auctionItems = MDL.GuildAuction.GetGvEAuctionCollectionItems() else auctionItems = MDL.GuildAuction.GetAuctionCollectionItems() end if auctionItems and #auctionItems > 0 then self.LoopScroll_My:ReloadAll(auctionItems) else self.LoopScroll_My:ClearCells() end UIUtils.SetActive(self.group_Empty, self.LoopScroll_My.Count == 0) end function UIGuildAuctionMy:OnCellDispose(scrollRect, index, cellTable, auctionItem) self.cacheItems[cellTable.Item] = nil end function UIGuildAuctionMy:SetCacheItem(item, id, count) if self.cacheItems[item] == id then UTL.Item.SetItemCount(item, count) else UTL.Item.SetItemCell(item, id, count) self.cacheItems[item] = id end end return UIGuildAuctionMy