local UIOACommonStoreBase = UIViewClass() function UIOACommonStoreBase:OnOpened(context) self.activityId = context and context.activityId self.activityType = context and context.activityType self.tabParam = context and context.tabParam --额外的参数,目前在号令天下用来处理多页签 self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OACommon_StoreRefresh, self.RefreshPanel) self.currency_Info:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICurrencyPanel), {viewClassPath = self.__viewClassPath, currencyTypeIds = CTL.Currency.GetCurrentTypeIds(self.__viewClassPath), param = {activityType = self.activityType, activityId = self.activityId}}) self:InitView() self:RefreshPanel() end function UIOACommonStoreBase:OnClosed() end function UIOACommonStoreBase:OnClickClose() self:CloseView() end function UIOACommonStoreBase:InitView() self.loop_Goods = self.loop_OAStoreGood end function UIOACommonStoreBase:RefreshPanel(tabParam) if self.loop_Goods.Count > 0 then self.loop_Goods:ClearCells() end if tabParam then --目前仅用于号令天下传参,因为有多个Tab页,可通用 self.tabParam = tabParam end for i, v in MDL.OACommon.GetStoreGoodsEnumerator(self.activityType, self.activityId, self.tabParam) do self.loop_Goods:AddData(v, 0) end end function UIOACommonStoreBase:ShowGoodCell(cellTable, data) UTL.Item.SetItemCell(cellTable.UIItemBase, data.ItemID, data.ItemNum) local itemData = DataSheetManager.ItemData:GetDataByID(data.ItemID) UIUtils.SetLabelText(cellTable.txt_ItemName, Const_IDS[itemData.Name]) UTL.Item.SetCurrencyImageIcon(cellTable.img_MoneyIcon, data.MoneyID) UIUtils.SetLabel(cellTable.txt_SumNum, UTL.Item.GetItemStockCount(data.MoneyID) >= data.BuyPrice and data.BuyPrice or UTL.Color.FormatRedColor(data.BuyPrice)) UIUtils.SetActive(cellTable.group_Hot, data.IsRareItem) UIUtils.SetActive(cellTable.img_BgHigh, data.IsRareItem) local isLimit, limitStr = CTL.PayMall.IsLimitedGood(data, true) UIUtils.SetActive(cellTable.group_Remain, isLimit) UIUtils.SetLabel(cellTable.txt_RemainNum, limitStr) cellTable.btn_Buy:SetGray(CTL.PayMall.IsSoldOut(data), true) if self.showAddTips or GameAppInfo.IsJapanesePackage() then UTL.Item.SetFormationAndBreakLv(cellTable.UIItemBase, data.ItemID) end end function UIOACommonStoreBase:GoodCellClicked(cellTable, target, data) if target == cellTable.btn_Buy then if not CTL.OperationActivity.IsOperationActivityTypeOpen(self.activityType) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RebelStrike_NotAtActivityTime"]) self:CloseView() return end local curStackCount = UTL.Item.GetItemStockCount(data.MoneyID) if curStackCount >= data.BuyPrice and not CTL.PayMall.IsSoldOut(data) then --需要添加一个弹窗的逻辑 local goodData = MDL.OperationActivity.StoreGoodsData:GetDataByID(data.ID) CTL.PayMall.OpenPayMallPopUp(goodData, self.activityId, self.activityType) else if CTL.PayMall.IsSoldOut(data) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Monopoly_NoBuyTimes"]) elseif curStackCount < data.BuyPrice then CTL.Tips.AddTipsMsg(Const_IDS["IDS_GoldHeroActivity_Store_WrongHint2"]) end end elseif target == cellTable.UIItemBase.event_Click then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end --region 基类抽象出来的方法,一般不用重写 function UIOACommonStoreBase:OnButtonClicked(comp) if comp == self.btn_Close then self:OnClickClose() end end function UIOACommonStoreBase:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIOACommonStoreBase:OnCellInit(scrollRect, index, cellTable, data) self:ShowGoodCell(cellTable, data) end function UIOACommonStoreBase:OnCellClicked(scrollRect, index, cellTable, target, data) self:GoodCellClicked(cellTable, target, data) end --endregion return UIOACommonStoreBase