local UIPayMallMain = UIViewClass() local NUM_PREFIX = "X%s" local EventSystem = require('Event/EventSystem') -------------------------------- 系统函数 ------------------------------------ --[[ context = { tabId = xxx, 页签TabID itemId = xxx, 物品ID } ]]-- function UIPayMallMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_PayMall_RefreshMain, self.RefreshPanel) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_PayMall_RefreshGoodsUI, self.RefreshGoodsUI) self:RefreshGoodsUI(context) end function UIPayMallMain:RefreshGoodsUI(context) self.selectedTabIndex = context.TabIndex self.typeData = context.TypeData self:RefreshMonthCardPanel() self:RefreshCurrencyInfo() self:RefreshShowGoods() self:SelectedItem(context) end function UIPayMallMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Commodity then -- 商品名字和品质色BG local itemCfg = DataSheetManager.ItemData:GetDataByID(data.ItemID) -- 此处加载武将需要特殊处理 if itemCfg.FirstType == LuaConst.ItemType.HeroFragment then UIUtils.SetUICircleImageScaleRadiusAndOffset(cellTable.item, 0.45, 0) else UIUtils.SetUICircleImageScaleRadiusAndOffset(cellTable.item, 0, 0) end UTL.Item.SetStoreGoodsQualityImg(data.ItemID, cellTable.item, cellTable.img_NameBG, cellTable.img_ItemBg) if data.TabID == CTL.PayMall.PayMallMainTabId.Jade then cellTable.txt_Name:SetText(string.FormatByIdsId(Const_IDS[itemCfg.Name], itemCfg.ThirdType)) else cellTable.txt_Name:SetText(UIUtils.GetLocalizedTxt(Const_IDS[itemCfg.Name])) end -- 数量 local itemNum = string.format(NUM_PREFIX, UTL.String.GetCountStr(data.ItemNum)) UIUtils.SetLabel(cellTable.txt_Amount, itemNum) -- 价格 UTL.Item.MoneyIcon(cellTable.group_Price.icon, data.MoneyID) local isInDiscount, timeStr, singlePrice = CTL.PayMall.IsInDiscount(data) UIUtils.SetActive(cellTable.group_Price.txt_PriceBefore, isInDiscount) cellTable.group_Price.txt_PriceBefore.text = data.BuyPrice UIUtils.SetLabel(cellTable.group_Price.txt_PriceAfter, singlePrice) -- 折扣 UIUtils.SetActive(cellTable.group_Discount, isInDiscount) if isInDiscount then UIUtils.SetLabel(cellTable.txt_Discount, UTL.String.GetDiscountStrByIdsId(data.ItemDiscount)) end -- 限时 local isLimit, limitStr = CTL.PayMall.IsLimitedGood(data) UIUtils.SetActive(cellTable.group_Limit.gameObject, isLimit) UIUtils.SetLabel(cellTable.group_Limit.txt_Limit, CTL.PayMall.GetLimitedTitle(data)) UIUtils.SetLabel(cellTable.group_Limit.txt_Num, limitStr) -- 解锁 local isUnlock, des = CTL.PayMall.IsUnlockPurchase(data) if self.typeData.TabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop and not CTL.MonthCard.IsAllMonthCardActive() then UIUtils.SetActive(cellTable.group_NotArrive, false) else UIUtils.SetActive(cellTable.group_NotArrive, not isUnlock) UIUtils.SetLabel(cellTable.txt_Limit, des) end -- 售罄 local isSoldOut = CTL.PayMall.IsSoldOut(data) UIUtils.SetActive(cellTable.group_Soldout, isUnlock and isSoldOut) if isSoldOut then UIUtils.SetLabel(cellTable.txt_Soldout, CTL.PayMall.GetLimitedSoldout(data)) end -- 时间 UIUtils.SetActive(cellTable.group_Time, isUnlock and not isSoldOut and isInDiscount) UIUtils.SetActive(cellTable.time_Bg, not data.IsContinueDiscount) UIUtils.SetLabel(cellTable.txt_Time, timeStr) local isShowMain, isShowAssist = CTL.PayMall.GetItemUseState(data.ItemID) UIUtils.SetActive(cellTable.img_OnMain, isShowMain) UIUtils.SetActive(cellTable.img_OnAssist, isShowAssist) -- 售罄或未解锁置灰 if self.typeData.TabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then if isSoldOut then UIUtils.SetComponentBlack(cellTable.BlackNode, true) else UIUtils.SetComponentBlack(cellTable.BlackNode, false) end else UIUtils.SetComponentBlack(cellTable.BlackNode, not isUnlock or isSoldOut) end UIUtils.SetActive(cellTable.img_New, MDL.PayMall.GetMonthCardNewGoodRedPoint(data.ID)) end end function UIPayMallMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Commodity then CTL.PayMall.OpenPayMallPopUp(data) end end ------------------------------------------------------------------------------ function UIPayMallMain:RefreshCurrencyInfo() CTL.Currency.OpenCurrencyPanel(nil, self.currency_Info, self.typeData.MoneyTypeHUD) end function UIPayMallMain:RefreshShowGoods(selectItemIndex) self.loop_Commodity:ClearCells() for _, v in ipairs (MDL.PayMall.GetShowGoods(self.typeData.TabID)) do self.loop_Commodity:AddData(v, 0) end self.loop_Commodity:MoveIndex(selectItemIndex or 0) end function UIPayMallMain:RefreshPanel() self.loop_Commodity:ReloadAll(MDL.PayMall.GetShowGoods(self.typeData.TabID)) end function UIPayMallMain:SelectedItem(context) if self.typeData.TabID ~= CTL.PayMall.ShopChildTabType.DoubleMonthCardShop and CTL.PayMall.subTabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then MDL.PayMall.RemoveMonthCardNewGoodRedPoint() end if context ~= nil and context.itemId ~= nil then local tabIndex, itemIndex = MDL.PayMall.GetTabIndexAndItemIndex(context.itemId) self.loop_Commodity:SelectIndex(itemIndex) end end function UIPayMallMain:RefreshMonthCardPanel() if self.typeData.TabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.MonthCard, 1) if not CTL.MonthCard.IsAllMonthCardActive() then UIUtils.SetActive(self.group_Hint, true) else UIUtils.SetActive(self.group_Hint, false) end else UIUtils.SetActive(self.group_Hint, false) end end return UIPayMallMain