local UIDailyGiftMain = UIViewClass() function UIDailyGiftMain:OnOpened(context) self:RegistSystemEvent(EventID.TeamLevelUpdate, self.UpdateInfo) self:RegistSystemEvent(EventID.UI_DailyGift_Refresh, self.UpdateInfo) if self.loc_Title.CurState == 0 then UIUtils.SetLocalizationImage(self.img_Title, "mrlb_msz.png") end self.click_state:SetState(1) self.giftInfoList = {} self.giftRewardList = {} self:UpdateInfo() end function UIDailyGiftMain:UpdateInfo() local curLevel = MDL.Player.GetRoleLevel() --七测注释掉 --奖励变更 --self.buyLevel = 0 --for _, v in DataSheetManager.DailyGift:GetEnumerator() do -- if curLevel < v.LevelMin then -- self.buyLevel = v.LevelMin -- break -- end --end --if self.buyLevel == 0 then -- UIUtils.SetActive(self.group_Info, false) --else -- UIUtils.SetActive(self.group_Info, true) -- self.lab_Info.text = string.FormatByIdsId(Const_IDS.IDS_Gift_RewardChange, self.buyLevel) --end local index = 0 local sum = 0 for _, v in DataSheetManager.DailyGift:GetEnumerator() do if curLevel >= v.LevelMin and curLevel <= v.LevelMax then index = index + 1 local rewardID = v.Reward local item = self.group_Gifts[index] self.giftInfoList[index] = v -- 充值积分信息 local iapConfig = DataSheetManager.IAP:GetDataByIndex(v.IAPID) if iapConfig.Item_Condition_Table and iapConfig.Item_Condition_Table[1] then UIUtils.SetActive(item.lab_Txt, true) UIUtils.SetLabel(item.lab_Txt, string.FormatByIdsId( Const_IDS["IDS_TotalTopUp_Score_Tips_Giftbag"], iapConfig.Item_Condition_Table[1].GetAmount) ) else UIUtils.SetActive(item.lab_Txt, false) end --返利标识 item.txt_Times.text = string.FormatByIdsId(Const_IDS.IDS_Gift_Multiple, v.Rebate) --按钮状态 local state, receiveGiftId = MDL.DailyGift.GetGiftState(v.IAPID) -- 充值积分显示状态 UIUtils.SetActive(item.lab_Txt, state ~= MDL.DailyGift.DailyGiftState.HasGet and state ~= MDL.DailyGift.DailyGiftState.UnGet) if state == MDL.DailyGift.DailyGiftState.HasGet then item.obj_state:SetState(2) local receiveData = DataSheetManager.DailyGift:GetDataByID(receiveGiftId) rewardID = receiveData.Reward elseif state == MDL.DailyGift.DailyGiftState.UnGet then item.obj_state:SetState(1) item.btn_Get:SetRedPoint(true) else item.obj_state:SetState(0) item.lab_Buy.text = MDL.Currency.GetFullyIAPPrice(v.IAPID) end sum = sum + MDL.Currency.GetIAPPriceNum(v.IAPID) --固定奖励 --中间展示第一个奖励,滑动框展示剩下的奖励 local reward = DataSheetManager.DailyGiftReward:GetDataByID(rewardID) if reward then self.giftRewardList[index] = reward local item1 = item.item local reward1 = reward.Item_Table[1] UTL.Item.SetItemCell(item1, reward1.ItemID, reward1.ItemNum) CTL.DailyGift.SetEnumSourceData(reward.Item_Table) CSExt.CSFunc_ReloadAll(item.dailyGift_loop_Reward, CTL.DailyGift.EnumDailyGiftReward) end if MDL.Currency.IsNotShowRechargeButton() then item.obj_state:SetState(3) UIUtils.SetActive(item.lab_Txt, false) end UIUtils.SetActive(item.group_NewYear, CTL.NewYear.IsInCfgNewYearPeriod()) end end local info = MDL.DailyGift.GetDailyGiftInfo() local day = info and info.receiveDayNum or 0 if day > 0 then self.obj_state:SetState(1) self.buy_state:SetState(0) self.lab_Remain.text = string.FormatByIdsId(Const_IDS.IDS_Gift_DaysRemaining, day) UIUtils.SetActive(self.lab_Txt, false) else UIUtils.SetActive(self.lab_Txt, true) local buySum = MDL.DailyGift.GetBuySum() if string.isNilOrEmpty(buySum) == false then self.obj_state:SetState(1) self.buy_state:SetState(1) self.lab_Money.text = buySum else self.obj_state:SetState(0) --现价 local curIAP = DataSheetManager.ConstData:GetDataByID("DailyGiftCurrentPrice").IntValue local curPrice = MDL.Currency.GetFullyIAPPrice(curIAP) self.lab_Get.text = string.FormatByIdsId(Const_IDS.IDS_Gift_7DaysPurchase, curPrice) local amount = MDL.Currency.GetAmountByIAPIndex(curIAP) UIUtils.SetActive(self.lab_Txt, amount and true or false) if amount then UIUtils.SetLabel(self.lab_Txt, string.FormatByIdsId(Const_IDS["IDS_TotalTopUp_Score_Tips_Giftbag"], amount)) end --原价是将现价乘以7 local oriPriceNum = sum * 7 local oriPrice = MDL.Currency.FormatPriceNum(oriPriceNum) self.lab_Original.text = string.FormatByIdsId(Const_IDS.IDS_Gift_OriginalPrice, oriPrice) end end if MDL.Currency.IsNotShowRechargeButton() then self.obj_state:SetState(2) end --次日福利 local tomorrowReward = MDL.DailyGift.GetTomorrowWelfareReward() self.ItemID_tomorrow = tomorrowReward[1].ItemID UTL.Item.SetItemCell(self.item_tomorrow, tomorrowReward[1].ItemID, tomorrowReward[1].ItemNum) --每日福利 local todayReward = MDL.DailyGift.GetTodayWelfareReward() self.ItemID_today = todayReward[1].ItemID UTL.Item.SetItemCell(self.item_Daily, todayReward[1].ItemID, todayReward[1].ItemNum) local hasGet = info and info.welfareReceiveState or false if hasGet == false then self.btn_DailyGet:SetRedPoint(true) self.btn_DailyGet:SetGray(false) UIUtils.SetLabelText(self.lab_DailyGet, Const_IDS.IDS_Gift_Receive) else self.btn_DailyGet:SetRedPoint(false) self.btn_DailyGet:SetGray(true, false) UIUtils.SetLabelText(self.lab_DailyGet, Const_IDS.IDS_Gift_Received) end end function UIDailyGiftMain:OnCellInit(scrollRect, index, cellTable, data) for i = 1, 3 do local item = self.group_Gifts[i] if scrollRect == item.dailyGift_loop_Reward then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) break end end end function UIDailyGiftMain:OnCellClicked(scrollRect, index, cellTable, target, data) for i = 1, 3 do local item = self.group_Gifts[i] if scrollRect == item.dailyGift_loop_Reward then UTL.ItemTips.ShowCommonTipsById(data.ItemID) break end end end function UIDailyGiftMain:OnButtonClicked(comp) if comp == self.group_Info then self.click_state:SetState(0) self.txt_Info.text = string.FormatByIdsId(Const_IDS.IDS_Gift_RewardChangeTips, self.buyLevel) elseif comp == self.obj_click then self.click_state:SetState(1) elseif comp == self.btn_DailyGet then MDL.DailyGift.DailyGiftWelfareReq() elseif comp == self.btn_Get then local iap = DataSheetManager.ConstData:GetDataByID("DailyGiftCurrentPrice").IntValue MDL.Currency.GetOrderIDReq(iap, MDL.Currency.PayType.DailyGift, 0) elseif comp == self.btn_Info then CTL.DailyGift.OpenPreviewReward() elseif comp == self.btn_Info2 then UIUtils.SetActive(self.img_PopTip, true) elseif comp == self.img_PopTip then UIUtils.SetActive(self.img_PopTip, false) elseif comp == self.item_tomorrow.event_Click then UTL.ItemTips.ShowCommonTipsById(self.ItemID_tomorrow) elseif comp == self.item_Daily.event_Click then UTL.ItemTips.ShowCommonTipsById(self.ItemID_today) else for i = 1, 3 do local item = self.group_Gifts[i] local info = self.giftInfoList[i] if item.btn_Buy == comp then local iap = info.IAPID MDL.Currency.GetOrderIDReq(iap, MDL.Currency.PayType.DailyGift, info.ID) break elseif item.btn_Get == comp then local iap = info.IAPID MDL.DailyGift.DailyGiftReq(iap) break elseif item.item.event_Click == comp then local reward = self.giftRewardList[i] if reward then local itemID = reward.Item_Table[1].ItemID UTL.ItemTips.ShowCommonTipsById(itemID) end break end end end end return UIDailyGiftMain