local UIMonopolyStore = UIViewClass() ----------------------------- 系统函数 ----------------------------- function UIMonopolyStore:OnOpened() self:RegistSystemEvent(EventID.Monopoly_Store_Refresh, self.RefreshPanel) -- 开启奖励提示 self.activityId = self.context.activityId MDL.Reward.SetCloseRewardTipShow(false) --设置货币跳转activityId self.currency_Info:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICurrencyPanel), { viewClassPath = self.__viewClassPath, currencyTypeIds = CTL.Currency.GetCurrentTypeIds(self.__viewClassPath), param = { activityType = MDL.OperationActivity.ActivityType.Monopoly, activityId = self.activityId } }) self:RefreshPanel() end function UIMonopolyStore:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIMonopolyStore:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UIMonopolyStore:SetMoneyAndItemShow() if CTL.Monopoly.IsSuperGold(self.activityId) then local moneyId,itemId = MDL.Monopoly.GetMoneyAndItemShow(self.activityId) CTL.Currency.OpenCurrencyPanel(nil, self.currency_Info,{MDL.Currency.CurrencyType.GoldIngot,moneyId,itemId}) end end function UIMonopolyStore:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.ItemScroll then local goodData = CTL.Monopoly.GetGoodByIndex(self.activityId, data) UTL.Item.SetItemCell(cellTable.UIItemBase, goodData.ItemID, goodData.ItemNum) local itemData = DataSheetManager.ItemData:GetDataByID(goodData.ItemID) UIUtils.SetLabelText(cellTable.txt_ItemName, Const_IDS[itemData.Name]) UTL.Item.MoneyIcon(cellTable.img_MoneyIcon, goodData.MoneyID) UIUtils.SetLabel(cellTable.txt_SumNum, UTL.Item.GetItemStockCount(goodData.MoneyID) >= goodData.BuyPrice and goodData.BuyPrice or UTL.Color.FormatRedColor(goodData.BuyPrice)) UIUtils.SetActive(cellTable.group_Hot, goodData.IsRareItem) UIUtils.SetActive(cellTable.img_BgHigh, goodData.IsRareItem) local isLimit, limitStr = CTL.PayMall.IsLimitedGood(goodData, true) UIUtils.SetActive(cellTable.group_Remain, isLimit) UIUtils.SetLabel(cellTable.txt_RemainNum, limitStr) cellTable.btn_Buy:SetGray(CTL.PayMall.IsSoldOut(goodData), true) UTL.Item.SetFormationAndBreakLv(cellTable.UIItemBase, goodData.ItemID) end end function UIMonopolyStore:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.ItemScroll then local goodData = CTL.Monopoly.GetGoodByIndex(self.activityId, data) if target == cellTable.btn_Buy then if not CTL.OperationActivity.IsOperationActivityOpen(MDL.Monopoly.GetActivityInfo(self.activityId)) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RebelStrike_NotAtActivityTime"]) self:CloseView() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIMonopolyMainPanel) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIMonopolyMainPanel) end return end CTL.PayMall.OpenPayMallPopUp(goodData, self.activityId, MDL.OperationActivity.ActivityType.Monopoly, "IDS_Buy") elseif target == cellTable.UIItemBase.event_Click then UTL.ItemTips.ShowCommonTipsById(goodData.ItemID) end end end ------------------------------------------------------------------- function UIMonopolyStore:RefreshPanel(activityId, isRebuild) if activityId and activityId ~= self.activityId then return end if isRebuild then self.ItemScroll:ClearCells() end CTL.Monopoly.SortGoods(self.activityId) if self.ItemScroll.Count == 0 then for i = 1, CTL.Monopoly.GetGoodCount(self.activityId) do self.ItemScroll:AddData(i, 0) end else self.ItemScroll:RefreshCells(false) end self:SetMoneyAndItemShow() end return UIMonopolyStore