local UIPayMallPopUp = UIViewClass() local EventSystem = require('Event/EventSystem') local ColorStr = "%d" ------------------------------ 系统函数 ------------------------------------- function UIPayMallPopUp:OnCreated() self.keyBoardView = nil end function UIPayMallPopUp:OnOpened(context) self.activityId = 0 self.activityType = 0 if context.activityId then self.activityId = context.activityId self.activityType = context.activityType end self:RegistSystemEvent(EventID.UI_PayMall_RefreshPopUp, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_PayMall_SetCount, self.OnSetCount) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.OnDataChanged) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, context.titleIDS and Const_IDS[context.titleIDS] or Const_IDS["IDS_Item_Shop"]) self.goodData = context.goodData self.purchaseCount = 1 self.isLimit = false self.limitStr = "" self.availablePurchaseCount = 0 self.isInDiscount = false self.discountStr = "" self.singlePrice = 0 self:RefreshPanel() -- 动态HUD local curMoneyIds = CTL.Currency.GetCurrentTypeIds(self.__viewClassPath) local isContain = false for i, v in ipairs (curMoneyIds) do if v == self.goodData.MoneyID then isContain = true break end end if not isContain then local newMoneyIds = LuaExt.CreateTable(#curMoneyIds) for i, v in ipairs (curMoneyIds) do if v == MDL.Currency.CurrencyType.SilverCoin then newMoneyIds[i] = self.goodData.MoneyID else newMoneyIds[i] = v end end EventSystem.Dispatch(EventID.UI_Shop_Refresh_Currency, newMoneyIds, self.__viewClassPath) end EventSystem.Dispatch(EventID.UI_PayMall_RefreshMain) if self.activityId > 0 and GameAppInfo.IsJapanesePackage() and self.group_NumSelect.txt_Time then --该节点在日服专属的prefab下 UIPayMallPopUp_JP,代码完全一致,多了个节点显示时间 self.group_NumSelect.txt_Time.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_JP_MoneyConsumption_Period) .. MDL.OperationActivity.GetTimePeriodDesc(self.activityType, self.activityId) end --策划说这个页面不要退出商城后打开 self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) end function UIPayMallPopUp:OnDataChanged() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIPayMallPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIPayMallPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close or comp == self.btn_Cancel then self:CloseView() elseif comp == self.btn_Buy then if self.purchaseCount > 0 then -- 折扣变化 local formerIsDiscount = self.isInDiscount self.isInDiscount = CTL.PayMall.IsInDiscount(self.goodData) if formerIsDiscount ~= self.isInDiscount then self:RefreshPanel() EventSystem.Dispatch(EventID.UI_PayMall_RefreshMain) CTL.Tips.AddTipsMsg(Const_IDS.IDS_Store_ResetPrice) return end if CTL.PayMall.IsCanPurchase(self.goodData, self.purchaseCount) then MDL.Purchase.PurchaseItemsReq(self.goodData.ID, self.purchaseCount, self.activityId, self.activityType) self:CloseView() end end elseif comp == self.group_NumSelect.event_Plus then self:RefreshPurchaseCount(self.purchaseCount + 1 <= self.availablePurchaseCount and self.purchaseCount + 1 or self.purchaseCount) elseif comp == self.group_NumSelect.event_Minus then self:RefreshPurchaseCount(self.purchaseCount - 1 > 0 and self.purchaseCount - 1 or self.purchaseCount) elseif comp == self.group_NumSelect.event_Max then self:RefreshPurchaseCount(self.availablePurchaseCount) elseif comp == self.group_NumSelect.bg_NumSelect then if not self.keyBoardView then self.keyBoardView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIKeypad), {parentView = self, callBackParam = data, scale = 0.8, x = 384, y = 248, minNum = 1, maxNum = self.availablePurchaseCount}) end elseif comp == self.btn_UpdateMoonCard then CTL.ItemSources.ExecuteSourceFunctionById(MDL.ItemSources.SourceType.MonthCard) end end function UIPayMallPopUp:ExcuteKeyBoardBack(count, paramData) self:RefreshPurchaseCount(count) end function UIPayMallPopUp:CloseKeyBoardView() self.keyBoardView:CloseView() self.keyBoardView = nil end ----------------------------------------------------------------------------- function UIPayMallPopUp:RefreshPanel() self.isLimit, self.limitStr, self.availablePurchaseCount = CTL.PayMall.IsLimitedGood(self.goodData) self.isInDiscount, self.discountStr, self.singlePrice = CTL.PayMall.IsInDiscount(self.goodData) local itemCfg = DataSheetManager.ItemData:GetDataByID(self.goodData.ItemID) UTL.Item.SetItemCell(self.group_ItemInfo.item150, self.goodData.ItemID, self.goodData.ItemNum) UIUtils.SetLabel(self.group_ItemInfo.txt_ItemName, UTL.Item.GetItemColorName(self.goodData.ItemID)) UIUtils.SetLabelText(self.group_ItemInfo.txt_ItemType, Const_IDS[itemCfg.Tips]) UIUtils.SetLabel(self.group_ItemInfo.txt_BagCount, UTL.String.GetCountStr(UTL.Item.GetItemStockCount(self.goodData.ItemID))) local data = UTL.Item.GetItemDataSpliceByType(self.goodData.ItemID) UIUtils.SetLabel(self.group_ItemInfo.txt_Des, data.Des) UIUtils.SetActive(self.group_Price.group_Limit, self.isLimit) --活动类型 要单独显示限购文本 if self.activityId then UIUtils.SetLabel(self.group_Price.txt_LimitTitle, CTL.PayMall.GetLimitedTitle(self.goodData,true)) else UIUtils.SetLabel(self.group_Price.txt_LimitTitle, CTL.PayMall.GetLimitedTitle(self.goodData)) end UIUtils.SetLabel(self.group_Price.txt_LimitNum, self.limitStr) UTL.Item.SetCurrencyImageIcon(self.group_Price.icon, self.goodData.MoneyID) UTL.Item.SetCurrencyImageIcon(self.img_Icon, self.goodData.MoneyID) UIUtils.SetLabel(self.group_NumSelect.lab_Time, self.discountStr) self:RefreshPurchaseCount(self.availablePurchaseCount > 0 and 1 or 0) local isUnlock, des = CTL.PayMall.IsUnlockPurchase(self.goodData, true) UIUtils.SetActive(self.group_Btns, isUnlock) UIUtils.SetActive(self.group_Limit, not isUnlock) UIUtils.SetActive(self.group_Hint, false) if self.goodData.TabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then UIUtils.SetActive(self.group_Hint, not isUnlock) else UIUtils.SetLabel(self.txt_Limit, des) end self.btn_Buy:SetGray(CTL.PayMall.IsSoldOut(self.goodData), true) local isShow, showStr = CTL.PayMall.GetItemUpgradeInfo(self.goodData.ItemID) UIUtils.SetActive(self.group_ItemInfo.group_NeedNum, isShow) if isShow then UIUtils.SetLabel(self.group_ItemInfo.txt_Need, showStr) end UTL.Item.SetFormationAndBreakLv(self.group_ItemInfo.item150, self.goodData.ItemID) end function UIPayMallPopUp:RefreshPurchaseCount(purchaseCount) local canBuyCount, isEnough, costNum = CTL.PayMall.CalculateAvailablePurchase(self.goodData, purchaseCount) self.purchaseCount = canBuyCount UIUtils.SetLabel(self.group_NumSelect.txt_NumSelect, self.purchaseCount) local sumCost = self.singlePrice * self.purchaseCount self.group_Price.txt_Cost.text = self.singlePrice self.State_PriceTxt:SetState(not CTL.PayMall.IsCanPurchase(self.goodData, self.purchaseCount, true) and 1 or 0) UIUtils.SetLabel(self.txt_Price, sumCost) end function UIPayMallPopUp:OnSetCount(count) if count > self.availablePurchaseCount then count = self.availablePurchaseCount end self:RefreshPurchaseCount(count) end return UIPayMallPopUp